Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::fv::gradScheme
29
30Description
31 Abstract base class for gradient schemes.
32
33SourceFiles
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"
46
47// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48
49namespace Foam
50{
51
52class fvMesh;
53
54// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55
56namespace fv
57{
58
59/*---------------------------------------------------------------------------*\
60 Class gradScheme Declaration
61\*---------------------------------------------------------------------------*/
62
63template<class Type>
64class 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
83public:
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
110 // Selectors
111
112 //- Return a pointer to a new gradScheme created on freestore
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_;
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 <
142 const word& name
143 ) const = 0;
144
145 //- Calculate the grad of the given field into supplied field
146 virtual void calcGrad
147 (
151 ) const;
152
153 //- Calculate and return the grad of the given field
154 //- which may have been cached
155 tmp
156 <
159 > grad
160 (
162 const word& name
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 <
172 > grad
173 (
175 ) const;
176
177 //- Calculate and return the grad of the given field
178 //- with the default name
179 //- which may have been cached
180 tmp
181 <
184 > grad
185 (
187 ) const;
188};
189
190
191// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192
193} // End namespace fv
194
195// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196
197} // End namespace Foam
198
199// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200
201// Add the patch constructor functions to the hash tables
202
203#define makeFvGradTypeScheme(SS, Type) \
204 defineNamedTemplateTypeNameAndDebug(Foam::fv::SS<Foam::Type>, 0); \
205 \
206 namespace Foam \
207 { \
208 namespace fv \
209 { \
210 gradScheme<Type>::addIstreamConstructorToTable<SS<Type>> \
211 add##SS##Type##IstreamConstructorToTable_; \
212 } \
213 }
214
215
216#define makeFvGradScheme(SS) \
217 \
218makeFvGradTypeScheme(SS, scalar) \
219makeFvGradTypeScheme(SS, vector)
220
221
222// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223
224#ifdef NoRepository
225 #include "gradScheme.C"
226#endif
227
228// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229
230#endif
231
232// ************************************************************************* //
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:85
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
gradScheme(const fvMesh &mesh)
Construct from mesh.
Definition gradScheme.H:109
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.
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 which may have been cached.
Definition gradScheme.C:81
declareRunTimeSelectionTable(tmp, gradScheme, Istream,(const fvMesh &mesh, Istream &schemeData),(mesh, schemeData))
const fvMesh & mesh() const
Return const reference to mesh.
Definition gradScheme.H:138
virtual ~gradScheme()=default
Destructor.
virtual const word & type() const =0
Runtime type information.
static tmp< gradScheme< Type > > New(const fvMesh &mesh, Istream &schemeData)
Return a pointer to a new gradScheme created on freestore.
Definition gradScheme.C:30
typeOfRank< typenamepTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank)>::type type
Definition products.H:118
constexpr refCount() noexcept
Default construct, initializing count to 0.
Definition refCount.H:63
A class for managing temporary objects.
Definition tmp.H:75
Mesh data needed to do the Finite Volume discretisation.
Definition volMesh.H:47
A class for handling words, derived from Foam::string.
Definition word.H:66
dynamicFvMesh & mesh
Namespace for finite-volume.
Namespace for OpenFOAM.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
Macros to ease declaration of run-time selection tables.
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes).
Basic run-time type information using word as the type's name. Used to enhance the standard RTTI to c...
Forwards and collection of common volume field types.