snGradScheme.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::fv::snGradScheme
29 
30 Group
31  grpFvSnGradSchemes
32 
33 Description
34  Abstract base class for runtime selected \c snGrad surface
35  normal gradient schemes.
36 
37  A surface normal gradient is evaluated at a cell face. It
38  is the normal-to-face component of the gradient of
39  values at the centres of two cells that the face connects.
40 
41  Unit-surface-normal vector decomposition is based on the
42  so-called over-relaxed approach. Orthogonal components are
43  treated implicitly and non-orthogonal components are treated
44  explicitly with (or without) various limiters.
45 
46 SourceFiles
47  snGradScheme.C
48 
49 \*---------------------------------------------------------------------------*/
50 
51 #ifndef snGradScheme_H
52 #define snGradScheme_H
53 
54 #include "tmp.H"
55 #include "volFieldsFwd.H"
56 #include "surfaceFieldsFwd.H"
57 #include "typeInfo.H"
58 #include "runTimeSelectionTables.H"
59 
60 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
61 
62 namespace Foam
63 {
64 
65 class fvMesh;
66 
67 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 
69 namespace fv
70 {
71 
72 /*---------------------------------------------------------------------------*\
73  Class snGradScheme Declaration
74 \*---------------------------------------------------------------------------*/
75 
76 template<class Type>
77 class snGradScheme
78 :
79  public refCount
80 {
81  // Private Data
82 
83  //- Hold const reference to mesh
84  const fvMesh& mesh_;
85 
86 
87  // Private Member Functions
88 
89  //- No copy construct
90  snGradScheme(const snGradScheme&) = delete;
91 
92  //- No copy assignment
93  void operator=(const snGradScheme&) = delete;
94 
95 
96 public:
97 
98  //- Runtime type information
99  virtual const word& type() const = 0;
100 
101 
102  // Declare run-time constructor selection tables
103 
105  (
106  tmp,
107  snGradScheme,
108  Mesh,
109  (const fvMesh& mesh, Istream& schemeData),
110  (mesh, schemeData)
111  );
112 
113 
114  // Constructors
115 
116  //- Construct from mesh
117  snGradScheme(const fvMesh& mesh)
118  :
119  mesh_(mesh)
120  {}
121 
123  // Selectors
124 
125  //- Return new tmp interpolation scheme
127  (
128  const fvMesh& mesh,
129  Istream& schemeData
130  );
131 
132 
133  //- Destructor
134  virtual ~snGradScheme() = default;
135 
136 
137  // Member Functions
138 
139  //- Return const reference to mesh
140  const fvMesh& mesh() const
141  {
142  return mesh_;
143  }
144 
145  //- Return the snGrad of the given cell field
146  //- by using the given deltaCoeffs
148  snGrad
149  (
152  const word& snGradName = "snGrad"
153  );
154 
155  //- Return the sndGrad of the given cell field
157  sndGrad
158  (
160  const word& snGradName = "sndGrad"
161  );
162 
163  //- Return the interpolation weighting factors for the given field
165  (
167  ) const = 0;
168 
169  //- Return true if this scheme uses an explicit correction
170  virtual bool corrected() const noexcept
171  {
172  return false;
173  }
174 
175  //- Return the explicit correction to the snGrad for the given field
178  {
179  return nullptr;
180  }
181 
182  //- Return the snGrad of the given cell field
183  //- with explicit correction
186 
187  //- Return the snGrad of the given tmp cell field
188  //- with explicit correction
190  snGrad
191  (
193  ) const;
194 };
195 
196 
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 } // End namespace fv
200 
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 
203 } // End namespace Foam
204 
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 
207 // Add the patch constructor functions to the hash tables
208 
209 #define makeSnGradTypeScheme(SS, Type) \
210  defineNamedTemplateTypeNameAndDebug(Foam::fv::SS<Foam::Type>, 0); \
211  \
212  namespace Foam \
213  { \
214  namespace fv \
215  { \
216  snGradScheme<Type>::addMeshConstructorToTable<SS<Type>> \
217  add##SS##Type##MeshConstructorToTable_; \
218  } \
219  }
220 
221 #define makeSnGradScheme(SS) \
222  \
223 makeSnGradTypeScheme(SS, scalar) \
224 makeSnGradTypeScheme(SS, vector) \
225 makeSnGradTypeScheme(SS, sphericalTensor) \
226 makeSnGradTypeScheme(SS, symmTensor) \
227 makeSnGradTypeScheme(SS, tensor)
228 
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 #ifdef NoRepository
233  #include "snGradScheme.C"
234 #endif
235 
236 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237 
238 #endif
239 
240 // ************************************************************************* //
virtual tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > correction(const GeometricField< Type, fvPatchField, volMesh > &) const
Return the explicit correction to the snGrad for the given field.
Definition: snGradScheme.H:198
static tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > snGrad(const GeometricField< Type, fvPatchField, volMesh > &, const tmp< surfaceScalarField > &, const word &snGradName="snGrad")
Return the snGrad of the given cell field by using the given deltaCoeffs.
Definition: snGradScheme.C:86
virtual bool corrected() const noexcept
Return true if this scheme uses an explicit correction.
Definition: snGradScheme.H:189
Reference counter for various OpenFOAM components.
Definition: refCount.H:44
Forwards and collection of common volume field types.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
static tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > sndGrad(const GeometricField< Type, fvPatchField, volMesh > &, const word &snGradName="sndGrad")
Return the sndGrad of the given cell field.
Definition: snGradScheme.C:151
Generic GeometricField class.
Definition: areaFieldsFwd.H:50
static tmp< snGradScheme< Type > > New(const fvMesh &mesh, Istream &schemeData)
Return new tmp interpolation scheme.
Definition: snGradScheme.C:42
virtual tmp< surfaceScalarField > deltaCoeffs(const GeometricField< Type, fvPatchField, volMesh > &) const =0
Return the interpolation weighting factors for the given field.
A class for handling words, derived from Foam::string.
Definition: word.H:63
labelList fv(nPoints)
virtual const word & type() const =0
Runtime type information.
const direction noexcept
Definition: Scalar.H:258
declareRunTimeSelectionTable(tmp, snGradScheme, Mesh,(const fvMesh &mesh, Istream &schemeData),(mesh, schemeData))
Abstract base class for runtime selected snGrad surface normal gradient schemes.
Definition: snGradScheme.H:72
virtual ~snGradScheme()=default
Destructor.
const fvMesh & mesh() const
Return const reference to mesh.
Definition: snGradScheme.H:151
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Macros to ease declaration of run-time selection tables.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Namespace for OpenFOAM.