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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::fv::gradScheme
28 
29 Description
30  Abstract base class for gradient schemes.
31 
32 SourceFiles
33  gradScheme.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef gradScheme_H
38 #define gradScheme_H
39 
40 #include "tmp.H"
41 #include "volFieldsFwd.H"
42 #include "surfaceFieldsFwd.H"
43 #include "typeInfo.H"
44 #include "runTimeSelectionTables.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 class fvMesh;
52 
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 
55 namespace fv
56 {
57 
58 /*---------------------------------------------------------------------------*\
59  Class gradScheme Declaration
60 \*---------------------------------------------------------------------------*/
61 
62 template<class Type>
63 class gradScheme
64 :
65  public refCount
66 {
67  // Private data
68 
69  const fvMesh& mesh_;
70 
71 
72  // Private Member Functions
73 
74  //- No copy construct
75  gradScheme(const gradScheme&) = delete;
76 
77  //- No copy assignment
78  void operator=(const gradScheme&) = delete;
79 
80 
81 public:
82 
83  //- Runtime type information
84  virtual const word& type() const = 0;
85 
86 
87  // Declare run-time constructor selection tables
88 
90  (
91  tmp,
92  gradScheme,
93  Istream,
94  (const fvMesh& mesh, Istream& schemeData),
95  (mesh, schemeData)
96  );
97 
98 
99  // Constructors
100 
101  //- Construct from mesh
102  gradScheme(const fvMesh& mesh)
103  :
104  mesh_(mesh)
105  {}
106 
107 
108  // Selectors
109 
110  //- Return a pointer to a new gradScheme created on freestore
111  static tmp<gradScheme<Type>> New
112  (
113  const fvMesh& mesh,
114  Istream& schemeData
115  );
116 
117 
118  //- Destructor
119  virtual ~gradScheme() = default;
120 
121 
122  // Member Functions
123 
124  //- Return mesh reference
125  const fvMesh& mesh() const
126  {
127  return mesh_;
128  }
129 
130  //- Calculate and return the grad of the given field.
131  // Used by grad either to recalculate the cached gradient when it is
132  // out of date with respect to the field or when it is not cached.
133  virtual tmp
134  <
137  > calcGrad
138  (
140  const word& name
141  ) const = 0;
142 
143  //- Calculate and return the grad of the given field
144  // which may have been cached
145  tmp
146  <
149  > grad
150  (
152  const word& name
153  ) const;
154 
155  //- Calculate and return the grad of the given field
156  // with the default name
157  // which may have been cached
158  tmp
159  <
162  > grad
163  (
165  ) const;
166 
167  //- Calculate and return the grad of the given field
168  // with the default name
169  // which may have been cached
170  tmp
171  <
174  > grad
175  (
177  ) const;
178 };
179 
180 
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182 
183 } // End namespace fv
184 
185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186 
187 } // End namespace Foam
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 // Add the patch constructor functions to the hash tables
192 
193 #define makeFvGradTypeScheme(SS, Type) \
194  defineNamedTemplateTypeNameAndDebug(Foam::fv::SS<Foam::Type>, 0); \
195  \
196  namespace Foam \
197  { \
198  namespace fv \
199  { \
200  gradScheme<Type>::addIstreamConstructorToTable<SS<Type>> \
201  add##SS##Type##IstreamConstructorToTable_; \
202  } \
203  }
204 
205 
206 #define makeFvGradScheme(SS) \
207  \
208 makeFvGradTypeScheme(SS, scalar) \
209 makeFvGradTypeScheme(SS, vector)
210 
211 
212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213 
214 #ifdef NoRepository
215  #include "gradScheme.C"
216 #endif
217 
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 
220 #endif
221 
222 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:50
volFieldsFwd.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
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:50
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::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
Foam::fv::gradScheme::mesh
const fvMesh & mesh() const
Return mesh reference.
Definition: gradScheme.H:124
Foam::fv::gradScheme
Abstract base class for gradient schemes.
Definition: gradScheme.H:62
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:83
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::fv::gradScheme::gradScheme
gradScheme(const fvMesh &mesh)
Construct from mesh.
Definition: gradScheme.H:101
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
Calculate and return the grad of the given field.