From 441b7e041b9c648f3ccc6616ee690d9178f7d988 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Thu, 27 Sep 2018 15:03:01 +0100 Subject: [PATCH] MULES: Added optional boundaryExtremaCoeff This provides more flexibility in specifying the allowed internal and boundary extrema. For driftFluxFoam and other settling problems it is beneficial to set the boundaryExtremaCoeff to 1 to allow rapid accumulation of the partials on the bottom wall (which was the previous default behaviour) but this is not suitable for many Euler-Euler cases for which a uniform etrema coefficient is preferable, either 0 or a small value. Now by default boundaryExtremaCoeff is set to extremaCoeff which defaults to 0 which provides the behaviour before OpenFOAM-dev commit cb2bc60fa557943bb5657d46b5f69538101f9e97 and the driftFluxFoam tutorials have been updated adding boundaryExtremaCoeff 1; to the MULES controls in fvSolution so reproduce the previous behaviour. --- src/OpenFOAM/primitives/one/oneI.H | 24 +++++++++++++++ .../solvers/MULES/CMULESTemplates.C | 30 ++++++++++++++++--- .../fvMatrices/solvers/MULES/MULESTemplates.C | 30 ++++++++++++++++--- .../driftFluxFoam/RAS/dahl/system/fvSolution | 2 ++ .../RAS/mixerVessel2D/system/fvSolution | 2 ++ .../RAS/tank3D/system/fvSolution | 2 ++ 6 files changed, 82 insertions(+), 8 deletions(-) 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;