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
92 (
93 tmp,
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
109
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_;
130 }
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 <
139 > calcGrad
140 (
142 const word& name
143 ) const = 0;
144
145 //- Calculate and return the grad of the given field
146 //- which may have been cached
147 tmp
148 <
151 > grad
152 (
154 const word& name
155 ) const;
156
157 //- Calculate and return the grad of the given field
158 //- with the default name
159 //- which may have been cached
160 tmp
161 <
164 > grad
165 (
167 ) const;
168
169 //- Calculate and return the grad of the given field
170 //- with the default name
171 //- which may have been cached
172 tmp
173 <
176 > grad
177 (
179 ) const;
180};
181
182
183// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184
185} // End namespace fv
186
187// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188
189} // End namespace Foam
190
191// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192
193// Add the patch constructor functions to the hash tables
195#define makeFvGradTypeScheme(SS, Type) \
196 defineNamedTemplateTypeNameAndDebug(Foam::fv::SS<Foam::Type>, 0); \
197 \
198 namespace Foam \
199 { \
200 namespace fv \
201 { \
202 gradScheme<Type>::addIstreamConstructorToTable<SS<Type>> \
203 add##SS##Type##IstreamConstructorToTable_; \
204 } \
205 }
206
208#define makeFvGradScheme(SS) \
209 \
210makeFvGradTypeScheme(SS, scalar) \
211makeFvGradTypeScheme(SS, vector)
212
213
214// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215
216#ifdef NoRepository
217 #include "gradScheme.C"
218#endif
219
220// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221
222#endif
223
224// ************************************************************************* //
Generic GeometricField class.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:82
Abstract base class for gradient schemes.
Definition: gradScheme.H:66
gradScheme(const fvMesh &mesh)
Construct from mesh.
Definition: gradScheme.H:103
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
Definition: gradScheme.C:88
declareRunTimeSelectionTable(tmp, gradScheme, Istream,(const fvMesh &mesh, Istream &schemeData),(mesh, schemeData))
const fvMesh & mesh() const
Return const reference to mesh.
Definition: gradScheme.H:126
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:37
Reference counter for various OpenFOAM components.
Definition: refCount.H:51
A class for managing temporary objects.
Definition: tmp.H:65
Mesh data needed to do the Finite Volume discretisation.
Definition: volMesh.H:54
type
Volume classification types.
Definition: volumeType.H:66
A class for handling words, derived from Foam::string.
Definition: word.H:68
Namespace for OpenFOAM.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
labelList fv(nPoints)
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)