faGradScheme.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) 2016-2017 Wikki Ltd
9  Copyright (C) 2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::fa::gradScheme
29 
30 Description
31  Abstract base class for finite area calculus gradient schemes.
32 
33 SourceFiles
34  faGradScheme.C
35  faGradSchemes.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef faGradScheme_H
40 #define faGradScheme_H
41 
42 #include "tmp.H"
43 #include "areaFieldsFwd.H"
44 #include "edgeFieldsFwd.H"
45 #include "typeInfo.H"
46 #include "runTimeSelectionTables.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 class faMesh;
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 namespace fa
58 {
59 
60 /*---------------------------------------------------------------------------*\
61  Class gradScheme Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 template<class Type>
65 class gradScheme
66 :
67  public refCount
68 {
69  // Private data
70 
71  const faMesh& 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 
83 public:
84 
85  // Declare run-time constructor selection tables
86 
88  (
89  tmp,
90  gradScheme,
91  Istream,
92  (const faMesh& mesh, Istream& schemeData),
93  (mesh, schemeData)
94  );
95 
96 
97  // Constructors
98 
99  //- Construct from mesh
100  gradScheme(const faMesh& 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 faMesh& mesh,
112  Istream& schemeData
113  );
114 
115 
116  //- Destructor
117  virtual ~gradScheme() = default;
118 
119 
120  // Member Functions
121 
122  //- Return mesh reference
123  const faMesh& mesh() const { return mesh_; }
124 
125  //- Calculate and return the grad of the given field.
126  // Used by grad either to recalculate the cached gradient when it is
127  // out of date with respect to the field or when it is not cached.
128  virtual tmp
129  <
132  > calcGrad
133  (
135  const word& name
136  ) const = 0;
137 
138  //- Calculate and return the grad of the given field
139  //- which may have been cached
140  tmp
141  <
144  > grad
145  (
147  const word& name
148  ) const;
149 
150  //- Calculate and return the grad of the given field
151  //- with the default name
152  //- which may have been cached
153  tmp
154  <
157  > grad
158  (
160  ) const;
161 
162  //- Calculate and return the grad of the given field
163  //- with the default name
164  //- which may have been cached
165  tmp
166  <
169  > grad
170  (
172  ) const;
173 };
174 
175 
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 
178 } // End namespace fa
179 
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 
182 } // End namespace Foam
183 
184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 
186 // Add the patch constructor functions to the hash tables
187 
188 #define makeFaGradTypeScheme(SS, Type) \
189  \
190  defineNamedTemplateTypeNameAndDebug(Foam::fa::SS<Foam::Type>, 0); \
191  \
192  namespace Foam \
193  { \
194  namespace fa \
195  { \
196  gradScheme<Type>::addIstreamConstructorToTable<SS<Type>> \
197  add##SS##Type##IstreamConstructorToTable_; \
198  } \
199  }
200 
201 
202 #define makeFaGradScheme(SS) \
203  \
204 makeFaGradTypeScheme(SS, scalar) \
205 makeFaGradTypeScheme(SS, vector)
206 
207 
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 
210 #ifdef NoRepository
211  #include "faGradScheme.C"
212 #endif
213 
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 
216 #endif
217 
218 // ************************************************************************* //
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:87
const faMesh & mesh() const
Return mesh reference.
Definition: faGradScheme.H:130
Reference counter for various OpenFOAM components.
Definition: refCount.H:44
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
tmp< GeometricField< typename outerProduct< vector, Type >::type, faPatchField, areaMesh > > grad(const GeometricField< Type, faPatchField, areaMesh > &, const word &name) const
Calculate and return the grad of the given field which may have been cached.
typeOfRank< typename pTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank) >::type type
Definition: products.H:118
Generic GeometricField class.
Definition: areaFieldsFwd.H:50
virtual tmp< GeometricField< typename outerProduct< vector, Type >::type, faPatchField, areaMesh > > calcGrad(const GeometricField< Type, faPatchField, areaMesh > &, const word &name) const =0
Calculate and return the grad of the given field.
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
Definition: areaFieldsFwd.H:56
Forwards for edge field types.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
A class for handling words, derived from Foam::string.
Definition: word.H:63
static tmp< gradScheme< Type > > New(const faMesh &mesh, Istream &schemeData)
Return a pointer to a new gradScheme created on freestore.
Definition: faGradScheme.C:41
Abstract base class for finite area calculus gradient schemes.
Definition: faGradScheme.H:60
virtual ~gradScheme()=default
Destructor.
Mesh data needed to do the Finite Area discretisation.
Definition: areaFaMesh.H:47
Macros to ease declaration of run-time selection tables.
declareRunTimeSelectionTable(tmp, gradScheme, Istream,(const faMesh &mesh, Istream &schemeData),(mesh, schemeData))
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Forwards and collection of common area field types.
Namespace for OpenFOAM.