From 37a6fc8db3598cd6f1449a66257a39ddd40d1984 Mon Sep 17 00:00:00 2001 From: Kutalmis Bercin <kutalmis.bercin@esi-group.com> Date: Fri, 26 Nov 2021 09:37:55 +0000 Subject: [PATCH] STYLE: snGradSchemes: modernise and clean up code ENH: removes an unused scalarField from skewCorrectedSnGrad DOC: snGradSchemes: improve header-file documentation --- .../CentredFitSnGrad/CentredFitSnGradScheme.H | 3 +- .../correctedSnGrad/correctedSnGrad.C | 10 +---- .../correctedSnGrad/correctedSnGrad.H | 23 +++++++--- .../faceCorrectedSnGrad/faceCorrectedSnGrad.C | 22 +++------- .../faceCorrectedSnGrad/faceCorrectedSnGrad.H | 23 +++++++--- .../limitedSnGrad/limitedSnGrad.C | 8 +--- .../limitedSnGrad/limitedSnGrad.H | 44 +++++++++++-------- .../limitedSnGrad/limitedSnGrads.C | 8 +--- .../orthogonalSnGrad/orthogonalSnGrad.C | 11 +---- .../orthogonalSnGrad/orthogonalSnGrad.H | 27 +++++++++--- .../orthogonalSnGrad/orthogonalSnGrads.C | 4 +- .../skewCorrectedSnGrad/skewCorrectedSnGrad.C | 3 +- .../skewCorrectedSnGrad/skewCorrectedSnGrad.H | 16 +++++-- .../snGradSchemes/snGradScheme/snGradScheme.C | 4 +- .../snGradSchemes/snGradScheme/snGradScheme.H | 33 +++++++++----- .../snGradScheme/snGradSchemes.C | 4 +- .../uncorrectedSnGrad/uncorrectedSnGrad.C | 11 +---- .../uncorrectedSnGrad/uncorrectedSnGrad.H | 27 +++++++++--- .../uncorrectedSnGrad/uncorrectedSnGrads.C | 4 +- 19 files changed, 154 insertions(+), 131 deletions(-) diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/CentredFitSnGrad/CentredFitSnGradScheme.H b/src/finiteVolume/finiteVolume/snGradSchemes/CentredFitSnGrad/CentredFitSnGradScheme.H index 81b7cdf0efe..7a7a80366c3 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/CentredFitSnGrad/CentredFitSnGradScheme.H +++ b/src/finiteVolume/finiteVolume/snGradSchemes/CentredFitSnGrad/CentredFitSnGradScheme.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -109,7 +110,7 @@ public: } //- Return true if this scheme uses an explicit correction - virtual bool corrected() const + virtual bool corrected() const noexcept { return true; } diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/correctedSnGrad/correctedSnGrad.C b/src/finiteVolume/finiteVolume/snGradSchemes/correctedSnGrad/correctedSnGrad.C index 174d11bbb94..ab5d7f40633 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/correctedSnGrad/correctedSnGrad.C +++ b/src/finiteVolume/finiteVolume/snGradSchemes/correctedSnGrad/correctedSnGrad.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -32,13 +33,6 @@ License #include "fvcGrad.H" #include "gaussGrad.H" -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -template<class Type> -Foam::fv::correctedSnGrad<Type>::~correctedSnGrad() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> @@ -96,7 +90,7 @@ Foam::fv::correctedSnGrad<Type>::correction GeometricField<Type, fvsPatchField, surfaceMesh>& ssf = tssf.ref(); ssf.setOriented(); - for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; cmpt++) + for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; ++cmpt) { ssf.replace ( diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/correctedSnGrad/correctedSnGrad.H b/src/finiteVolume/finiteVolume/snGradSchemes/correctedSnGrad/correctedSnGrad.H index 8f0b7c3abea..4533778dc8d 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/correctedSnGrad/correctedSnGrad.H +++ b/src/finiteVolume/finiteVolume/snGradSchemes/correctedSnGrad/correctedSnGrad.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,7 +31,16 @@ Group grpFvSnGradSchemes Description - Simple central-difference snGrad scheme with non-orthogonal correction. + Surface gradient scheme with full explicit non-orthogonal correction. + +Usage + Minimal example by using \c system/fvSchemes: + \verbatim + snGradSchemes + { + snGrad(<term>) corrected; + } + \endverbatim SourceFiles correctedSnGrad.C @@ -53,7 +63,7 @@ namespace fv { /*---------------------------------------------------------------------------*\ - Class correctedSnGrad Declaration + Class correctedSnGrad Declaration \*---------------------------------------------------------------------------*/ template<class Type> @@ -81,7 +91,6 @@ public: snGradScheme<Type>(mesh) {} - //- Construct from mesh and data stream correctedSnGrad(const fvMesh& mesh, Istream&) : @@ -90,7 +99,7 @@ public: //- Destructor - virtual ~correctedSnGrad(); + virtual ~correctedSnGrad() = default; // Member Functions @@ -105,13 +114,13 @@ public: } //- Return true if this scheme uses an explicit correction - virtual bool corrected() const + virtual bool corrected() const noexcept { return true; } //- Return the explicit correction to the correctedSnGrad - // for the given field using the gradient of the field + //- for the given field using the gradient of the field tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> fullGradCorrection ( @@ -119,7 +128,7 @@ public: ) const; //- Return the explicit correction to the correctedSnGrad - // for the given field using the gradients of the field components + //- for the given field using the gradients of the field components virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> correction(const GeometricField<Type, fvPatchField, volMesh>&) const; }; diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrad.C b/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrad.C index 913af1e61bf..46982ebda83 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrad.C +++ b/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrad.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -29,13 +30,6 @@ License #include "volPointInterpolation.H" #include "triangle.H" -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -template<class Type> -Foam::fv::faceCorrectedSnGrad<Type>::~faceCorrectedSnGrad() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> @@ -89,18 +83,18 @@ Foam::fv::faceCorrectedSnGrad<Type>::fullGradCorrection const face& fi = faces[facei]; - vector nf(Sf[facei]/magSf[facei]); + const vector nf(Sf[facei]/magSf[facei]); - for (label pi=0; pi<fi.size(); pi++) + for (label pi = 0; pi < fi.size(); ++pi) { // Next point index - label pj = (pi+1)%fi.size(); + const label pj = fi.fcIndex(pi); // Edge normal in plane of face - vector edgen(nf^(points[fi[pj]] - points[fi[pi]])); + const vector edgen(nf^(points[fi[pj]] - points[fi[pi]])); // Edge centre field value - Type pvfe(0.5*(pvf[fi[pj]] + pvf[fi[pi]])); + const Type pvfe(0.5*(pvf[fi[pj]] + pvf[fi[pi]])); // Integrate face gradient fgrad += edgen*pvfe; @@ -113,8 +107,6 @@ Foam::fv::faceCorrectedSnGrad<Type>::fullGradCorrection vector dCorr(C[neighbour[facei]] - C[owner[facei]]); dCorr /= (nf & dCorr); - // if (mag(dCorr) > 2) dCorr *= 2/mag(dCorr); - sfCorr[facei] = dCorr&fgrad; } @@ -152,7 +144,7 @@ Foam::fv::faceCorrectedSnGrad<Type>::correction ); GeometricField<Type, fvsPatchField, surfaceMesh>& ssf = tssf.ref(); - for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; cmpt++) + for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; ++cmpt) { ssf.replace ( diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrad.H b/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrad.H index 13bb2774646..f4540ba0c0f 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrad.H +++ b/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrad.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,7 +31,16 @@ Group grpFvSnGradSchemes Description - Simple central-difference snGrad scheme with non-orthogonal correction. + Surface gradient scheme with full explicit non-orthogonal correction. + +Usage + Minimal example by using \c system/fvSchemes: + \verbatim + snGradSchemes + { + snGrad(<term>) faceCorrected; + } + \endverbatim SourceFiles faceCorrectedSnGrad.C @@ -53,7 +63,7 @@ namespace fv { /*---------------------------------------------------------------------------*\ - Class faceCorrectedSnGrad Declaration + Class faceCorrectedSnGrad Declaration \*---------------------------------------------------------------------------*/ template<class Type> @@ -81,7 +91,6 @@ public: snGradScheme<Type>(mesh) {} - //- Construct from mesh and data stream faceCorrectedSnGrad(const fvMesh& mesh, Istream&) : @@ -90,7 +99,7 @@ public: //- Destructor - virtual ~faceCorrectedSnGrad(); + virtual ~faceCorrectedSnGrad() = default; // Member Functions @@ -105,13 +114,13 @@ public: } //- Return true if this scheme uses an explicit correction - virtual bool corrected() const + virtual bool corrected() const noexcept { return true; } //- Return the explicit correction to the faceCorrectedSnGrad - // for the given field using the gradient of the field + //- for the given field using the gradient of the field tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> fullGradCorrection ( @@ -119,7 +128,7 @@ public: ) const; //- Return the explicit correction to the faceCorrectedSnGrad - // for the given field using the gradients of the field components + //- for the given field using the gradients of the field components virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> correction(const GeometricField<Type, fvPatchField, volMesh>&) const; }; diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/limitedSnGrad/limitedSnGrad.C b/src/finiteVolume/finiteVolume/snGradSchemes/limitedSnGrad/limitedSnGrad.C index babc458a20b..6f0f95ee350 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/limitedSnGrad/limitedSnGrad.C +++ b/src/finiteVolume/finiteVolume/snGradSchemes/limitedSnGrad/limitedSnGrad.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -42,13 +43,6 @@ namespace Foam namespace fv { -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -template<class Type> -limitedSnGrad<Type>::~limitedSnGrad() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/limitedSnGrad/limitedSnGrad.H b/src/finiteVolume/finiteVolume/snGradSchemes/limitedSnGrad/limitedSnGrad.H index b14abfa5cfa..1922fe14d8e 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/limitedSnGrad/limitedSnGrad.H +++ b/src/finiteVolume/finiteVolume/snGradSchemes/limitedSnGrad/limitedSnGrad.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,20 +31,26 @@ Group grpFvSnGradSchemes Description - Run-time selected snGrad scheme with limited non-orthogonal correction. + Surface gradient scheme with limited explicit non-orthogonal correction. The limiter is controlled by a coefficient with a value between 0 and 1 which when 0 switches the correction off and the scheme behaves as - uncorrectedSnGrad, when set to 1 the full correction of the selected scheme - is used and when set to 0.5 the limiter is calculated such that the - non-orthogonal contribution does not exceed the orthogonal part. - - Format: - limited \<corrected scheme\> \<coefficient\>; - - or - - limited \<coefficient\>; // Backward compatibility + \c uncorrected \c snGrad, when set to 1 the full correction of the + selected scheme is used and the scheme behaves as \c corrected \c snGrad, + and when set to 0.5 the limiter is calculated such that the non-orthogonal + component does not exceed the orthogonal component. + +Usage + Minimal example by using \c system/fvSchemes: + \verbatim + snGradSchemes + { + snGrad(<term>) limited <corrected scheme> <coefficient>; + + // Backward compatibility + snGrad(<term>) limited <coefficient>; + } + \endverbatim SourceFiles limitedSnGrad.C @@ -66,7 +73,7 @@ namespace fv { /*---------------------------------------------------------------------------*\ - Class limitedSnGrad Declaration + Class limitedSnGrad Declaration \*---------------------------------------------------------------------------*/ template<class Type> @@ -74,10 +81,12 @@ class limitedSnGrad : public snGradScheme<Type> { - // Private data + // Private Data + //- Type of correction scheme tmp<snGradScheme<Type>> correctedScheme_; + //- Limiter coefficient scalar limitCoeff_; @@ -87,7 +96,7 @@ class limitedSnGrad void operator=(const limitedSnGrad&) = delete; //- Lookup function for the corrected to support backward compatibility - // of dictionary specification + //- of dictionary specification tmp<snGradScheme<Type>> lookupCorrectedScheme(Istream& schemeData) { token nextToken(schemeData); @@ -131,7 +140,6 @@ public: limitCoeff_(1) {} - //- Construct from mesh and data stream limitedSnGrad(const fvMesh& mesh, Istream& schemeData) : @@ -149,7 +157,7 @@ public: //- Destructor - virtual ~limitedSnGrad(); + virtual ~limitedSnGrad() = default; // Member Functions @@ -164,13 +172,13 @@ public: } //- Return true if this scheme uses an explicit correction - virtual bool corrected() const + virtual bool corrected() const noexcept { return true; } //- Return the explicit correction to the limitedSnGrad - // for the given field + //- for the given field virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> correction(const GeometricField<Type, fvPatchField, volMesh>&) const; }; diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/limitedSnGrad/limitedSnGrads.C b/src/finiteVolume/finiteVolume/snGradSchemes/limitedSnGrad/limitedSnGrads.C index ef02a344a54..5a385681bff 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/limitedSnGrad/limitedSnGrads.C +++ b/src/finiteVolume/finiteVolume/snGradSchemes/limitedSnGrad/limitedSnGrads.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -23,13 +24,6 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. -Description - Central-difference snGrad scheme with limited non-orthogonal correction. - The limiter is controlled by a coefficient with a value between 0 and 1 - which when zero switches the limiter off and the scheme behaves as - correctedSnGrad, and when set to 1 the limiter is calculated such that the - non-orthogonal contribution does not exceed the orthogonal part. - \*---------------------------------------------------------------------------*/ #include "limitedSnGrad.H" diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/orthogonalSnGrad/orthogonalSnGrad.C b/src/finiteVolume/finiteVolume/snGradSchemes/orthogonalSnGrad/orthogonalSnGrad.C index 1ea8894bbfb..64380af3add 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/orthogonalSnGrad/orthogonalSnGrad.C +++ b/src/finiteVolume/finiteVolume/snGradSchemes/orthogonalSnGrad/orthogonalSnGrad.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -23,9 +24,6 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. -Description - Simple central-difference snGrad scheme without non-orthogonal correction. - \*---------------------------------------------------------------------------*/ #include "orthogonalSnGrad.H" @@ -42,13 +40,6 @@ namespace Foam namespace fv { -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -template<class Type> -orthogonalSnGrad<Type>::~orthogonalSnGrad() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/orthogonalSnGrad/orthogonalSnGrad.H b/src/finiteVolume/finiteVolume/snGradSchemes/orthogonalSnGrad/orthogonalSnGrad.H index 747870a911d..c242628b843 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/orthogonalSnGrad/orthogonalSnGrad.H +++ b/src/finiteVolume/finiteVolume/snGradSchemes/orthogonalSnGrad/orthogonalSnGrad.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,8 +31,21 @@ Group grpFvSnGradSchemes Description - Simple central-difference snGrad scheme using the cell-centre to cell-centre - delta-coefficients. + Surface gradient scheme with no non-orthogonal correction. + +Usage + Minimal example by using \c system/fvSchemes: + \verbatim + snGradSchemes + { + snGrad(<term>) orthogonal; + } + \endverbatim + +Note + - Interpolation weighting factors (i.e. delta coefficients) are based + on the \c deltaCoeffs function rather than the \c nonOrthDeltaCoeffs + function, which is used by the \c uncorrected scheme. SourceFiles orthogonalSnGrad.C @@ -54,7 +68,7 @@ namespace fv { /*---------------------------------------------------------------------------*\ - Class orthogonalSnGrad Declaration + Class orthogonalSnGrad Declaration \*---------------------------------------------------------------------------*/ template<class Type> @@ -82,7 +96,6 @@ public: snGradScheme<Type>(mesh) {} - //- Construct from mesh and data stream orthogonalSnGrad(const fvMesh& mesh, Istream&) : @@ -91,7 +104,7 @@ public: //- Destructor - virtual ~orthogonalSnGrad(); + virtual ~orthogonalSnGrad() = default; // Member Functions @@ -106,13 +119,13 @@ public: } //- Return true if this scheme uses an explicit correction - virtual bool corrected() const + virtual bool corrected() const noexcept { return false; } //- Return the explicit correction to the orthogonalSnGrad - // for the given field + //- for the given field virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> correction(const GeometricField<Type, fvPatchField, volMesh>&) const; }; diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/orthogonalSnGrad/orthogonalSnGrads.C b/src/finiteVolume/finiteVolume/snGradSchemes/orthogonalSnGrad/orthogonalSnGrads.C index b52a70ca6b6..9f350c0bf21 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/orthogonalSnGrad/orthogonalSnGrads.C +++ b/src/finiteVolume/finiteVolume/snGradSchemes/orthogonalSnGrad/orthogonalSnGrads.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -23,9 +24,6 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. -Description - Simple central-difference snGrad scheme without non-orthogonal correction. - \*---------------------------------------------------------------------------*/ #include "orthogonalSnGrad.H" diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/skewCorrectedSnGrad/skewCorrectedSnGrad.C b/src/finiteVolume/finiteVolume/snGradSchemes/skewCorrectedSnGrad/skewCorrectedSnGrad.C index 7138197f694..5faffa76f5d 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/skewCorrectedSnGrad/skewCorrectedSnGrad.C +++ b/src/finiteVolume/finiteVolume/snGradSchemes/skewCorrectedSnGrad/skewCorrectedSnGrad.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2019 Zeljko Tukovic, FSB Zagreb. + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -72,8 +73,6 @@ Foam::fv::skewCorrectedSnGrad<Type>::fullGradCorrection const vectorField& Sf = mesh.Sf().internalField(); const scalarField& magSf = mesh.magSf().internalField(); - vectorField nf(Sf/magSf); - const vectorField& Cf = mesh.Cf().internalField(); const vectorField& C = mesh.C().internalField(); diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/skewCorrectedSnGrad/skewCorrectedSnGrad.H b/src/finiteVolume/finiteVolume/snGradSchemes/skewCorrectedSnGrad/skewCorrectedSnGrad.H index 1ab2e696a9d..5e2919c2505 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/skewCorrectedSnGrad/skewCorrectedSnGrad.H +++ b/src/finiteVolume/finiteVolume/snGradSchemes/skewCorrectedSnGrad/skewCorrectedSnGrad.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2019 Zeljko Tukovic, FSB Zagreb. + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,7 +31,17 @@ Group grpFvSnGradSchemes Description - Simple central-difference snGrad scheme with non-orthogonal correction. + Surface gradient scheme with skewness and full + explicit non-orthogonal corrections. + +Usage + Minimal example by using \c system/fvSchemes: + \verbatim + snGradSchemes + { + snGrad(<term>) skewCorrected; + } + \endverbatim SourceFiles skewCorrectedSnGrad.C @@ -81,7 +92,6 @@ public: snGradScheme<Type>(mesh) {} - //- Construct from mesh and data stream skewCorrectedSnGrad(const fvMesh& mesh, Istream&) : @@ -105,7 +115,7 @@ public: } //- Return true if this scheme uses an explicit correction - virtual bool corrected() const + virtual bool corrected() const noexcept { return true; } diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/snGradScheme/snGradScheme.C b/src/finiteVolume/finiteVolume/snGradSchemes/snGradScheme/snGradScheme.C index 0dc584dcfb1..e507d053c88 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/snGradScheme/snGradScheme.C +++ b/src/finiteVolume/finiteVolume/snGradSchemes/snGradScheme/snGradScheme.C @@ -60,8 +60,8 @@ tmp<snGradScheme<Type>> snGradScheme<Type>::New { FatalIOErrorInFunction(schemeData) << "Discretisation scheme not specified" - << endl << endl - << "Valid schemes are :" << endl + << nl << nl + << "Valid schemes are :" << nl << MeshConstructorTablePtr_->sortedToc() << exit(FatalIOError); } diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/snGradScheme/snGradScheme.H b/src/finiteVolume/finiteVolume/snGradSchemes/snGradScheme/snGradScheme.H index 324fd03a699..d19a63bf3fe 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/snGradScheme/snGradScheme.H +++ b/src/finiteVolume/finiteVolume/snGradSchemes/snGradScheme/snGradScheme.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,7 +31,17 @@ Group grpFvSnGradSchemes Description - Abstract base class for snGrad schemes. + Abstract base class for runtime selected \c snGrad surface + normal gradient schemes. + + A surface normal gradient is evaluated at a cell face. It + is the normal-to-face component of the gradient of + values at the centres of two cells that the face connects. + + Unit-surface-normal vector decomposition is based on the + so-called over-relaxed approach. Orthogonal components are + treated implicitly and non-orthogonal components are treated + explicitly with (or without) various limiters. SourceFiles snGradScheme.C @@ -59,7 +70,7 @@ namespace fv { /*---------------------------------------------------------------------------*\ - Class snGradScheme Declaration + Class snGradScheme Declaration \*---------------------------------------------------------------------------*/ template<class Type> @@ -67,9 +78,9 @@ class snGradScheme : public refCount { - // Private data + // Private Data - //- Hold reference to mesh + //- Hold const reference to mesh const fvMesh& mesh_; @@ -125,14 +136,14 @@ public: // Member Functions - //- Return mesh reference + //- Return const reference to mesh const fvMesh& mesh() const { return mesh_; } - - //- Return the snGrad of the given cell field with the given deltaCoeffs + //- Return the snGrad of the given cell field + //- by using the given deltaCoeffs static tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> snGrad ( @@ -156,13 +167,13 @@ public: ) const = 0; //- Return true if this scheme uses an explicit correction - virtual bool corrected() const + virtual bool corrected() const noexcept { return false; } //- Return the explicit correction to the snGrad - // for the given field + //- for the given field virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> correction(const GeometricField<Type, fvPatchField, volMesh>&) const { @@ -173,12 +184,12 @@ public: } //- Return the snGrad of the given cell field - // with explicit correction + //- with explicit correction virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> snGrad(const GeometricField<Type, fvPatchField, volMesh>&) const; //- Return the snGrad of the given tmp cell field - // with explicit correction + //- with explicit correction tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> snGrad ( diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/snGradScheme/snGradSchemes.C b/src/finiteVolume/finiteVolume/snGradSchemes/snGradScheme/snGradSchemes.C index 1f5c316d22a..d03fe44c7af 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/snGradScheme/snGradSchemes.C +++ b/src/finiteVolume/finiteVolume/snGradSchemes/snGradScheme/snGradSchemes.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -23,9 +24,6 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. -Description - Abstract base class for snGrad schemes. - \*---------------------------------------------------------------------------*/ #include "snGradScheme.H" diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/uncorrectedSnGrad/uncorrectedSnGrad.C b/src/finiteVolume/finiteVolume/snGradSchemes/uncorrectedSnGrad/uncorrectedSnGrad.C index e8af0a09fe1..793e16a563d 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/uncorrectedSnGrad/uncorrectedSnGrad.C +++ b/src/finiteVolume/finiteVolume/snGradSchemes/uncorrectedSnGrad/uncorrectedSnGrad.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -23,9 +24,6 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. -Description - Simple central-difference snGrad scheme without non-orthogonal correction. - \*---------------------------------------------------------------------------*/ #include "uncorrectedSnGrad.H" @@ -42,13 +40,6 @@ namespace Foam namespace fv { -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -template<class Type> -uncorrectedSnGrad<Type>::~uncorrectedSnGrad() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/uncorrectedSnGrad/uncorrectedSnGrad.H b/src/finiteVolume/finiteVolume/snGradSchemes/uncorrectedSnGrad/uncorrectedSnGrad.H index 72d9c874815..afdd1d8b944 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/uncorrectedSnGrad/uncorrectedSnGrad.H +++ b/src/finiteVolume/finiteVolume/snGradSchemes/uncorrectedSnGrad/uncorrectedSnGrad.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,8 +31,21 @@ Group grpFvSnGradSchemes Description - Simple central-difference snGrad scheme using the non-orthogonal mesh - delta-coefficients but without non-orthogonal correction. + Surface gradient scheme with no non-orthogonal correction. + +Usage + Minimal example by using \c system/fvSchemes: + \verbatim + snGradSchemes + { + snGrad(<term>) uncorrected; + } + \endverbatim + +Note + - Interpolation weighting factors (i.e. delta coefficients) are based + on the \c nonOrthDeltaCoeffs function rather than the \c deltaCoeffs + function, which is used by the \c orthogonal scheme. SourceFiles uncorrectedSnGrad.C @@ -54,7 +68,7 @@ namespace fv { /*---------------------------------------------------------------------------*\ - Class uncorrectedSnGrad Declaration + Class uncorrectedSnGrad Declaration \*---------------------------------------------------------------------------*/ template<class Type> @@ -82,7 +96,6 @@ public: snGradScheme<Type>(mesh) {} - //- Construct from mesh and data stream uncorrectedSnGrad(const fvMesh& mesh, Istream&) : @@ -91,7 +104,7 @@ public: //- Destructor - virtual ~uncorrectedSnGrad(); + virtual ~uncorrectedSnGrad() = default; // Member Functions @@ -106,13 +119,13 @@ public: } //- Return true if this scheme uses an explicit correction - virtual bool corrected() const + virtual bool corrected() const noexcept { return false; } //- Return the explicit correction to the uncorrectedSnGrad - // for the given field + //- for the given field virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> correction(const GeometricField<Type, fvPatchField, volMesh>&) const; }; diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/uncorrectedSnGrad/uncorrectedSnGrads.C b/src/finiteVolume/finiteVolume/snGradSchemes/uncorrectedSnGrad/uncorrectedSnGrads.C index c8fc0c122f8..284a991eac6 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/uncorrectedSnGrad/uncorrectedSnGrads.C +++ b/src/finiteVolume/finiteVolume/snGradSchemes/uncorrectedSnGrad/uncorrectedSnGrads.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -23,9 +24,6 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. -Description - Simple central-difference snGrad scheme without non-orthogonal correction. - \*---------------------------------------------------------------------------*/ #include "uncorrectedSnGrad.H" -- GitLab