fvsPatchField.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-2022 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::fvsPatchField
29
30Description
31 An abstract base class with a fat-interface to all derived classes
32 covering all possible ways in which they might be used.
33
34 The first level of derivation is to basic patchFields which cover
35 zero-gradient, fixed-gradient, fixed-value and mixed conditions.
36
37 The next level of derivation covers all the specialised typed with
38 specific evaluation procedures, particularly with respect to specific
39 fields.
40
41SourceFiles
42 fvsPatchField.C
43 fvsPatchFieldNew.C
44
45\*---------------------------------------------------------------------------*/
46
47#ifndef Foam_fvsPatchField_H
48#define Foam_fvsPatchField_H
49
50#include "fvPatch.H"
51#include "DimensionedField.H"
52
53// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54
55namespace Foam
56{
57
58// Forward Declarations
59
60class objectRegistry;
61class dictionary;
62class fvPatchFieldMapper;
63class surfaceMesh;
64
65template<class Type> class fvsPatchField;
66template<class Type> class calculatedFvsPatchField;
67
68template<class Type>
70
71
72/*---------------------------------------------------------------------------*\
73 Class patch Declaration
74\*---------------------------------------------------------------------------*/
75
76template<class Type>
77class fvsPatchField
78:
79 public Field<Type>
80{
81 // Private Data
82
83 //- Reference to patch
84 const fvPatch& patch_;
85
86 //- Reference to internal field
87 const DimensionedField<Type, surfaceMesh>& internalField_;
88
89
90public:
91
92 //- The internal field type associated with the patch field
94
95 //- The patch type for the patch field
96 typedef fvPatch Patch;
97
98 //- Type for a \em calculated patch
100
101
102 //- Runtime type information
103 TypeName("fvsPatchField");
104
105 //- Debug switch to disallow the use of genericFvsPatchField
107
108
109 // Declare run-time constructor selection tables
112 (
113 tmp,
115 patch,
116 (
117 const fvPatch& p,
119 ),
120 (p, iF)
121 );
124 (
125 tmp,
127 patchMapper,
128 (
129 const fvsPatchField<Type>& ptf,
130 const fvPatch& p,
132 const fvPatchFieldMapper& m
133 ),
134 (dynamic_cast<const fvsPatchFieldType&>(ptf), p, iF, m)
135 );
138 (
139 tmp,
142 (
143 const fvPatch& p,
145 const dictionary& dict
146 ),
147 (p, iF, dict)
148 );
149
150
151 // Constructors
152
153 //- Construct from patch and internal field
155 (
156 const fvPatch&,
158 );
159
160 //- Construct from patch and internal field and patch field
162 (
163 const fvPatch&,
165 const Field<Type>&
166 );
167
168 //- Construct from patch, internal field and dictionary
170 (
171 const fvPatch&,
173 const dictionary&,
174 const bool valueRequired=true
175 );
176
177 //- Construct by mapping the given fvsPatchField onto a new patch
179 (
180 const fvsPatchField<Type>&,
181 const fvPatch&,
183 const fvPatchFieldMapper&
184 );
185
186 //- Construct as copy
188
189 //- Construct and return a clone
190 virtual tmp<fvsPatchField<Type>> clone() const
191 {
192 return tmp<fvsPatchField<Type>>::New(*this);
193 }
194
195 //- Construct as copy setting internal field reference
197 (
198 const fvsPatchField<Type>&,
200 );
201
202 //- Construct and return a clone setting internal field reference
204 (
206 ) const
207 {
208 return tmp<fvsPatchField<Type>>::New(*this, iF);
209 }
210
211
212 // Selectors
213
214 //- Return a pointer to a new patchField created on freestore given
215 // patch and internal field
216 // (does not set the patch field values)
218 (
219 const word& patchFieldType,
220 const fvPatch&,
222 );
223
224 //- Return a pointer to a new patchField created on freestore given
225 // patch and internal field
226 // (does not set the patch field values)
227 // Allows override of constraint type
229 (
230 const word& patchFieldType,
231 const word& actualPatchType,
232 const fvPatch&,
234 );
235
236 //- Return a pointer to a new patchField created on freestore from
237 // a given fvsPatchField mapped onto a new patch
239 (
240 const fvsPatchField<Type>&,
241 const fvPatch&,
243 const fvPatchFieldMapper&
244 );
245
246 //- Return a pointer to a new patchField created on freestore
247 // from dictionary
249 (
250 const fvPatch&,
252 const dictionary&
253 );
254
255 //- Return a pointer to a new calculatedFvsPatchField created on
256 // freestore without setting patchField values
258 (
259 const fvPatch&
260 );
261
262 //- Return a pointer to a new calculatedFvsPatchField created on
263 // freestore without setting patchField values
264 template<class Type2>
266 (
268 );
269
270
271 //- Destructor
272 virtual ~fvsPatchField<Type>() = default;
273
274
275 // Member functions
276
277 // Access
278
279 //- Return local objectRegistry
280 const objectRegistry& db() const;
281
282 //- Return patch
283 const fvPatch& patch() const
284 {
285 return patch_;
286 }
287
288 //- Return dimensioned internal field reference
290 {
291 return internalField_;
292 }
293
294 //- Return internal field reference
295 const Field<Type>& primitiveField() const
296 {
297 return internalField_;
298 }
299
300 //- Return the type of the calculated for of fvsPatchField
301 static const word& calculatedType();
302
303 //- Return true if this patch field fixes a value.
304 // Needed to check if a level has to be specified while solving
305 // Poissons equations.
306 virtual bool fixesValue() const
307 {
308 return false;
309 }
310
311 //- Return true if this patch field is coupled
312 virtual bool coupled() const
313 {
314 return false;
315 }
316
317
318 // Mapping functions
319
320 //- Map (and resize as needed) from self given a mapping object
321 virtual void autoMap
322 (
323 const fvPatchFieldMapper&
324 );
325
326 //- Reverse map the given fvsPatchField onto this fvsPatchField
327 virtual void rmap
328 (
329 const fvsPatchField<Type>&,
330 const labelList&
331 );
332
333
334 //- Write
335 virtual void write(Ostream&) const;
336
337
338 // Check
339
340 //- Check fvsPatchField<Type> against given fvsPatchField<Type>
341 void check(const fvsPatchField<Type>&) const;
342
343
344 // Member operators
345
346 virtual void operator=(const UList<Type>&);
347
348 virtual void operator=(const fvsPatchField<Type>&);
349 virtual void operator+=(const fvsPatchField<Type>&);
350 virtual void operator-=(const fvsPatchField<Type>&);
351 virtual void operator*=(const fvsPatchField<scalar>&);
352 virtual void operator/=(const fvsPatchField<scalar>&);
353
354 virtual void operator+=(const Field<Type>&);
355 virtual void operator-=(const Field<Type>&);
356
357 virtual void operator*=(const Field<scalar>&);
358 virtual void operator/=(const Field<scalar>&);
359
360 virtual void operator=(const Type&);
361 virtual void operator+=(const Type&);
362 virtual void operator-=(const Type&);
363 virtual void operator*=(const scalar);
364 virtual void operator/=(const scalar);
365
366
367 // Force an assignment irrespective of form of patch
368
369 virtual void operator==(const fvsPatchField<Type>&);
370 virtual void operator==(const Field<Type>&);
371 virtual void operator==(const Type&);
372
373
374 // Ostream operator
376 friend Ostream& operator<< <Type>(Ostream&, const fvsPatchField<Type>&);
377};
378
379
380// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
381
382} // End namespace Foam
383
384// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
385
386#ifdef NoRepository
387 #include "fvsPatchField.C"
389#endif
390
392#define makeFvsPatchTypeFieldTypeName(type) \
393 \
394defineNamedTemplateTypeNameAndDebug(type, 0);
396#define makeFvsPatchFieldsTypeName(type) \
397 \
398makeFvsPatchTypeFieldTypeName(type##FvsPatchScalarField); \
399makeFvsPatchTypeFieldTypeName(type##FvsPatchVectorField); \
400makeFvsPatchTypeFieldTypeName(type##FvsPatchSphericalTensorField); \
401makeFvsPatchTypeFieldTypeName(type##FvsPatchSymmTensorField); \
402makeFvsPatchTypeFieldTypeName(type##FvsPatchTensorField);
404#define makeFvsPatchTypeField(PatchTypeField, typePatchTypeField) \
405 \
406defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0); \
407 \
408addToRunTimeSelectionTable \
409( \
410 PatchTypeField, typePatchTypeField, patch \
411); \
412 \
413addToRunTimeSelectionTable \
414( \
415 PatchTypeField, \
416 typePatchTypeField, \
417 patchMapper \
418); \
419 \
420addToRunTimeSelectionTable \
421( \
422 PatchTypeField, typePatchTypeField, dictionary \
423);
424
426#define makeFvsPatchFields(type) \
427 \
428makeFvsPatchTypeField(fvsPatchScalarField, type##FvsPatchScalarField); \
429makeFvsPatchTypeField(fvsPatchVectorField, type##FvsPatchVectorField); \
430makeFvsPatchTypeField \
431( \
432 fvsPatchSphericalTensorField, \
433 type##FvsPatchSphericalTensorField \
434); \
435makeFvsPatchTypeField(fvsPatchSymmTensorField, type##FvsPatchSymmTensorField); \
436makeFvsPatchTypeField(fvsPatchTensorField, type##FvsPatchTensorField);
437
439#define makeFvsPatchTypeFieldTypedefs(type) \
440 \
441typedef type##FvsPatchField<scalar> type##FvsPatchScalarField; \
442typedef type##FvsPatchField<vector> type##FvsPatchVectorField; \
443typedef type##FvsPatchField<sphericalTensor> \
444 type##FvsPatchSphericalTensorField; \
445typedef type##FvsPatchField<symmTensor> type##FvsPatchSymmTensorField; \
446typedef type##FvsPatchField<tensor> type##FvsPatchTensorField;
447
448
449// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
450
451#endif
452
453// ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic templated field type.
Definition: Field.H:82
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:94
Foam::calculatedFvsPatchField.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A FieldMapper for finite-volume patch fields.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:71
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:79
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
virtual bool fixesValue() const
Return true if this patch field fixes a value.
virtual void rmap(const fvsPatchField< Type > &, const labelList &)
Reverse map the given fvsPatchField onto this fvsPatchField.
virtual tmp< fvsPatchField< Type > > clone(const DimensionedField< Type, surfaceMesh > &iF) const
Construct and return a clone setting internal field reference.
virtual bool coupled() const
Return true if this patch field is coupled.
fvPatch Patch
The patch type for the patch field.
Definition: fvsPatchField.H:95
virtual void operator==(const fvsPatchField< Type > &)
declareRunTimeSelectionTable(tmp, fvsPatchField, patch,(const fvPatch &p, const DimensionedField< Type, surfaceMesh > &iF),(p, iF))
virtual tmp< fvsPatchField< Type > > clone() const
Construct and return a clone.
declareRunTimeSelectionTable(tmp, fvsPatchField, dictionary,(const fvPatch &p, const DimensionedField< Type, surfaceMesh > &iF, const dictionary &dict),(p, iF, dict))
const objectRegistry & db() const
Return local objectRegistry.
const DimensionedField< Type, surfaceMesh > & internalField() const
Return dimensioned internal field reference.
static tmp< fvsPatchField< Type > > NewCalculatedType(const fvPatch &)
Return a pointer to a new calculatedFvsPatchField created on.
virtual void operator=(const UList< Type > &)
const Field< Type > & primitiveField() const
Return internal field reference.
declareRunTimeSelectionTable(tmp, fvsPatchField, patchMapper,(const fvsPatchField< Type > &ptf, const fvPatch &p, const DimensionedField< Type, surfaceMesh > &iF, const fvPatchFieldMapper &m),(dynamic_cast< const fvsPatchFieldType & >(ptf), p, iF, m))
TypeName("fvsPatchField")
Runtime type information.
static tmp< fvsPatchField< Type > > NewCalculatedType(const fvsPatchField< Type2 > &)
Return a pointer to a new calculatedFvsPatchField created on.
DimensionedField< Type, surfaceMesh > Internal
The internal field type associated with the patch field.
Definition: fvsPatchField.H:92
static tmp< fvsPatchField< Type > > New(const word &patchFieldType, const fvPatch &, const DimensionedField< Type, surfaceMesh > &)
Return a pointer to a new patchField created on freestore given.
virtual void operator-=(const fvsPatchField< Type > &)
virtual void operator/=(const fvsPatchField< scalar > &)
virtual void operator+=(const fvsPatchField< Type > &)
calculatedFvsPatchField< Type > Calculated
Type for a calculated patch.
Definition: fvsPatchField.H:98
void check(const fvsPatchField< Type > &) const
Check fvsPatchField<Type> against given fvsPatchField<Type>
static int disallowGenericFvsPatchField
Debug switch to disallow the use of genericFvsPatchField.
virtual void operator*=(const fvsPatchField< scalar > &)
static const word & calculatedType()
Return the type of the calculated for of fvsPatchField.
const fvPatch & patch() const
Return patch.
Registry of regIOobjects.
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
volScalarField & p
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
runTime write()
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes)
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73