Loading...
Searching...
No Matches
faePatchField.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-2025 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::faePatchField
29
30Description
31 faePatchField<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 faePatchField.C
44 faePatchFieldBase.C
45 faePatchFieldNew.C
46
47\*---------------------------------------------------------------------------*/
48
49#ifndef Foam_faePatchField_H
50#define Foam_faePatchField_H
51
52#include "faPatch.H"
53#include "DimensionedField.H"
54#include "fieldTypes.H"
55
56// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57
58namespace Foam
59{
60
61// Forward Declarations
62class dictionary;
63class objectRegistry;
65class edgeMesh;
67template<class Type> class faePatchField;
68template<class Type> class calculatedFaePatchField;
69
70template<class Type>
72
73
74/*---------------------------------------------------------------------------*\
75 Class faePatchFieldBase Declaration
76\*---------------------------------------------------------------------------*/
77
78//- Template invariant parts for faePatchField
80{
81 // Private Data
82
83 //- Reference to patch
84 const faPatch& patch_;
85
86 //- Optional patch type
87 // Used to allow specified boundary conditions to be applied
88 // to constraint patches by providing the constraint
89 // patch type as 'patchType'
90 word patchType_;
91
92
93protected:
94
95 // Protected Member Functions
96
97 //- Read dictionary entries.
98 // Useful when initially constructed without a dictionary
99 virtual void readDict(const dictionary& dict);
100
101
102public:
103
104 //- Debug switch to disallow the use of generic faePatchField
105 static int disallowGenericPatchField;
106
107 //- Runtime type information
108 TypeName("faePatchField");
109
110
111 // Constructors
113 //- Construct from patch
114 explicit faePatchFieldBase(const faPatch& p);
115
116 //- Construct from patch and patch type
117 explicit faePatchFieldBase(const faPatch& p, const word& patchType);
118
119 //- Construct from patch and dictionary
120 faePatchFieldBase(const faPatch& p, const dictionary& dict);
121
122 //- Copy construct with new patch
124
125 //- Copy construct
127
128
129 //- Destructor
130 virtual ~faePatchFieldBase() = default;
131
132
133 // Static Member Functions
134
135 //- The type name for \c empty patch fields
136 static const word& emptyType() noexcept
137 {
139 }
140
141 //- The type name for \c calculated patch fields
142 static const word& calculatedType() noexcept
143 {
145 }
146
147 //- The type name for \c zeroValue patch fields
148 static const word& zeroValueType() noexcept
149 {
152
153
154 // Member Functions
155
156 // Attributes
157
158 //- True if the patch field fixes a value.
159 // Needed to check if a level has to be specified while solving
160 // Poissons equations.
161 virtual bool fixesValue() const
162 {
163 return false;
164 }
165
166 //- True if the patch field is coupled
167 virtual bool coupled() const
168 {
169 return false;
170 }
171
172
173 // Access
174
175 //- The associated objectRegistry
176 const objectRegistry& db() const;
177
178 //- Return the patch
179 const faPatch& patch() const noexcept
180 {
181 return patch_;
182 }
183
184 //- The optional patch type
185 const word& patchType() const noexcept
186 {
187 return patchType_;
188 }
189
190 //- The optional patch type
192 {
193 return patchType_;
194 }
195
196 //- True if the type does not correspond to the constraint type
197 virtual bool constraintOverride() const
198 {
199 return !patchType_.empty() && patchType_ != type();
200 }
201
202
203 // Solution
204
205 //- True if the boundary condition has already been updated.
206 //- This is always true for faePatchField
207 bool updated() const noexcept
208 {
209 return true;
210 }
211
212 //- Set updated state. This is a no-op for faePatchField
213 void setUpdated(bool state) noexcept
214 {}
216 //- True if the matrix has already been manipulated.
217 //- Always false for faePatchField
218 bool manipulatedMatrix() const noexcept
219 {
220 return false;
221 }
222
223 //- Set matrix manipulated state.
224 //- This is a no-op for faePatchField
225 void setManipulated(bool state) noexcept
226 {}
227
228
229 // Check
230
231 //- Check that patches are identical
232 void checkPatch(const faePatchFieldBase& rhs) const;
233};
234
235
236/*---------------------------------------------------------------------------*\
237 Class faePatchField Declaration
238\*---------------------------------------------------------------------------*/
240template<class Type>
241class faePatchField
242:
243 public faePatchFieldBase,
244 public Field<Type>
245{
246public:
247
248 // Public Data Types
249
250 //- The patch type for the patch field
251 typedef faPatch Patch;
252
253 //- The value_type for the patch field
254 typedef Type value_type;
255
256 //- The component type for patch field
257 typedef typename pTraits<Type>::cmptType cmptType;
258
259 //- The internal field type associated with the patch field
261
262 //- Type for a \em calculated patch
264
265
266private:
267
268 // Private Data
269
270 //- Reference to internal field
271 const DimensionedField<Type, edgeMesh>& internalField_;
272
273protected:
274
275 // Protected Member Functions
276
277 //- Read the "value" entry into \c *this.
278 // The reading can be optional (default), mandatory etc.
279 // \returns True on success
280 bool readValueEntry
281 (
282 const dictionary& dict,
284 );
285
286 //- Write \c *this field as a "value" entry
287 void writeValueEntry(Ostream& os) const
288 {
289 Field<Type>::writeEntry("value", os);
290 }
291
292
293public:
294
295 // Declare run-time constructor selection tables
296
298 (
299 tmp,
301 patch,
302 (
303 const faPatch& p,
305 ),
306 (p, iF)
307 );
308
311 tmp,
313 patchMapper,
314 (
316 const faPatch& p,
318 const faPatchFieldMapper& m
319 ),
320 (dynamic_cast<const faePatchFieldType&>(ptf), p, iF, m)
321 );
322
324 (
328 (
329 const faPatch& p,
331 const dictionary& dict
332 ),
333 (p, iF, dict)
334 );
335
336
337 // Constructors
338
339 //- Construct from patch and internal field
341 (
342 const faPatch&,
344 );
345
346 //- Construct from patch, internal field and value
348 (
349 const faPatch&,
351 const Type& value
352 );
353
354 //- Construct from patch, internal field and patch field
357 const faPatch&,
359 const Field<Type>& pfld
360 );
361
362 //- Construct from patch, internal field and patch field
364 (
365 const faPatch&,
367 Field<Type>&& pfld
368 );
369
370 //- Construct from patch, internal field and dictionary
371 // \note older versions have always treated "value" as optional
373 (
374 const faPatch&,
376 const dictionary& dict,
379 );
380
381 //- Construct by mapping the given faePatchField onto a new patch
383 (
384 const faePatchField<Type>&,
385 const faPatch&,
387 const faPatchFieldMapper&
388 );
389
390 //- Copy construct onto new patch with specified value
393 const faePatchField<Type>& pfld,
394 const faPatch& p,
396 const Type& value
397 );
398
399 //- Copy construct with internal field reference
401 (
402 const faePatchField<Type>& pfld,
404 );
405
406 //- Copy construct
408 :
409 faePatchField<Type>(pfld, pfld.internalField())
410 {}
412
413 //- Clone patch field with its own internal field reference
414 virtual tmp<faePatchField<Type>> clone() const
415 {
417 (
418 new faePatchField<Type>(*this, this->internalField_)
419 );
421
422 //- Clone with an internal field reference
424 (
426 ) const
427 {
428 return tmp<faePatchField<Type>>::New(*this, iF);
429 }
431
432 //- Destructor
433 virtual ~faePatchField() = default;
434
435
436 // Factory Methods
437
438 //- Clone a patch field, optionally with internal field reference etc.
439 template<class DerivedPatchField, class... Args>
441 (
442 const DerivedPatchField& pf,
443 Args&&... args
444 )
445 {
447 (
448 new DerivedPatchField(pf, std::forward<Args>(args)...)
449 );
450 }
451
452 //- Return a pointer to a new patchField created on freestore given
453 // patch and internal field
454 // (does not set the patch field values)
456 (
457 const word& patchFieldType,
458 const faPatch&,
460 );
461
462 //- Return a pointer to a new patchField created on freestore given
463 // patch and internal field
464 // (does not set the patch field values)
465 // Allows override of constraint type
467 (
468 const word& patchFieldType,
469 const word& actualPatchType,
470 const faPatch&,
472 );
473
474 //- Return a pointer to a new patchField created on freestore from
475 // a given faePatchField mapped onto a new patch
477 (
478 const faePatchField<Type>&,
479 const faPatch&,
481 const faPatchFieldMapper&
482 );
483
484 //- Return a pointer to a new patchField created on freestore
485 // from dictionary
487 (
488 const faPatch&,
490 const dictionary&
491 );
492
493 //- Return a pointer to a new calculatedFaePatchField created on
494 // freestore without setting patchField values
496 (
497 const faPatch& p
498 );
499
500 //- Return a pointer to a new calculatedFaePatchField created on
501 // freestore without setting patchField values
502 template<class AnyType>
505 const faePatchField<AnyType>& pf
506 );
507
508
509 // Member Functions
510
511 // Access
512
513 //- Return const-reference to the dimensioned internal field
516 return internalField_;
517 }
518
519 //- Return const-reference to the internal field values
520 const Field<Type>& primitiveField() const noexcept
521 {
522 return internalField_;
523 }
524
525
526 // Evaluation Functions
528 //- Initialise the evaluation of the patch field after a local
529 // operation
530 virtual void initEvaluateLocal
531 (
532 const Pstream::commsTypes commsType =
534 )
535 {}
537 //- Evaluate the patch field after a local operation (e.g. *=)
538 virtual void evaluateLocal
539 (
540 const Pstream::commsTypes commsType =
542 )
543 {}
544
545
546 // Mapping
547
548 //- Map (and resize as needed) from self given a mapping object
549 virtual void autoMap
550 (
551 const faPatchFieldMapper&
552 );
553
554 //- Reverse map the given faePatchField onto this faePatchField
555 virtual void rmap
556 (
557 const faePatchField<Type>&,
558 const labelList&
559 );
560
561
562 // Evaluation Functions
563
564 //- Initialise the evaluation of the patch field, generally a no-op
565 virtual void initEvaluate
566 (
569 {}
570
571 //- Evaluate the patch field, generally a no-op
572 virtual void evaluate
573 (
575 )
576 {}
577
578
579 // Other
580
581 //- Write
582 virtual void write(Ostream& os) const;
583
584 //- Check against given patch field
585 void check(const faePatchField<Type>&) const;
586
587
588 // Member Operators
589
590 virtual void operator=(const UList<Type>&);
591
592 virtual void operator=(const faePatchField<Type>&);
593 virtual void operator+=(const faePatchField<Type>&);
594 virtual void operator-=(const faePatchField<Type>&);
595 virtual void operator*=(const faePatchField<scalar>&);
596 virtual void operator/=(const faePatchField<scalar>&);
597
598 virtual void operator+=(const Field<Type>&);
599 virtual void operator-=(const Field<Type>&);
600
601 virtual void operator*=(const Field<scalar>&);
602 virtual void operator/=(const Field<scalar>&);
603
604 virtual void operator=(const Type&);
605 virtual void operator+=(const Type&);
606 virtual void operator-=(const Type&);
607 virtual void operator*=(const scalar);
608 virtual void operator/=(const scalar);
609
610
611 // Force an assignment irrespective of form of patch
612
613 virtual void operator==(const faePatchField<Type>&);
614 virtual void operator==(const Field<Type>&);
615 virtual void operator==(const Type&);
616
617 // Prevent automatic comparison rewriting (c++20)
618 bool operator!=(const faePatchField<Type>&) const = delete;
619 bool operator!=(const Field<Type>&) const = delete;
620 bool operator!=(const Type&) const = delete;
621
622
623 // Ostream Operator
624
625 friend Ostream& operator<< <Type>(Ostream&, const faePatchField<Type>&);
626};
627
628
629// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
631} // End namespace Foam
632
633// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
634
635#ifdef NoRepository
636 #include "faePatchField.C"
637 #include "faePatchFieldNew.C"
639#endif
640
641// Runtime selection macros
642#include "faePatchFieldMacros.H"
643
644// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
645
646#endif
647
648// ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
void writeEntry(const word &keyword, Ostream &os) const
Write the field as a dictionary entry.
Definition Field.C:754
constexpr Field() noexcept
Default construct.
Definition FieldI.H:24
readOption
Enumeration defining read preferences.
@ LAZY_READ
Reading is optional [identical to READ_IF_PRESENT].
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
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:89
commsTypes
Communications types.
Definition UPstream.H:81
@ buffered
"buffered" : (MPI_Bsend, MPI_Recv)
Definition UPstream.H:82
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:133
Mesh data needed to do the Finite Area discretisation.
Definition edgeFaMesh.H:50
A FieldMapper for finite-area patch fields.
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition faPatch.H:76
Template invariant parts for faePatchField.
virtual bool fixesValue() const
True if the patch field fixes a value.
TypeName("faePatchField")
Runtime type information.
virtual bool coupled() const
True if the patch field is coupled.
static const word & zeroValueType() noexcept
The type name for zeroValue patch fields.
static const word & calculatedType() noexcept
The type name for calculated patch fields.
faePatchFieldBase(const faPatch &p)
Construct from patch.
const objectRegistry & db() const
The associated objectRegistry.
virtual void readDict(const dictionary &dict)
Read dictionary entries.
void setManipulated(bool state) noexcept
Set matrix manipulated state. This is a no-op for faePatchField.
void setUpdated(bool state) noexcept
Set updated state. This is a no-op for faePatchField.
static int disallowGenericPatchField
Debug switch to disallow the use of generic faePatchField.
const word & patchType() const noexcept
The optional patch type.
bool manipulatedMatrix() const noexcept
True if the matrix has already been manipulated. Always false for faePatchField.
void checkPatch(const faePatchFieldBase &rhs) const
Check that patches are identical.
virtual bool constraintOverride() const
True if the type does not correspond to the constraint type.
bool updated() const noexcept
True if the boundary condition has already been updated. This is always true for faePatchField.
word & patchType() noexcept
The optional patch type.
static const word & emptyType() noexcept
The type name for empty patch fields.
virtual ~faePatchFieldBase()=default
Destructor.
const faPatch & patch() const noexcept
Return the patch.
faePatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cove...
const DimensionedField< scalar, edgeMesh > & internalField() const noexcept
faePatchField(const faPatch &, const DimensionedField< Type, edgeMesh > &, const Type &value)
Construct from patch, internal field and value.
virtual void operator/=(const Field< scalar > &)
virtual void operator+=(const faePatchField< Type > &)
static tmp< faePatchField< Type > > New(const word &patchFieldType, const word &actualPatchType, const faPatch &, const DimensionedField< Type, edgeMesh > &)
Return a pointer to a new patchField created on freestore given.
virtual void operator=(const faePatchField< Type > &)
declareRunTimeSelectionTable(tmp, faePatchField, patch,(const faPatch &p, const DimensionedField< Type, edgeMesh > &iF),(p, iF))
calculatedFaePatchField< Type > Calculated
Type for a calculated patch.
faePatchField(const faPatch &, const DimensionedField< Type, edgeMesh > &)
Construct from patch and internal field.
static tmp< faePatchField< Type > > New(const faPatch &, const DimensionedField< Type, edgeMesh > &, const dictionary &)
Return a pointer to a new patchField created on freestore.
faePatchField(const faPatch &, const DimensionedField< Type, edgeMesh > &, Field< Type > &&pfld)
Construct from patch, internal field and patch field.
virtual void operator=(const Type &)
declareRunTimeSelectionTable(tmp, faePatchField, patchMapper,(const faePatchField< Type > &ptf, const faPatch &p, const DimensionedField< Type, edgeMesh > &iF, const faPatchFieldMapper &m),(dynamic_cast< const faePatchFieldType & >(ptf), p, iF, m))
faePatchField(const faePatchField< Type > &pfld, const faPatch &p, const DimensionedField< Type, edgeMesh > &iF, const Type &value)
Copy construct onto new patch with specified value.
faePatchField(const faPatch &, const DimensionedField< Type, edgeMesh > &, const dictionary &dict, IOobjectOption::readOption requireValue=IOobjectOption::LAZY_READ)
Construct from patch, internal field and dictionary.
static tmp< faePatchField< Type > > NewCalculatedType(const faePatchField< AnyType > &pf)
Return a pointer to a new calculatedFaePatchField created on.
virtual void operator-=(const Type &)
Type value_type
The value_type for the patch field.
virtual void initEvaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Initialise the evaluation of the patch field, generally a no-op.
virtual void operator*=(const faePatchField< scalar > &)
faPatch Patch
The patch type for the patch field.
void writeValueEntry(Ostream &os) const
Write *this field as a "value" entry.
static tmp< faePatchField< Type > > NewCalculatedType(const faPatch &p)
Return a pointer to a new calculatedFaePatchField created on.
bool operator!=(const faePatchField< Type > &) const =delete
virtual void operator*=(const Field< scalar > &)
virtual void operator==(const Field< Type > &)
virtual void operator==(const faePatchField< Type > &)
virtual tmp< faePatchField< Type > > clone(const DimensionedField< Type, edgeMesh > &iF) const
Clone with an internal field reference.
virtual ~faePatchField()=default
Destructor.
virtual void operator+=(const Field< Type > &)
virtual void initEvaluateLocal(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Initialise the evaluation of the patch field after a local.
const Field< Type > & primitiveField() const noexcept
Return const-reference to the internal field values.
virtual void operator+=(const Type &)
virtual void evaluateLocal(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Evaluate the patch field after a local operation (e.g. *=).
virtual void operator-=(const Field< Type > &)
virtual void operator=(const UList< Type > &)
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Evaluate the patch field, generally a no-op.
void check(const faePatchField< Type > &) const
Check against given patch field.
pTraits< Type >::cmptType cmptType
The component type for patch field.
static tmp< faePatchField< Type > > New(const faePatchField< Type > &, const faPatch &, const DimensionedField< Type, edgeMesh > &, const faPatchFieldMapper &)
Return a pointer to a new patchField created on freestore from.
virtual void write(Ostream &os) const
Write.
DimensionedField< Type, edgeMesh > Internal
The internal field type associated with the patch field.
faePatchField(const faePatchField< Type > &pfld, const DimensionedField< Type, edgeMesh > &iF)
Copy construct with internal field reference.
virtual tmp< faePatchField< Type > > clone() const
Clone patch field with its own internal field reference.
virtual void operator/=(const scalar)
faePatchField(const faePatchField< Type > &pfld)
Copy construct.
bool operator!=(const Field< Type > &) const =delete
static tmp< faePatchField< Type > > New(const word &patchFieldType, const faPatch &, const DimensionedField< Type, edgeMesh > &)
Return a pointer to a new patchField created on freestore given.
faePatchField(const faPatch &, const DimensionedField< Type, edgeMesh > &, const Field< Type > &pfld)
Construct from patch, internal field and patch field.
virtual void operator/=(const faePatchField< scalar > &)
virtual void autoMap(const faPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
bool operator!=(const Type &) const =delete
bool readValueEntry(const dictionary &dict, IOobjectOption::readOption readOpt=IOobjectOption::LAZY_READ)
Read the "value" entry into *this.
virtual void operator-=(const faePatchField< Type > &)
static tmp< faePatchField< Type > > Clone(const DerivedPatchField &pf, Args &&... args)
Clone a patch field, optionally with internal field reference etc.
virtual void rmap(const faePatchField< Type > &, const labelList &)
Reverse map the given faePatchField onto this faePatchField.
declareRunTimeSelectionTable(tmp, faePatchField, dictionary,(const faPatch &p, const DimensionedField< Type, edgeMesh > &iF, const dictionary &dict),(p, iF, dict))
virtual void operator*=(const scalar)
virtual void operator==(const Type &)
faePatchField(const faePatchField< Type > &, const faPatch &, const DimensionedField< Type, edgeMesh > &, const faPatchFieldMapper &)
Construct by mapping the given faePatchField onto a new patch.
Registry of regIOobjects.
A traits class, which is primarily used for primitives and vector-space.
Definition pTraits.H:64
A class for managing temporary objects.
Definition tmp.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
volScalarField & p
OBJstream os(runTime.globalPath()/outputName)
Macros for creating faePatchField types.
const word calculatedType
A calculated patch field type.
const word emptyType
An empty patch field type.
const word zeroValueType
A zeroValue patch field type.
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition POSIX.C:801
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
const direction noexcept
Definition scalarImpl.H:265
runTime write()
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes).
dictionary dict
Foam::argList args(argc, argv)
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68