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