All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-2023 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 public:
71 
72  //- Runtime type information
73  virtual const word& type() const = 0;
74 
75 
76  // Declare run-time constructor selection tables
77 
79  (
80  tmp,
81  gradScheme,
82  Istream,
83  (const fvMesh& mesh, Istream& schemeData),
84  (mesh, schemeData)
85  );
86 
87 
88  // Constructors
89 
90  //- Construct from mesh
91  gradScheme(const fvMesh& mesh)
92  :
93  mesh_(mesh)
94  {}
95 
96  //- Disallow default bitwise copy construction
97  gradScheme(const gradScheme&) = delete;
98 
99 
100  // Selectors
101 
102  //- Return a pointer to a new gradScheme created on freestore
103  static tmp<gradScheme<Type>> New
104  (
105  const fvMesh& mesh,
106  Istream& schemeData
107  );
108 
109 
110  //- Destructor
111  virtual ~gradScheme();
112 
113 
114  // Member Functions
115 
116  //- Return mesh reference
117  const fvMesh& mesh() const
118  {
119  return mesh_;
120  }
121 
122  //- Calculate and return the grad of the given field.
123  // Used by grad either to recalculate the cached gradient when it is
124  // out of date with respect to the field or when it is not cached.
126  calcGrad
127  (
128  const VolField<Type>&,
129  const word& name
130  ) const = 0;
131 
132  //- Calculate and return the grad of the given field
133  // which may have been cached
135  grad
136  (
137  const VolField<Type>&,
138  const word& name
139  ) const;
140 
141  //- Calculate and return the grad of the given field
142  // with the default name
143  // which may have been cached
145  grad
146  (
147  const VolField<Type>&
148  ) const;
149 
150  //- Calculate and return the grad of the given field
151  // with the default name
152  // which may have been cached
154  grad
155  (
156  const tmp<VolField<Type>>&
157  ) const;
158 
159 
160  // Member Operators
161 
162  //- Disallow default bitwise assignment
163  void operator=(const gradScheme&) = delete;
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:99
Abstract base class for gradient schemes.
Definition: gradScheme.H:63
gradScheme(const fvMesh &mesh)
Construct from mesh.
Definition: gradScheme.H:90
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:116
void operator=(const gradScheme &)=delete
Disallow default bitwise assignment.
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 bool)
Return a word representation of a bool.
Definition: boolIO.C:39
labelList fv(nPoints)
Macros to ease declaration of run-time selection tables.
Basic run-time type information using word as the type's name. Used to enhance the standard RTTI to c...