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 "areaFieldsFwd.H"
43 #include "edgeFieldsFwd.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 // Forward Declarations
51 class faMesh;
52 
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 
55 namespace fa
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  //- Reference to mesh
70  const faMesh& mesh_;
71 
72 
73 public:
74 
75  // Declare run-time constructor selection tables
76 
78  (
79  tmp,
80  gradScheme,
81  Istream,
82  (const faMesh& mesh, Istream& schemeData),
83  (mesh, schemeData)
84  );
85 
86 
87  // Generated Methods
88 
89  //- No copy construct
90  gradScheme(const gradScheme&) = delete;
91 
92  //- No copy assignment
93  void operator=(const gradScheme&) = delete;
94 
95 
96  // Constructors
97 
98  //- Construct from mesh
99  gradScheme(const faMesh& mesh)
100  :
101  mesh_(mesh)
102  {}
103 
104 
105  // Selectors
106 
107  //- Return a pointer to a new gradScheme created on freestore
108  static tmp<gradScheme<Type>> New
109  (
110  const faMesh& mesh,
111  Istream& schemeData
112  );
113 
114 
115  //- Destructor
116  virtual ~gradScheme() = default;
117 
118 
119  // Member Functions
120 
121  //- Return mesh reference
122  const faMesh& mesh() const noexcept { return mesh_; }
123 
124  //- Calculate and return the grad of the given field.
125  // Used by grad either to recalculate the cached gradient when it is
126  // out of date with respect to the field or when it is not cached.
127  virtual tmp
128  <
132  (
134  const word& name
135  ) const = 0;
136 
137  //- Calculate and return the grad of the given field
138  //- which may have been cached
139  tmp
140  <
143  > grad
144  (
146  const word& name
147  ) const;
148 
149  //- Calculate and return the grad of the given field
150  //- with the default name
151  //- which may have been cached
152  tmp
153  <
156  > grad
157  (
159  ) const;
160 
161  //- Calculate and return the grad of the given field
162  //- with the default name
163  //- which may have been cached
164  tmp
165  <
168  > grad
169  (
171  ) const;
172 };
173 
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 } // End namespace fa
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 } // End namespace Foam
182 
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 
185 // Add the patch constructor functions to the hash tables
186 
187 #define makeFaGradTypeScheme(SS, Type) \
188  \
189  defineNamedTemplateTypeNameAndDebug(Foam::fa::SS<Foam::Type>, 0); \
190  \
191  namespace Foam \
192  { \
193  namespace fa \
194  { \
195  gradScheme<Type>::addIstreamConstructorToTable<SS<Type>> \
196  add##SS##Type##IstreamConstructorToTable_; \
197  } \
198  }
199 
200 
201 #define makeFaGradScheme(SS) \
202  \
203 makeFaGradTypeScheme(SS, scalar) \
204 makeFaGradTypeScheme(SS, vector)
206 
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 
209 #ifdef NoRepository
210  #include "faGradScheme.C"
211 #endif
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 #endif
216 
217 // ************************************************************************* //
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:133
gradScheme(const gradScheme &)=delete
No copy construct.
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.
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:46
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
void operator=(const gradScheme &)=delete
No copy assignment.
const direction noexcept
Definition: Scalar.H:258
static tmp< gradScheme< Type > > New(const faMesh &mesh, Istream &schemeData)
Return a pointer to a new gradScheme created on freestore.
Definition: faGradScheme.C:40
Abstract base class for finite area calculus gradient schemes.
Definition: faGradScheme.H:58
virtual ~gradScheme()=default
Destructor.
Mesh data needed to do the Finite Area discretisation.
Definition: areaFaMesh.H:47
const faMesh & mesh() const noexcept
Return mesh reference.
Definition: faGradScheme.H:131
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.