limitedSnGrad.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::fv::limitedSnGrad
26 
27 Description
28  Run-time selected snGrad scheme with limited non-orthogonal correction.
29 
30  The limiter is controlled by a coefficient with a value between 0 and 1
31  which when 0 switches the correction off and the scheme behaves as
32  uncorrectedSnGrad, when set to 1 the full correction of the selected scheme
33  is used and when set to 0.5 the limiter is calculated such that the
34  non-orthogonal contribution does not exceed the orthogonal part.
35 
36  Format:
37  limited <corrected scheme> <coefficient>;
38 
39  or
40 
41  limited <coefficient>; // Backward compatibility
42 
43 SourceFiles
44  limitedSnGrad.C
45 
46 \*---------------------------------------------------------------------------*/
47 
48 #ifndef limitedSnGrad_H
49 #define limitedSnGrad_H
50 
51 #include "correctedSnGrad.H"
52 
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 
55 namespace Foam
56 {
57 
58 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
59 
60 namespace fv
61 {
62 
63 /*---------------------------------------------------------------------------*\
64  Class limitedSnGrad Declaration
65 \*---------------------------------------------------------------------------*/
66 
67 template<class Type>
68 class limitedSnGrad
69 :
70  public snGradScheme<Type>
71 {
72  // Private Data
73 
74  tmp<snGradScheme<Type>> correctedScheme_;
75 
76  scalar limitCoeff_;
77 
78 
79  // Private Member Functions
80 
81  //- Lookup function for the corrected to support backward compatibility
82  // of dictionary specification
83  tmp<snGradScheme<Type>> lookupCorrectedScheme(Istream& schemeData)
84  {
85  token nextToken(schemeData);
86 
87  if (nextToken.isNumber())
88  {
89  limitCoeff_ = nextToken.number();
91  (
92  new correctedSnGrad<Type>(this->mesh())
93  );
94  }
95  else
96  {
97  schemeData.putBack(nextToken);
98  tmp<snGradScheme<Type>> tcorrectedScheme
99  (
100  fv::snGradScheme<Type>::New(this->mesh(), schemeData)
101  );
102 
103  schemeData >> limitCoeff_;
104 
105  return tcorrectedScheme;
106  }
107  }
108 
109 
110 public:
111 
112  //- Runtime type information
113  TypeName("limited");
114 
115 
116  // Constructors
117 
118  //- Construct from mesh
119  limitedSnGrad(const fvMesh& mesh);
120 
121  //- Construct from mesh and data stream
122  limitedSnGrad(const fvMesh& mesh, Istream& schemeData);
123 
124 
125  //- Destructor
126  virtual ~limitedSnGrad();
127 
128 
129  // Member Functions
130 
131  //- Return the interpolation weighting factors for the given field
133  (
134  const VolField<Type>&
135  ) const;
136 
137  //- Return true if this scheme uses an explicit correction
138  virtual bool corrected() const
139  {
140  return true;
141  }
142 
143  //- Return the explicit correction to the limitedSnGrad
144  // for the given field
145  virtual tmp<SurfaceField<Type>>
146  correction(const VolField<Type>&) const;
147 
148 
149  // Member Operators
150 
151  //- Disallow default bitwise assignment
152  void operator=(const limitedSnGrad&) = delete;
153 };
154 
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 } // End namespace fv
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 } // End namespace Foam
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 #ifdef NoRepository
167  #include "limitedSnGrad.C"
168 #endif
169 
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171 
172 #endif
173 
174 // ************************************************************************* //
Generic GeometricField class.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
void putBack(const token &)
Put back token.
Definition: Istream.C:30
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:101
Simple central-difference snGrad scheme with non-orthogonal correction.
Run-time selected snGrad scheme with limited non-orthogonal correction.
Definition: limitedSnGrad.H:70
virtual bool corrected() const
Return true if this scheme uses an explicit correction.
virtual ~limitedSnGrad()
Destructor.
Definition: limitedSnGrad.C:72
void operator=(const limitedSnGrad &)=delete
Disallow default bitwise assignment.
virtual tmp< SurfaceField< Type > > correction(const VolField< Type > &) const
Return the explicit correction to the limitedSnGrad.
Definition: limitedSnGrad.C:91
virtual tmp< surfaceScalarField > deltaCoeffs(const VolField< Type > &) const
Return the interpolation weighting factors for the given field.
Definition: limitedSnGrad.C:80
limitedSnGrad(const fvMesh &mesh)
Construct from mesh.
Definition: limitedSnGrad.C:43
TypeName("limited")
Runtime type information.
Abstract base class for snGrad schemes.
Definition: snGradScheme.H:63
const fvMesh & mesh() const
Return mesh reference.
Definition: snGradScheme.H:117
A class for managing temporary objects.
Definition: tmp.H:55
A token holds items read from Istream.
Definition: token.H:73
bool isNumber() const
Definition: tokenI.H:498
scalar number() const
Definition: tokenI.H:503
Namespace for OpenFOAM.
labelList fv(nPoints)