diff --git a/src/OpenFOAM/primitives/one/oneI.H b/src/OpenFOAM/primitives/one/oneI.H index 3d1e0898de..5be4bc3f88 100644 --- a/src/OpenFOAM/primitives/one/oneI.H +++ b/src/OpenFOAM/primitives/one/oneI.H @@ -41,6 +41,30 @@ public: typedef arg2 type; }; +template +inline const Type& operator+(const Type& t, const one&) +{ + return t + 1; +} + +template +inline const Type& operator+(const one&, const Type& t) +{ + return 1 + t; +} + +template +inline const Type& operator-(const Type& t, const one&) +{ + return t - 1; +} + +template +inline const Type& operator-(const one&, const Type& t) +{ + return 1 - t; +} + inline const one& operator*(const one& o, const one&) { return o; diff --git a/src/finiteVolume/fvMatrices/solvers/MULES/CMULESTemplates.C b/src/finiteVolume/fvMatrices/solvers/MULES/CMULESTemplates.C index 9fa61573ed..f43e43e43c 100644 --- a/src/finiteVolume/fvMatrices/solvers/MULES/CMULESTemplates.C +++ b/src/finiteVolume/fvMatrices/solvers/MULES/CMULESTemplates.C @@ -233,6 +233,20 @@ void Foam::MULES::limiterCorr MULEScontrols.lookupOrDefault("extremaCoeff", 0) ); + const scalar boundaryExtremaCoeff + ( + MULEScontrols.lookupOrDefault + ( + "boundaryExtremaCoeff", + extremaCoeff + ) + ); + + const scalar boundaryDeltaExtremaCoeff + ( + max(boundaryExtremaCoeff - extremaCoeff, 0) + ); + const labelUList& owner = mesh.owner(); const labelUList& neighb = mesh.neighbour(); tmp tVsc = mesh.Vsc(); @@ -331,12 +345,20 @@ void Foam::MULES::limiterCorr } else { - forAll(phiCorrPf, pFacei) + // Add the optional additional allowed boundary extrema + if (boundaryDeltaExtremaCoeff > 0) { - const label pfCelli = pFaceCells[pFacei]; + forAll(phiCorrPf, pFacei) + { + const label pfCelli = pFaceCells[pFacei]; + + const scalar extrema = + boundaryDeltaExtremaCoeff + *(psiMax[pfCelli] - psiMin[pfCelli]); - psiMaxn[pfCelli] = max(psiMaxn[pfCelli], psiMax[pfCelli]); - psiMinn[pfCelli] = min(psiMinn[pfCelli], psiMin[pfCelli]); + psiMaxn[pfCelli] += extrema; + psiMinn[pfCelli] -= extrema; + } } } diff --git a/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C b/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C index 65b921ed67..251b799a71 100644 --- a/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C +++ b/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C @@ -224,6 +224,20 @@ void Foam::MULES::limiter MULEScontrols.lookupOrDefault("extremaCoeff", 0) ); + const scalar boundaryExtremaCoeff + ( + MULEScontrols.lookupOrDefault + ( + "boundaryExtremaCoeff", + extremaCoeff + ) + ); + + const scalar boundaryDeltaExtremaCoeff + ( + max(boundaryExtremaCoeff - extremaCoeff, 0) + ); + const scalarField& psi0 = psi.oldTime(); const labelUList& owner = mesh.owner(); @@ -330,12 +344,20 @@ void Foam::MULES::limiter } else { - forAll(phiCorrPf, pFacei) + // Add the optional additional allowed boundary extrema + if (boundaryDeltaExtremaCoeff > 0) { - const label pfCelli = pFaceCells[pFacei]; + forAll(phiCorrPf, pFacei) + { + const label pfCelli = pFaceCells[pFacei]; + + const scalar extrema = + boundaryDeltaExtremaCoeff + *(psiMax[pfCelli] - psiMin[pfCelli]); - psiMaxn[pfCelli] = max(psiMaxn[pfCelli], psiMax[pfCelli]); - psiMinn[pfCelli] = min(psiMinn[pfCelli], psiMin[pfCelli]); + psiMaxn[pfCelli] += extrema; + psiMinn[pfCelli] -= extrema; + } } } diff --git a/tutorials/multiphase/driftFluxFoam/RAS/dahl/system/fvSolution b/tutorials/multiphase/driftFluxFoam/RAS/dahl/system/fvSolution index 95a23401a5..ce36225626 100644 --- a/tutorials/multiphase/driftFluxFoam/RAS/dahl/system/fvSolution +++ b/tutorials/multiphase/driftFluxFoam/RAS/dahl/system/fvSolution @@ -26,6 +26,8 @@ solvers nLimiterIter 3; alphaApplyPrevCorr yes; + boundaryExtremaCoeff 1; + solver smoothSolver; smoother symGaussSeidel; tolerance 1e-6; diff --git a/tutorials/multiphase/driftFluxFoam/RAS/mixerVessel2D/system/fvSolution b/tutorials/multiphase/driftFluxFoam/RAS/mixerVessel2D/system/fvSolution index 97244e10a1..3e6394c7f8 100644 --- a/tutorials/multiphase/driftFluxFoam/RAS/mixerVessel2D/system/fvSolution +++ b/tutorials/multiphase/driftFluxFoam/RAS/mixerVessel2D/system/fvSolution @@ -26,6 +26,8 @@ solvers nLimiterIter 3; alphaApplyPrevCorr yes; + boundaryExtremaCoeff 1; + solver smoothSolver; smoother symGaussSeidel; tolerance 1e-6; diff --git a/tutorials/multiphase/driftFluxFoam/RAS/tank3D/system/fvSolution b/tutorials/multiphase/driftFluxFoam/RAS/tank3D/system/fvSolution index 825d041bce..a675081006 100644 --- a/tutorials/multiphase/driftFluxFoam/RAS/tank3D/system/fvSolution +++ b/tutorials/multiphase/driftFluxFoam/RAS/tank3D/system/fvSolution @@ -26,6 +26,8 @@ solvers nLimiterIter 3; alphaApplyPrevCorr yes; + boundaryExtremaCoeff 1; + solver smoothSolver; smoother symGaussSeidel; tolerance 1e-6;