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-2020 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.
131  virtual tmp
132  <
135  > calcGrad
136  (
138  const word& name
139  ) const = 0;
140 
141  //- Calculate and return the grad of the given field
142  // which may have been cached
143  tmp
144  <
146  <typename outerProduct<vector, Type>::type, fvPatchField, volMesh>
147  > grad
148  (
150  const word& name
151  ) const;
152 
153  //- Calculate and return the grad of the given field
154  // with the default name
155  // which may have been cached
156  tmp
157  <
159  <typename outerProduct<vector, Type>::type, fvPatchField, volMesh>
160  > grad
161  (
163  ) const;
164 
165  //- Calculate and return the grad of the given field
166  // with the default name
167  // which may have been cached
168  tmp
169  <
171  <typename outerProduct<vector, Type>::type, fvPatchField, volMesh>
172  > grad
173  (
175  ) const;
176 };
177 
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 } // End namespace fv
182 
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 
185 } // End namespace Foam
186 
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 
189 // Add the patch constructor functions to the hash tables
191 #define makeFvGradTypeScheme(SS, Type) \
192  defineNamedTemplateTypeNameAndDebug(Foam::fv::SS<Foam::Type>, 0); \
193  \
194  namespace Foam \
195  { \
196  namespace fv \
197  { \
198  gradScheme<Type>::addIstreamConstructorToTable<SS<Type>> \
199  add##SS##Type##IstreamConstructorToTable_; \
200  } \
201  }
202 
204 #define makeFvGradScheme(SS) \
205  \
206 makeFvGradTypeScheme(SS, scalar) \
207 makeFvGradTypeScheme(SS, vector)
208 
209 
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 
212 #ifdef NoRepository
213  #include "gradScheme.C"
214 #endif
215 
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 
218 #endif
219 
220 // ************************************************************************* //
Reference counter for various OpenFOAM components.
Definition: refCount.H:49
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
typeOfRank< typename pTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank) >::type type
Definition: products.H:90
Generic GeometricField class.
declareRunTimeSelectionTable(tmp, gradScheme, Istream,(const fvMesh &mesh, Istream &schemeData),(mesh, schemeData))
Mesh data needed to do the Finite Volume discretisation.
Definition: volMesh.H:53
A class for handling words, derived from string.
Definition: word.H:59
labelList fv(nPoints)
virtual ~gradScheme()
Destructor.
Definition: gradScheme.C:78
virtual const word & type() const =0
Runtime type information.
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.
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Abstract base class for gradient schemes.
Definition: gradScheme.H:60
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:95
static tmp< gradScheme< Type > > New(const fvMesh &mesh, Istream &schemeData)
Return a pointer to a new gradScheme created on freestore.
Definition: gradScheme.C:34
Macros to ease declaration of run-time selection tables.
A class for managing temporary objects.
Definition: PtrList.H:53
const fvMesh & mesh() const
Return mesh reference.
Definition: gradScheme.H:122
Namespace for OpenFOAM.
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh > > grad(const GeometricField< Type, fvPatchField, volMesh > &, const word &name) const
Calculate and return the grad of the given field.