faPatchField.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) 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::faPatchField
29
30Description
31 faPatchField<Type> abstract base class. This class gives a fat-interface
32 to all derived classes covering all possible ways in which they might be
33 used. The first level of derivation is to basic patchFields which cover
34 zero-gradient, fixed-gradient, fixed-value and mixed conditions. The next
35 level of derivation covers all the specialised typed with specific
36 evaluation procedures, particularly with respect to specific fields.
37
38Author
39 Zeljko Tukovic, FMENA
40 Hrvoje Jasak, Wikki Ltd.
41
42SourceFiles
43 faPatchField.C
44 newPatchField.C
45
46\*---------------------------------------------------------------------------*/
47
48#ifndef Foam_faPatchField_H
49#define Foam_faPatchField_H
50
51#include "faPatch.H"
52#include "DimensionedField.H"
53
54// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55
56namespace Foam
57{
58
59// Forward Declarations
60
61class objectRegistry;
62class dictionary;
63class faPatchFieldMapper;
64class areaMesh;
65
66template<class Type>
67class faPatchField;
68
69template<class Type>
70class calculatedFaPatchField;
71
72template<class Type>
74
75/*---------------------------------------------------------------------------*\
76 Class faPatchField Declaration
77\*---------------------------------------------------------------------------*/
78
79template<class Type>
80class faPatchField
81:
82 public Field<Type>
83{
84 // Private Data
85
86 //- Reference to a patch
87 const faPatch& patch_;
88
89 //- Reference to internal field
90 const DimensionedField<Type, areaMesh>& internalField_;
91
92 //- Update index used so that updateCoeffs is called only once during
93 // the construction of the matrix
94 bool updated_;
95
96 //- Optional patch type, used to allow specified boundary conditions
97 //- to be applied to constraint patches by providing the constraint
98 //- patch type as 'patchType'
99 word patchType_;
100
101
102public:
103
104 //- The internal field type associated with the patch field
106
107 //- The patch type for the patch field
108 typedef faPatch Patch;
109
110 //- Type for a \em calculated patch
112
113
114 //- Runtime type information
115 TypeName("faPatchField");
116
117 //- Debug switch to disallow the use of
119
120
121 // Declare run-time constructor selection tables
124 (
125 tmp,
127 patch,
128 (
129 const faPatch& p,
131 ),
132 (p, iF)
133 );
136 (
137 tmp,
139 patchMapper,
140 (
141 const faPatchField<Type>& ptf,
142 const faPatch& p,
144 const faPatchFieldMapper& m
145 ),
146 (dynamic_cast<const faPatchFieldType&>(ptf), p, iF, m)
147 );
150 (
151 tmp,
154 (
155 const faPatch& p,
157 const dictionary& dict
158 ),
159 (p, iF, dict)
160 );
161
162
163 // Constructors
164
165 //- Construct from patch and internal field
167 (
168 const faPatch&,
170 );
171
172 //- Construct from patch and internal field and patch field
174 (
175 const faPatch&,
177 const Field<Type>&
178 );
179
180 //- Construct from patch, internal field and dictionary
182 (
183 const faPatch&,
185 const dictionary&,
186 const bool valueRequired=true
187 );
188
189 //- Construct by mapping the given faPatchField onto a new patch
191 (
192 const faPatchField<Type>&,
193 const faPatch&,
195 const faPatchFieldMapper&
196 );
197
198 //- Construct as copy
200
201 //- Construct and return a clone
202 virtual tmp<faPatchField<Type>> clone() const
203 {
204 return tmp<faPatchField<Type>>(new faPatchField<Type>(*this));
205 }
206
207 //- Construct as copy setting internal field reference
209 (
210 const faPatchField<Type>&,
212 );
213
214 //- Construct and return a clone setting internal field reference
216 (
218 ) const
219 {
220 return tmp<faPatchField<Type>>(new faPatchField<Type>(*this, iF));
221 }
222
223
224 // Selectors
225
226 //- Return a pointer to a new patchField created on freestore given
227 //- patch and internal field
228 // (does not set the patch field values)
230 (
231 const word& patchFieldType,
232 const word& actualPatchType,
233 const faPatch&,
235 );
236
237 //- Return a pointer to a new patchField created on freestore given
238 //- patch and internal field
239 // (does not set the patch field values)
241 (
242 const word& patchFieldType,
243 const faPatch&,
245 );
246
247 //- Return a pointer to a new patchField created on freestore from
248 //- a given faPatchField mapped onto a new patch
250 (
251 const faPatchField<Type>&,
252 const faPatch&,
254 const faPatchFieldMapper&
255 );
256
257 //- Return a pointer to a new patchField created on freestore
258 //- from dictionary
260 (
261 const faPatch&,
263 const dictionary&
264 );
265
266 //- Return a pointer to a new calculatedFaPatchField created on
267 //- freestore without setting patchField values
268 template<class Type2>
270 (
272 );
273
274
275 //- Destructor
276 virtual ~faPatchField<Type>() = default;
277
278
279 // Member Functions
280
281 // Access
282
283 //- Return local objectRegistry
284 const objectRegistry& db() const;
285
286 //- Return patch
287 const faPatch& patch() const
288 {
289 return patch_;
290 }
291
292 //- Return dimensioned internal field reference
294 {
295 return internalField_;
296 }
297
298 //- Return internal field reference
299 const Field<Type>& primitiveField() const
300 {
301 return internalField_;
302 }
303
304 //- Optional patch type
305 const word& patchType() const
306 {
307 return patchType_;
308 }
309
310 //- Optional patch type
311 word& patchType()
312 {
313 return patchType_;
314 }
315
316 //- Return the type of the calculated for of faPatchField
317 static const word& calculatedType();
318
319 //- Return true if this patch field fixes a value.
320 // Needed to check if a level has to be specified while solving
321 // Poissons equations.
322 virtual bool fixesValue() const
323 {
324 return false;
325 }
326
327 //- Return true if this patch field is coupled
328 virtual bool coupled() const
329 {
330 return false;
331 }
332
333 //- Return true if the boundary condition has already been updated
334 bool updated() const
335 {
336 return updated_;
337 }
338
339
340 // Mapping
341
342 //- Map (and resize as needed) from self given a mapping object
343 virtual void autoMap
344 (
345 const faPatchFieldMapper&
346 );
347
348 //- Reverse map the given faPatchField onto this faPatchField
349 virtual void rmap
350 (
351 const faPatchField<Type>&,
352 const labelList&
353 );
354
355
356 // Evaluation
357
358 //- Return patch-normal gradient
359 virtual tmp<Field<Type>> snGrad() const;
360
361 //- Update the coefficients associated with the patch field
362 // Sets Updated to true
363 virtual void updateCoeffs()
364 {
365 updated_ = true;
366 }
367
368 //- Return internal field next to patch as patch field
369 virtual tmp<Field<Type>> patchInternalField() const;
370
371 //- Return patchField on the opposite patch of a coupled patch
372 virtual tmp<Field<Type>> patchNeighbourField() const
373 {
375 return *this;
376 }
377
378 //- Initialise the evaluation of the patch field
379 virtual void initEvaluate
380 (
381 const Pstream::commsTypes commsType =
383 )
384 {}
385
386 //- Evaluate the patch field, sets Updated to false
387 virtual void evaluate
388 (
389 const Pstream::commsTypes commsType =
391 );
392
393 //- Return the matrix diagonal coefficients corresponding to the
394 //- evaluation of the value of this patchField with given weights
396 (
397 const tmp<Field<scalar>>&
398 ) const
399 {
401 return *this;
402 }
403
404 //- Return the matrix source coefficients corresponding to the
405 //- evaluation of the value of this patchField with given weights
407 (
408 const tmp<Field<scalar>>&
409 ) const
410 {
412 return *this;
413 }
414
415 //- Return the matrix diagonal coefficients corresponding to the
416 //- evaluation of the gradient of this patchField
418 {
420 return *this;
421 }
422
423 //- Return the matrix source coefficients corresponding to the
424 //- evaluation of the gradient of this patchField
426 {
428 return *this;
429 }
430
431
432 // IO
433
434 //- Write
435 virtual void write(Ostream&) const;
436
437
438 // Check
439
440 //- Check faPatchField<Type> against given faPatchField<Type>
441 void check(const faPatchField<Type>&) const;
442
443
444 // Member Operators
445
446 virtual void operator=(const UList<Type>&);
447
448 virtual void operator=(const faPatchField<Type>&);
449 virtual void operator+=(const faPatchField<Type>&);
450 virtual void operator-=(const faPatchField<Type>&);
451 virtual void operator*=(const faPatchField<scalar>&);
452 virtual void operator/=(const faPatchField<scalar>&);
453
454 virtual void operator+=(const Field<Type>&);
455 virtual void operator-=(const Field<Type>&);
456
457 virtual void operator*=(const Field<scalar>&);
458 virtual void operator/=(const Field<scalar>&);
459
460 virtual void operator=(const Type&);
461 virtual void operator+=(const Type&);
462 virtual void operator-=(const Type&);
463 virtual void operator*=(const scalar);
464 virtual void operator/=(const scalar);
465
466
467 // Force an assignment irrespective of form of patch
468
469 virtual void operator==(const faPatchField<Type>&);
470 virtual void operator==(const Field<Type>&);
471 virtual void operator==(const Type&);
472
473
474 // Ostream operator
476 friend Ostream& operator<< <Type>(Ostream&, const faPatchField<Type>&);
477};
478
479
480// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
481
482} // End namespace Foam
483
484// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
485
486#ifdef NoRepository
487 #include "faPatchField.C"
488 #include "calculatedFaPatchField.H"
489#endif
490
492#define addToFaPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField) \
493 \
494addToRunTimeSelectionTable \
495( \
496 PatchTypeField, typePatchTypeField, patch \
497); \
498 \
499addToRunTimeSelectionTable \
500( \
501 PatchTypeField, \
502 typePatchTypeField, \
503 patchMapper \
504); \
505 \
506addToRunTimeSelectionTable \
507( \
508 PatchTypeField, typePatchTypeField, dictionary \
509);
510
512#define makeFaPatchTypeFieldTypeName(typePatchTypeField) \
513 \
514defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0);
515
517#define makeFaPatchFieldsTypeName(typePatchField) \
518 \
519makeFaPatchTypeFieldTypeName(typePatchField##FaPatchScalarField); \
520makeFaPatchTypeFieldTypeName(typePatchField##FaPatchVectorField); \
521makeFaPatchTypeFieldTypeName(typePatchField##FaPatchSphericalTensorField); \
522makeFaPatchTypeFieldTypeName(typePatchField##FaPatchSymmTensorField); \
523makeFaPatchTypeFieldTypeName(typePatchField##FaPatchTensorField);
524
526#define makeFaPatchTypeField(PatchTypeField, typePatchTypeField) \
527 \
528defineTypeNameAndDebug(typePatchTypeField, 0); \
529 \
530addToFaPatchFieldRunTimeSelection \
531( \
532 PatchTypeField, typePatchTypeField \
533);
535#define makeTemplateFaPatchTypeField(PatchTypeField, typePatchTypeField) \
536 \
537defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0); \
538 \
539addToFaPatchFieldRunTimeSelection \
540( \
541 PatchTypeField, typePatchTypeField \
542);
543
545#define makeFaPatchFields(type) \
546 \
547makeTemplateFaPatchTypeField(faPatchScalarField, type##FaPatchScalarField); \
548makeTemplateFaPatchTypeField(faPatchVectorField, type##FaPatchVectorField); \
549makeTemplateFaPatchTypeField \
550( \
551 faPatchSphericalTensorField, \
552 type##FaPatchSphericalTensorField \
553); \
554makeTemplateFaPatchTypeField \
555( \
556 faPatchSymmTensorField, \
557 type##FaPatchSymmTensorField \
558); \
559makeTemplateFaPatchTypeField \
560( \
561 faPatchTensorField, \
562 type##FaPatchTensorField \
563);
564
566#define makeFaPatchTypeFieldTypedefs(type) \
567 \
568typedef type##FaPatchField<scalar> type##FaPatchScalarField; \
569typedef type##FaPatchField<vector> type##FaPatchVectorField; \
570typedef type##FaPatchField<sphericalTensor> \
571 type##FaPatchSphericalTensorField; \
572typedef type##FaPatchField<symmTensor> type##FaPatchSymmTensorField; \
573typedef type##FaPatchField<tensor> type##FaPatchTensorField;
574
575
576// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
577
578#endif
579
580// ************************************************************************* //
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
commsTypes
Types of communications.
Definition: UPstream.H:67
Author Zeljko Tukovic, FMENA Hrvoje Jasak, Wikki Ltd.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A FieldMapper for finite-area patch fields.
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
Definition: faPatchField.H:82
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< Field< scalar > > &) const
Definition: faPatchField.H:406
virtual tmp< faPatchField< Type > > clone() const
Construct and return a clone.
Definition: faPatchField.H:201
virtual void initEvaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Initialise the evaluation of the patch field.
Definition: faPatchField.H:379
virtual bool fixesValue() const
Return true if this patch field fixes a value.
Definition: faPatchField.H:321
virtual tmp< Field< Type > > patchNeighbourField() const
Return patchField on the opposite patch of a coupled patch.
Definition: faPatchField.H:371
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field, sets Updated to false.
Definition: faPatchField.C:200
static int disallowGenericFaPatchField
Debug switch to disallow the use of.
Definition: faPatchField.H:117
virtual bool coupled() const
Return true if this patch field is coupled.
Definition: faPatchField.H:327
virtual tmp< Field< Type > > patchInternalField() const
Return internal field next to patch as patch field.
Definition: faPatchField.C:175
static tmp< faPatchField< Type > > New(const word &patchFieldType, const word &actualPatchType, const faPatch &, const DimensionedField< Type, areaMesh > &)
virtual void rmap(const faPatchField< Type > &, const labelList &)
Reverse map the given faPatchField onto this faPatchField.
Definition: faPatchField.C:190
faPatch Patch
The patch type for the patch field.
Definition: faPatchField.H:107
const faPatch & patch() const
Return patch.
Definition: faPatchField.H:286
virtual void operator==(const faPatchField< Type > &)
Definition: faPatchField.C:394
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
Definition: faPatchField.C:167
virtual void operator/=(const faPatchField< scalar > &)
Definition: faPatchField.C:287
virtual void operator-=(const faPatchField< Type > &)
Definition: faPatchField.C:259
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: faPatchField.H:362
declareRunTimeSelectionTable(tmp, faPatchField, dictionary,(const faPatch &p, const DimensionedField< Type, areaMesh > &iF, const dictionary &dict),(p, iF, dict))
const objectRegistry & db() const
Return local objectRegistry.
Definition: faPatchField.C:147
virtual void operator=(const UList< Type > &)
Definition: faPatchField.C:227
const Field< Type > & primitiveField() const
Return internal field reference.
Definition: faPatchField.H:298
calculatedFaPatchField< Type > Calculated
Type for a calculated patch.
Definition: faPatchField.H:110
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Definition: faPatchField.H:416
declareRunTimeSelectionTable(tmp, faPatchField, patchMapper,(const faPatchField< Type > &ptf, const faPatch &p, const DimensionedField< Type, areaMesh > &iF, const faPatchFieldMapper &m),(dynamic_cast< const faPatchFieldType & >(ptf), p, iF, m))
static tmp< faPatchField< Type > > NewCalculatedType(const faPatchField< Type2 > &)
declareRunTimeSelectionTable(tmp, faPatchField, patch,(const faPatch &p, const DimensionedField< Type, areaMesh > &iF),(p, iF))
virtual void operator+=(const faPatchField< Type > &)
Definition: faPatchField.C:248
const DimensionedField< Type, areaMesh > & internalField() const
Return dimensioned internal field reference.
Definition: faPatchField.H:292
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< Field< scalar > > &) const
Definition: faPatchField.H:395
virtual void autoMap(const faPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: faPatchField.C:182
virtual tmp< faPatchField< Type > > clone(const DimensionedField< Type, areaMesh > &iF) const
Construct and return a clone setting internal field reference.
Definition: faPatchField.H:215
const word & patchType() const
Optional patch type.
Definition: faPatchField.H:304
void check(const faPatchField< Type > &) const
Check faPatchField<Type> against given faPatchField<Type>
Definition: faPatchField.C:155
virtual void operator*=(const faPatchField< scalar > &)
Definition: faPatchField.C:270
DimensionedField< Type, areaMesh > Internal
The internal field type associated with the patch field.
Definition: faPatchField.H:104
word & patchType()
Optional patch type.
Definition: faPatchField.H:310
bool updated() const
Return true if the boundary condition has already been updated.
Definition: faPatchField.H:333
static const word & calculatedType()
Return the type of the calculated for of faPatchField.
TypeName("faPatchField")
Runtime type information.
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Definition: faPatchField.H:424
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition: faPatch.H:78
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
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
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