From 3f69f324d72b008215bd23da7853f7d77bcc8649 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Thu, 17 Mar 2016 10:21:18 +0000 Subject: [PATCH] New gradient limiter implementation and rewrite --- src/dbns/limiter/MDLimiter.H | 24 +-- src/finiteVolume/Make/files | 4 + .../cellLimitedGrad/cellLimitedGrads.C | 7 +- .../cellMDLimitedGrad/cellMDLimitedGrad.H | 6 +- .../limitedGrad/LimitedGrad.C | 62 ++++---- .../minModGrad/minModGrad.H | 139 ------------------ .../minModGrad/minModGrads.C | 89 ----------- .../venkatakrishnanGrad/venkatakrishnanGrad.H | 2 +- .../gradientLimiters/BarthJespersenLimiter.H | 24 ++- .../gradientLimiters/MinModLimiter.H | 126 ---------------- .../gradientLimiters/VenkatakrishnanLimiter.H | 34 ++--- .../gradientLimiters/WangLimiter.H | 28 ++-- 12 files changed, 94 insertions(+), 451 deletions(-) delete mode 100644 src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/minModGrad/minModGrad.H delete mode 100644 src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/minModGrad/minModGrads.C delete mode 100644 src/finiteVolume/finiteVolume/gradientLimiters/MinModLimiter.H diff --git a/src/dbns/limiter/MDLimiter.H b/src/dbns/limiter/MDLimiter.H index 5bfb3557f..98858ca49 100644 --- a/src/dbns/limiter/MDLimiter.H +++ b/src/dbns/limiter/MDLimiter.H @@ -191,8 +191,6 @@ public: const GradFieldType& gradPhiIn = gradPhi.internalField(); // Compute limiter values, internal faces - Type phiOwnerLimiter, phiNeighbourLimiter; - forAll (owner, faceI) { const label& own = owner[faceI]; @@ -201,10 +199,12 @@ public: vector deltaRLeft = faceCentre[faceI] - cellCentre[own]; vector deltaRRight = faceCentre[faceI] - cellCentre[nei]; + // Find minimal limiter value in each cell + // Owner side limitFunction.limiter ( - phiOwnerLimiter, + phiLimiterIn[own], cellVolume[own], phiMaxIn[own] - phi_[own], phiMinIn[own] - phi_[own], @@ -214,19 +214,12 @@ public: // Neighbour side limitFunction.limiter ( - phiNeighbourLimiter, + phiLimiterIn[nei], cellVolume[nei], phiMaxIn[nei] - phi_[nei], phiMinIn[nei] - phi_[nei], (deltaRRight & gradPhiIn[nei]) ); - - // Find minimal limiter value in each cell - phiLimiterIn[own] = - min(phiLimiterIn[own], phiOwnerLimiter); - - phiLimiterIn[nei] = - min(phiLimiterIn[nei], phiNeighbourLimiter); } // Coupled boundaries @@ -251,24 +244,19 @@ public: const GradFieldType gradPhiRight = gradPhi.boundaryField()[patchI].patchNeighbourField(); - Type phiFCLimiter; - + // Find minimal limiter value in each cell forAll (fc, faceI) { const label& curFC = fc[faceI]; limitFunction.limiter ( - phiFCLimiter, + phiLimiterIn[curFC], cellVolume[curFC], phiMaxIn[curFC] - phi_[curFC], phiMinIn[curFC] - phi_[curFC], (deltaR[faceI] & gradPhiLeft[faceI]) ); - - // Find minimal limiter value in each cell - phiLimiterIn[curFC] = - min(phiLimiterIn[curFC], phiFCLimiter); } } } diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 3d1c444b9..b0bdb2995 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -358,6 +358,10 @@ $(limitedGradSchemes)/faceLimitedGrad/faceLimitedGrads.C $(limitedGradSchemes)/cellLimitedGrad/cellLimitedGrads.C $(limitedGradSchemes)/faceMDLimitedGrad/faceMDLimitedGrads.C $(limitedGradSchemes)/cellMDLimitedGrad/cellMDLimitedGrads.C +$(limitedGradSchemes)/barthJespersenGrad/barthJespersenGrads.C +$(limitedGradSchemes)/venkatakrishnanGrad/venkatakrishnanGrads.C +$(limitedGradSchemes)/wangGrad/wangGrads.C +$(limitedGradSchemes)/michalakGoochGrad/michalakGoochGrads.C snGradSchemes = finiteVolume/snGradSchemes $(snGradSchemes)/snGradScheme/snGradSchemes.C diff --git a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellLimitedGrad/cellLimitedGrads.C b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellLimitedGrad/cellLimitedGrads.C index 3018950f3..c90da3834 100644 --- a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellLimitedGrad/cellLimitedGrads.C +++ b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellLimitedGrad/cellLimitedGrads.C @@ -66,6 +66,7 @@ inline void cellLimitedGrad::limitFace } } + template inline void cellLimitedGrad::limitFace ( @@ -229,7 +230,7 @@ tmp cellLimitedGrad::calcGrad if (fv::debug) { - Info<< "gradient limiter for: " << vsf.name() + Info<< "Explicit scalar gradient limiter for: " << vsf.name() << " max = " << gMax(limiter) << " min = " << gMin(limiter) << " average: " << gAverage(limiter) << endl; @@ -381,7 +382,7 @@ tmp cellLimitedGrad::calcGrad if (fv::debug) { - Info<< "gradient limiter for: " << vsf.name() + Info<< "Explicit vector gradient limiter for: " << vsf.name() << " max = " << gMax(limiter) << " min = " << gMin(limiter) << " average: " << gAverage(limiter) << endl; @@ -563,7 +564,7 @@ tmp > cellLimitedGrad::fvmGrad if (fv::debug) { - Info<< "gradient limiter for: " << vsf.name() + Info<< "Implicit scalar gradient limiter for: " << vsf.name() << " max = " << gMax(lfIn) << " min = " << gMin(lfIn) << " average: " << gAverage(lfIn) << endl; diff --git a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellMDLimitedGrad/cellMDLimitedGrad.H b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellMDLimitedGrad/cellMDLimitedGrad.H index 5ae805d3a..313440557 100644 --- a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellMDLimitedGrad/cellMDLimitedGrad.H +++ b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellMDLimitedGrad/cellMDLimitedGrad.H @@ -141,7 +141,11 @@ inline void cellMDLimitedGrad::limitFace { scalar extrapolate = dcf & g; - if (extrapolate > maxDelta) + if (mag(extrapolate) < SMALL) + { + // Limiter remains unchanged + } + else if (extrapolate > maxDelta) { g = g + dcf*(maxDelta - extrapolate)/magSqr(dcf); } diff --git a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/limitedGrad/LimitedGrad.C b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/limitedGrad/LimitedGrad.C index 98c889e41..3092c9231 100644 --- a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/limitedGrad/LimitedGrad.C +++ b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/limitedGrad/LimitedGrad.C @@ -67,16 +67,13 @@ LimitedGrad::limiter label own = owner[faceI]; label nei = neighbour[faceI]; - const Type& vfOwn = vfIn[own]; - const Type& vfNei = vfIn[nei]; - // Owner side - maxVf[own] = max(maxVf[own], vfNei); - minVf[own] = min(minVf[own], vfNei); + maxVf[own] = Foam::max(maxVf[own], vfIn[nei]); + minVf[own] = Foam::min(minVf[own], vfIn[nei]); // Neighbour side - maxVf[nei] = max(maxVf[nei], vfOwn); - minVf[nei] = min(minVf[nei], vfOwn); + maxVf[nei] = Foam::max(maxVf[nei], vfIn[own]); + minVf[nei] = Foam::min(minVf[nei], vfIn[own]); } const GeoBoundaryFieldType& bf = vf.boundaryField(); @@ -96,10 +93,9 @@ LimitedGrad::limiter forAll (pOwner, pFaceI) { label own = pOwner[pFaceI]; - Type vfNei = psfNei[pFaceI]; - maxVf[own] = max(maxVf[own], vfNei); - minVf[own] = min(minVf[own], vfNei); + maxVf[own] = Foam::max(maxVf[own], psfNei[pFaceI]); + minVf[own] = Foam::min(minVf[own], psfNei[pFaceI]); } } else @@ -108,18 +104,20 @@ LimitedGrad::limiter forAll (pOwner, pFaceI) { label own = pOwner[pFaceI]; - Type vfNei = psf[pFaceI]; + const Type& vfNei = psf[pFaceI]; - maxVf[own] = max(maxVf[own], vfNei); - minVf[own] = min(minVf[own], vfNei); + maxVf[own] = Foam::max(maxVf[own], vfNei); + minVf[own] = Foam::min(minVf[own], vfNei); } } } // Subtract the cell value to get differences - maxVf -= vf; - minVf -= vf; - + // Stabilise differences for round-off error, since maxVf must be + // positive or zero and minVf must be negative or zero + // HJ, 1/Feb/2016 + maxVf = Foam::max(maxVf - vf, pTraits::zero); + minVf = Foam::min(minVf - vf, pTraits::zero); // Create a limiter tmp tlimitField @@ -135,14 +133,18 @@ LimitedGrad::limiter IOobject::NO_WRITE ), mesh, - dimensioned("zero", dimless, pTraits::zero), + dimensioned("zero", dimless, pTraits::one), zeroGradientFvPatchField::typeName ) ); GeoFieldType& limitField = tlimitField(); const volVectorField& C = mesh.C(); + const vectorField& CIn = C.internalField(); + const surfaceVectorField& Cf = mesh.Cf(); + const vectorField& CfIn = Cf.internalField(); + const scalarField& vols = mesh.V().field(); Field& lfIn = limitField.internalField(); @@ -164,7 +166,7 @@ LimitedGrad::limiter vols[own], maxVf[own], minVf[own], - (Cf[faceI] - C[own]) & g[own] + (CfIn[faceI] - CIn[own]) & g[own] ); // Neighbour side @@ -174,7 +176,7 @@ LimitedGrad::limiter vols[nei], maxVf[nei], minVf[nei], - (Cf[faceI] - C[nei]) & g[nei] + (CfIn[faceI] - CIn[nei]) & g[nei] ); } @@ -199,7 +201,7 @@ LimitedGrad::limiter } // Update coupled boundaries for patchNeighbourField - limitField.boundaryField().evaluateCoupled(); + limitField.correctBoundaryConditions(); if (fv::debug) { @@ -234,7 +236,7 @@ LimitedGrad::gradientField GeoGradFieldType& gradVf = tGrad(); // Apply the limiter - GeoFieldType limitField = this->limiter(vf, gradVf); + GeoFieldType limitField(this->limiter(vf, gradVf)); gradVf.internalField() = scaleRow(gradVf.internalField(), limitField.internalField()); @@ -261,11 +263,15 @@ LimitedGrad::gradientMatrix GradMatrixType& bs = tbs(); // Calculate limiter. Using explicit gradient - GeoFieldType limitField = this->limiter + GeoFieldType limitField ( - vf, - basicGradScheme_().grad(vf)() + this->limiter + ( + vf, + basicGradScheme_().grad(vf)() + ) ); + const Field& lfIn = limitField.internalField(); typedef typename CoeffField::linearTypeField @@ -288,14 +294,14 @@ LimitedGrad::gradientMatrix const unallocLabelList& owner = mesh.owner(); const unallocLabelList& neighbour = mesh.neighbour(); - forAll(u, faceI) + forAll (u, faceI) { u[faceI] = scaleRow(u[faceI], lfIn[owner[faceI]]); l[faceI] = scaleRow(l[faceI], lfIn[neighbour[faceI]]); } // Limit diag and source coeffs - forAll(d, cellI) + forAll (d, cellI) { d[cellI] = scaleRow(d[cellI], lfIn[cellI]); @@ -303,7 +309,7 @@ LimitedGrad::gradientMatrix } // Limit coupling coeffs - forAll(vf.boundaryField(), patchI) + forAll (vf.boundaryField(), patchI) { const fvPatchField& pf = vf.boundaryField()[patchI]; const fvPatch& patch = pf.patch(); @@ -321,7 +327,7 @@ LimitedGrad::gradientMatrix const Field lfNei = limitField.boundaryField()[patchI].patchNeighbourField(); - forAll(pf, faceI) + forAll (pf, faceI) { pcoupleUpper[faceI] = scaleRow(pcoupleUpper[faceI], lfIn[fc[faceI]]); diff --git a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/minModGrad/minModGrad.H b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/minModGrad/minModGrad.H deleted file mode 100644 index 0232248fe..000000000 --- a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/minModGrad/minModGrad.H +++ /dev/null @@ -1,139 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | foam-extend: Open Source CFD - \\ / O peration | Version: 3.2 - \\ / A nd | Web: http://www.foam-extend.org - \\/ M anipulation | For copyright notice see file Copyright -------------------------------------------------------------------------------- -License - This file is part of foam-extend. - - foam-extend is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation, either version 3 of the License, or (at your - option) any later version. - - foam-extend is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with foam-extend. If not, see . - -Class - Foam::fv::minModGrad - -Description - MinMod gradient limiter applied to a runTime selected - base gradient scheme. - -SourceFiles - minModGrad.C - -\*---------------------------------------------------------------------------*/ - -#ifndef minModGrad_H -#define minModGrad_H - -#include "gradScheme.H" -#include "LimitedGrad.H" -#include "MinModLimiter.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace fv -{ - -/*---------------------------------------------------------------------------*\ - Class minModGrad Declaration -\*---------------------------------------------------------------------------*/ - -template -class minModGrad -: - public fv::gradScheme, - public LimitedGrad -{ - // Private Member Functions - - //- Disallow default bitwise copy construct - minModGrad(const minModGrad&); - - //- Disallow default bitwise assignment - void operator=(const minModGrad&); - - -public: - - //- RunTime type information - TypeName("minMod"); - - - // Constructors - - //- Construct from mesh and schemeData - minModGrad(const fvMesh& mesh, Istream& schemeData) - : - gradScheme(mesh), - LimitedGrad(mesh, schemeData) - {} - - - // Member Functions - - //- Return the gradient of the given field to the gradScheme::grad - // for optional caching - virtual tmp - < - GeometricField - ::type, fvPatchField, volMesh> - > calcGrad - ( - const GeometricField& vf, - const word& name - ) const - { - return LimitedGrad::gradientField - ( - vf, - name - ); - } - - //- Return the BlockLduSystem corresponding to the implicit cell - // limited grad discretization. For block coupled systems. - virtual tmp - < - BlockLduSystem::type> - > fvmGrad - ( - const GeometricField& vf - ) const - { - return LimitedGrad::gradientMatrix - ( - vf - ); - } -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace fv - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/minModGrad/minModGrads.C b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/minModGrad/minModGrads.C deleted file mode 100644 index 34aa93b73..000000000 --- a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/minModGrad/minModGrads.C +++ /dev/null @@ -1,89 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | foam-extend: Open Source CFD - \\ / O peration | Version: 3.2 - \\ / A nd | Web: http://www.foam-extend.org - \\/ M anipulation | For copyright notice see file Copyright -------------------------------------------------------------------------------- -License - This file is part of foam-extend. - - foam-extend is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation, either version 3 of the License, or (at your - option) any later version. - - foam-extend is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with foam-extend. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "minModGrad.H" -#include "fvMesh.H" -#include "volMesh.H" -#include "surfaceMesh.H" -#include "volFields.H" -#include "fixedValueFvPatchFields.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace fv -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -makeFvGradScheme(minModGrad) - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - - -template<> -tmp -< - BlockLduSystem::type> -> -minModGrad::fvmGrad -( - const volVectorField& vf -) const -{ - FatalErrorIn - ( - "tmp minModGrad::fvmGrad\n" - "(\n" - " GeometricField&" - ")\n" - ) << "Implicit gradient operators with cell limiters defined only for " - << "scalar." - << abort(FatalError); - - typedef outerProduct::type GradType; - - tmp > tbs - ( - new BlockLduSystem(vf.mesh()) - ); - - return tbs; -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace fv - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/venkatakrishnanGrad/venkatakrishnanGrad.H b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/venkatakrishnanGrad/venkatakrishnanGrad.H index 5b57e51ce..f73155d0e 100644 --- a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/venkatakrishnanGrad/venkatakrishnanGrad.H +++ b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/venkatakrishnanGrad/venkatakrishnanGrad.H @@ -26,7 +26,7 @@ Class Description Venkatakrishnan gradient limiter applied to a runTime selected - base gradient scheme. + base gradient scheme. SourceFiles venkatakrishnanGrad.C diff --git a/src/finiteVolume/finiteVolume/gradientLimiters/BarthJespersenLimiter.H b/src/finiteVolume/finiteVolume/gradientLimiters/BarthJespersenLimiter.H index c715ba6e9..39c339624 100644 --- a/src/finiteVolume/finiteVolume/gradientLimiters/BarthJespersenLimiter.H +++ b/src/finiteVolume/finiteVolume/gradientLimiters/BarthJespersenLimiter.H @@ -28,15 +28,14 @@ Description Barth-Jespersen limiter Author - Aleksandar Jemcov, Hrvoje Jasak + Aleksandar Jemcov + Rewrite by Hrvoje Jasak \*---------------------------------------------------------------------------*/ #ifndef BarthJespersenLimiter_H #define BarthJespersenLimiter_H -#include "vector.H" - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -74,19 +73,16 @@ public: { if (mag(extrapolate) < SMALL) { - lim = 1; + return; } - else + + if (extrapolate - deltaOneMax > SMALL) { - lim = min - ( - max - ( - max(deltaOneMax/extrapolate, 0), - max(deltaOneMin/extrapolate, 0) - ), - 1 - ); + lim = min(lim, deltaOneMax/extrapolate); + } + else if (extrapolate - deltaOneMin < -SMALL) + { + lim = min(lim, deltaOneMin/extrapolate); } } diff --git a/src/finiteVolume/finiteVolume/gradientLimiters/MinModLimiter.H b/src/finiteVolume/finiteVolume/gradientLimiters/MinModLimiter.H deleted file mode 100644 index 74def91d5..000000000 --- a/src/finiteVolume/finiteVolume/gradientLimiters/MinModLimiter.H +++ /dev/null @@ -1,126 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | foam-extend: Open Source CFD - \\ / O peration | Version: 3.2 - \\ / A nd | Web: http://www.foam-extend.org - \\/ M anipulation | For copyright notice see file Copyright -------------------------------------------------------------------------------- -License - This file is part of foam-extend. - - foam-extend is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation, either version 3 of the License, or (at your - option) any later version. - - foam-extend is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with foam-extend. If not, see . - -Class - MinModLimiter - -Description - Non-differentiable cell limiter. The limiter limits the gradient such - that the extrapolated face value does not under- or over-shoot the - neighbouring cell values - -Author - Hrvoje Jasak - -\*---------------------------------------------------------------------------*/ - -#ifndef MinModLimiter_H -#define MinModLimiter_H - -#include "vector.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class MinModLimiter Declaration -\*---------------------------------------------------------------------------*/ - -class MinModLimiter -{ -public: - - // Constructors - - //- Construct null - MinModLimiter() - {} - - - // Destructor - default - - - // Member functions - - //- Set scalar limiter value - inline void limiter - ( - scalar& lim, - const scalar& cellVolume, - const scalar& deltaOneMax, - const scalar& deltaOneMin, - const scalar& extrapolate - ) - { - if (mag(extrapolate) < SMALL) - { - lim = 1; - } - else - { - if (extrapolate > deltaOneMax + VSMALL) - { - lim = min(1, deltaOneMax/extrapolate); - } - else if (extrapolate < deltaOneMin - VSMALL) - { - lim = min(1, deltaOneMin/extrapolate); - } - } - } - - //- Set Type limiter - template - inline void limiter - ( - Type& lim, - const scalar& cellVolume, - const Type& deltaOneMax, - const Type& deltaOneMin, - const Type& extrapolate - ) - { - for (direction cmpt = 0; cmpt < Type::nComponents; cmpt++) - { - limiter - ( - lim.component(cmpt), - cellVolume, - deltaOneMax.component(cmpt), - deltaOneMin.component(cmpt), - extrapolate.component(cmpt) - ); - } - } -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -#endif - -// ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/gradientLimiters/VenkatakrishnanLimiter.H b/src/finiteVolume/finiteVolume/gradientLimiters/VenkatakrishnanLimiter.H index 1b6516753..c1ebb7f62 100644 --- a/src/finiteVolume/finiteVolume/gradientLimiters/VenkatakrishnanLimiter.H +++ b/src/finiteVolume/finiteVolume/gradientLimiters/VenkatakrishnanLimiter.H @@ -29,15 +29,13 @@ Description Author Aleksandar Jemcov - Updated by Hrvoje Jasak + Rewrite by Hrvoje Jasak \*---------------------------------------------------------------------------*/ #ifndef VenkatakrishnanLimiter_H #define VenkatakrishnanLimiter_H -#include "vector.H" - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -77,10 +75,16 @@ public: { scalar epsilonSquare = pow3(k_)*cellVolume; - if (extrapolate > SMALL) + if (mag(extrapolate) < SMALL) + { + // Limiter remains unchanged + return; + } + else if (extrapolate > VSMALL) { lim = max ( + 0, min ( ( @@ -92,21 +96,21 @@ public: extrapolate* ( sqr(deltaOneMax) - + 2.0*sqr(extrapolate) + + 2*sqr(extrapolate) + deltaOneMax*extrapolate + epsilonSquare ), SMALL ), - 1 - ), - 0 + lim + ) ); } - else if (extrapolate < SMALL) + else if (extrapolate < VSMALL) { lim = max ( + 0, min ( ( @@ -118,20 +122,16 @@ public: extrapolate* ( sqr(deltaOneMin) - + 2.0*sqr(extrapolate) + deltaOneMin*extrapolate + + 2*sqr(extrapolate) + + deltaOneMin*extrapolate + epsilonSquare ), SMALL ), - 1 - ), - 0 + lim + ) ); } - else - { - lim = 1; - } } //- Set Type limiter diff --git a/src/finiteVolume/finiteVolume/gradientLimiters/WangLimiter.H b/src/finiteVolume/finiteVolume/gradientLimiters/WangLimiter.H index a0b6c81f6..6424eb962 100644 --- a/src/finiteVolume/finiteVolume/gradientLimiters/WangLimiter.H +++ b/src/finiteVolume/finiteVolume/gradientLimiters/WangLimiter.H @@ -28,16 +28,13 @@ Description Wang differentiable limiter Author - Aleksandar Jemcov - Updated by Hrvoje Jasak + Hrvoje Jasak \*---------------------------------------------------------------------------*/ #ifndef WangLimiter_H #define WangLimiter_H -#include "vector.H" - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -78,10 +75,11 @@ public: scalar epsilonSquare = sqr(epsilonPrime_*(deltaOneMax - deltaOneMin)); - if (extrapolate > SMALL) + if (extrapolate > VSMALL) { lim = max ( + 0, min ( ( @@ -93,21 +91,21 @@ public: extrapolate* ( sqr(deltaOneMax) - + 2.0*sqr(extrapolate) + + 2*sqr(extrapolate) + deltaOneMax*extrapolate + epsilonSquare ), SMALL ), - 1 - ), - 0 + lim + ) ); } - else if (extrapolate < SMALL) + else if (extrapolate < VSMALL) { lim = max ( + 0, min ( ( @@ -119,19 +117,19 @@ public: extrapolate* ( sqr(deltaOneMin) - + 2.0*sqr(extrapolate) + deltaOneMin*extrapolate + + 2*sqr(extrapolate) + + deltaOneMin*extrapolate + epsilonSquare ), SMALL ), - 1 - ), - 0 + lim + ) ); } else { - lim = 1; + // Limiter remains unchanged } }