Skip to content
Snippets Groups Projects
Commit dff973d5 authored by Henry's avatar Henry
Browse files

limitedSnGrad: corrected scheme to be limited is now run-time selectable

defaults to "corrected" for backward compatibility
parent b1f90c83
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -21,23 +21,12 @@ License ...@@ -21,23 +21,12 @@ License
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
snGrad scheme with limited 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 is applied and the
scheme behaves as correctedSnGrad and when set to 0.5 the limiter is
calculated such that the non-orthogonal contribution does not exceed the
orthogonal part.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "fv.H" #include "fv.H"
#include "limitedSnGrad.H" #include "limitedSnGrad.H"
#include "volFields.H" #include "volFields.H"
#include "surfaceFields.H" #include "surfaceFields.H"
#include "correctedSnGrad.H"
#include "localMax.H" #include "localMax.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...@@ -68,7 +57,7 @@ limitedSnGrad<Type>::correction ...@@ -68,7 +57,7 @@ limitedSnGrad<Type>::correction
{ {
const GeometricField<Type, fvsPatchField, surfaceMesh> corr const GeometricField<Type, fvsPatchField, surfaceMesh> corr
( (
correctedSnGrad<Type>(this->mesh()).correction(vf) correctedScheme_().correction(vf)
); );
const surfaceScalarField limiter const surfaceScalarField limiter
...@@ -76,7 +65,7 @@ limitedSnGrad<Type>::correction ...@@ -76,7 +65,7 @@ limitedSnGrad<Type>::correction
min min
( (
limitCoeff_ limitCoeff_
*mag(snGradScheme<Type>::snGrad(vf, deltaCoeffs(vf), "orthSnGrad")) *mag(snGradScheme<Type>::snGrad(vf, deltaCoeffs(vf), "SndGrad"))
/( /(
(1 - limitCoeff_)*mag(corr) (1 - limitCoeff_)*mag(corr)
+ dimensionedScalar("small", corr.dimensions(), SMALL) + dimensionedScalar("small", corr.dimensions(), SMALL)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -25,14 +25,20 @@ Class ...@@ -25,14 +25,20 @@ Class
Foam::fv::limitedSnGrad Foam::fv::limitedSnGrad
Description Description
Central-difference snGrad scheme with limited non-orthogonal correction. Run-time selected snGrad scheme with limited non-orthogonal correction.
The limiter is controlled by a coefficient with a value between 0 and 1 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 which when 0 switches the correction off and the scheme behaves as
uncorrectedSnGrad, when set to 1 the full correction is applied and the uncorrectedSnGrad, when set to 1 the full correction of the selected scheme
scheme behaves as correctedSnGrad and when set to 0.5 the limiter is is used and when set to 0.5 the limiter is calculated such that the
calculated such that the non-orthogonal contribution does not exceed the non-orthogonal contribution does not exceed the orthogonal part.
orthogonal part.
Format:
limited <corrected scheme> <coefficient>;
or
limited <coefficient>; // Backward compatibility
SourceFiles SourceFiles
limitedSnGrad.C limitedSnGrad.C
...@@ -42,7 +48,7 @@ SourceFiles ...@@ -42,7 +48,7 @@ SourceFiles
#ifndef limitedSnGrad_H #ifndef limitedSnGrad_H
#define limitedSnGrad_H #define limitedSnGrad_H
#include "snGradScheme.H" #include "correctedSnGrad.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...@@ -65,6 +71,8 @@ class limitedSnGrad ...@@ -65,6 +71,8 @@ class limitedSnGrad
{ {
// Private data // Private data
tmp<snGradScheme<Type> > correctedScheme_;
scalar limitCoeff_; scalar limitCoeff_;
...@@ -73,6 +81,34 @@ class limitedSnGrad ...@@ -73,6 +81,34 @@ class limitedSnGrad
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const limitedSnGrad&); void operator=(const limitedSnGrad&);
//- Lookup function for the corrected to support backward compatibility
// of dictionary specification
tmp<snGradScheme<Type> > lookupCorrectedScheme(Istream& schemeData)
{
token nextToken(schemeData);
if (nextToken.isNumber())
{
limitCoeff_ = nextToken.number();
return tmp<snGradScheme<Type> >
(
new correctedSnGrad<Type>(this->mesh())
);
}
else
{
schemeData.putBack(nextToken);
tmp<snGradScheme<Type> > tcorrectedScheme
(
fv::snGradScheme<Type>::New(this->mesh(), schemeData)
);
schemeData >> limitCoeff_;
return tcorrectedScheme;
}
}
public: public:
...@@ -85,22 +121,24 @@ public: ...@@ -85,22 +121,24 @@ public:
//- Construct from mesh //- Construct from mesh
limitedSnGrad(const fvMesh& mesh) limitedSnGrad(const fvMesh& mesh)
: :
snGradScheme<Type>(mesh) snGradScheme<Type>(mesh),
correctedScheme_(new correctedSnGrad<Type>(this->mesh())),
limitCoeff_(1)
{} {}
//- Construct from mesh and data stream //- Construct from mesh and data stream
limitedSnGrad(const fvMesh& mesh, Istream& is) limitedSnGrad(const fvMesh& mesh, Istream& schemeData)
: :
snGradScheme<Type>(mesh), snGradScheme<Type>(mesh),
limitCoeff_(readScalar(is)) correctedScheme_(lookupCorrectedScheme(schemeData))
{ {
if (limitCoeff_ < 0 || limitCoeff_ > 1) if (limitCoeff_ < 0 || limitCoeff_ > 1)
{ {
FatalIOErrorIn FatalIOErrorIn
( (
"limitedSnGrad(const fvMesh& mesh, Istream& is) : ", "limitedSnGrad(const fvMesh& mesh, Istream& schemeData) : ",
is schemeData
) << "limitCoeff is specified as " << limitCoeff_ ) << "limitCoeff is specified as " << limitCoeff_
<< " but should be >= 0 && <= 1" << " but should be >= 0 && <= 1"
<< exit(FatalIOError); << exit(FatalIOError);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment