gradScheme.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) 2019-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::gradScheme
29 
30 Description
31  Abstract base class for gradient schemes.
32 
33 SourceFiles
34  gradScheme.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef gradScheme_H
39 #define gradScheme_H
40 
41 #include "tmp.H"
42 #include "volFieldsFwd.H"
43 #include "surfaceFieldsFwd.H"
44 #include "typeInfo.H"
45 #include "runTimeSelectionTables.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 class fvMesh;
53 
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56 namespace fv
57 {
58 
59 /*---------------------------------------------------------------------------*\
60  Class gradScheme Declaration
61 \*---------------------------------------------------------------------------*/
62 
63 template<class Type>
64 class gradScheme
65 :
66  public refCount
67 {
68  // Private Data
69 
70  //- Reference to mesh
71  const fvMesh& mesh_;
72 
73 
74  // Private Member Functions
75 
76  //- No copy construct
77  gradScheme(const gradScheme&) = delete;
78 
79  //- No copy assignment
80  void operator=(const gradScheme&) = delete;
81 
82 
83 public:
84 
85  //- Runtime type information
86  virtual const word& type() const = 0;
87 
88 
89  // Declare run-time constructor selection tables
90 
92  (
93  tmp,
94  gradScheme,
95  Istream,
96  (const fvMesh& mesh, Istream& schemeData),
97  (mesh, schemeData)
98  );
99 
100 
101  // Constructors
102 
103  //- Construct from mesh
104  gradScheme(const fvMesh& mesh)
105  :
106  mesh_(mesh)
107  {}
108 
109 
110  // Selectors
111 
112  //- Return a pointer to a new gradScheme created on freestore
113  static tmp<gradScheme<Type>> New
114  (
115  const fvMesh& mesh,
116  Istream& schemeData
117  );
118 
119 
120  //- Destructor
121  virtual ~gradScheme() = default;
122 
123 
124  // Member Functions
125 
126  //- Return const reference to mesh
127  const fvMesh& mesh() const
128  {
129  return mesh_;
130  }
131 
132  //- Calculate and return the grad of the given field.
133  // Used by grad either to recalculate the cached gradient when it is
134  // out of date with respect to the field or when it is not cached.
135  virtual tmp
136  <
139  > calcGrad
140  (
142  const word& name
143  ) const = 0;
144 
145  //- Calculate and return the grad of the given field
146  //- which may have been cached
147  tmp
148  <
151  > grad
152  (
154  const word& name
155  ) const;
156 
157  //- Calculate and return the grad of the given field
158  //- with the default name
159  //- which may have been cached
160  tmp
161  <
164  > grad
165  (
167  ) const;
168 
169  //- Calculate and return the grad of the given field
170  //- with the default name
171  //- which may have been cached
172  tmp
173  <
176  > grad
177  (
179  ) const;
180 };
181 
182 
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 
185 } // End namespace fv
186 
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 
189 } // End namespace Foam
190 
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 
193 // Add the patch constructor functions to the hash tables
194 
195 #define makeFvGradTypeScheme(SS, Type) \
196  defineNamedTemplateTypeNameAndDebug(Foam::fv::SS<Foam::Type>, 0); \
197  \
198  namespace Foam \
199  { \
200  namespace fv \
201  { \
202  gradScheme<Type>::addIstreamConstructorToTable<SS<Type>> \
203  add##SS##Type##IstreamConstructorToTable_; \
204  } \
205  }
206 
207 
208 #define makeFvGradScheme(SS) \
209  \
210 makeFvGradTypeScheme(SS, scalar) \
211 makeFvGradTypeScheme(SS, vector)
212 
213 
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 
216 #ifdef NoRepository
217  #include "gradScheme.C"
218 #endif
219 
220 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221 
222 #endif
223 
224 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:51
volFieldsFwd.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
typeInfo.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::refCount
Reference counter for various OpenFOAM components.
Definition: refCount.H:50
Foam::volMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: volMesh.H:51
Foam::outerProduct::type
typeOfRank< typename pTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank) >::type type
Definition: products.H:114
Foam::fv::gradScheme::calcGrad
virtual tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh > > calcGrad(const GeometricField< Type, fvPatchField, volMesh > &, const word &name) const =0
Calculate and return the grad of the given field.
Foam::fv::gradScheme::type
virtual const word & type() const =0
Runtime type information.
Foam::fv::gradScheme::New
static tmp< gradScheme< Type > > New(const fvMesh &mesh, Istream &schemeData)
Return a pointer to a new gradScheme created on freestore.
Definition: gradScheme.C:37
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::fv::gradScheme::mesh
const fvMesh & mesh() const
Return const reference to mesh.
Definition: gradScheme.H:126
Foam::fv::gradScheme
Abstract base class for gradient schemes.
Definition: gradScheme.H:63
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
gradScheme.C
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fv::gradScheme::~gradScheme
virtual ~gradScheme()=default
Destructor.
fv
labelList fv(nPoints)
tmp.H
runTimeSelectionTables.H
Macros to ease declaration of run-time selection tables.
surfaceFieldsFwd.H
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::fv::gradScheme::gradScheme
gradScheme(const fvMesh &mesh)
Construct from mesh.
Definition: gradScheme.H:103
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53
Foam::fv::gradScheme::declareRunTimeSelectionTable
declareRunTimeSelectionTable(tmp, gradScheme, Istream,(const fvMesh &mesh, Istream &schemeData),(mesh, schemeData))
Foam::fv::gradScheme::grad
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh > > grad(const GeometricField< Type, fvPatchField, volMesh > &, const word &name) const