Loading...
Searching...
No Matches
GeometricBoundaryField.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-2017,2022 OpenFOAM Foundation
9 Copyright (C) 2015-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::GeometricBoundaryField
29
30Description
31 Generic GeometricBoundaryField class.
32
33SourceFiles
34 GeometricBoundaryField.C
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef Foam_GeometricBoundaryField_H
39#define Foam_GeometricBoundaryField_H
40
41#include "dimensionedTypes.H"
42#include "DimensionedField.H"
43#include "FieldField.H"
46
47// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48
49namespace Foam
50{
51
52/*---------------------------------------------------------------------------*\
53 Class GeometricBoundaryField Declaration
54\*---------------------------------------------------------------------------*/
55
56template<class Type, template<class> class PatchField, class GeoMesh>
58:
59 public FieldField<PatchField, Type>
60{
61public:
62
63 // Public Typedefs
64
65 //- The template instance used for this GeometricBoundaryField type
67
68 //- The boundary mesh type for the boundary fields
69 typedef typename GeoMesh::BoundaryMesh BoundaryMesh;
70
71 //- The internal field type associated with the boundary fields
74 //- This boundary field type
76
77 //- The patch field type for the boundary fields
78 typedef PatchField<Type> Patch;
79
80
81private:
82
83 // Private Data
84
85 //- Reference to BoundaryMesh for which this field is defined
86 const BoundaryMesh& bmesh_;
87
88
89 // Private Member Functions
90
91 //- Check if patch fields have been consistently evaluated.
92 // If not:
93 // exit = true : FatalError
94 // exit = false : return bool
95 template<class CheckPatchField>
96 bool checkConsistency(const scalar tol, const bool exitIfBad) const;
97
98
99public:
100
101 //- Enable debug
102 static int debug;
103
104
105 // Constructors
106
107 //- Construct from a BoundaryMesh, setting patches later
108 explicit GeometricBoundaryField(const BoundaryMesh& bmesh);
109
110 //- Construct from a BoundaryMesh, reference to the internal field
111 //- and a patch type
113 (
114 const BoundaryMesh& bmesh,
115 const Internal& iField,
116 const word& patchFieldType = PatchField<Type>::calculatedType()
117 );
118
119 //- Construct from a BoundaryMesh, reference to the internal field
120 //- and a wordList of patch types and optional the actual patch
121 //- types (to override constraint patches)
123 (
124 const BoundaryMesh& bmesh,
125 const Internal& iField,
126 const wordList& wantedPatchTypes,
127 const wordList& actualPatchTypes = wordList()
128 );
129
130 //- Construct from a BoundaryMesh, reference to the internal field
131 //- and a PtrList<PatchField<Type>> (to be cloned)
133 (
134 const BoundaryMesh& bmesh,
135 const Internal& iField,
136 const PtrList<PatchField<Type>>& ptfl
137 );
138
139 //- Construct as copy, setting the reference to the internal field
141 (
142 const Internal& iField,
144 );
145
146 //- Construct as copy, setting the reference to the internal field
147 //- and resetting type of field for given patch IDs
149 (
150 const Internal& iField,
153 const word& patchFieldName
154 );
155
156 //- Copy construct
157 // Dangerous because Field may be set to a field which gets deleted
158 // Need new type of BoundaryField, one which is part of a geometric
159 // field for which snGrad etc. may be called and a free standing
160 // BoundaryField for which such operations are unavailable.
163 //- Construct from dictionary
165 (
166 const BoundaryMesh& bmesh,
167 const Internal& iField,
168 const dictionary& dict
169 );
170
171
172 // Member Functions
173
174 //- Return non-const reference to this boundary field
176 {
177 return const_cast<this_type&>(*this);
178 }
179
180 //- Read the boundary field
181 void readField(const Internal& iField, const dictionary& dict);
182
183 //- Update the boundary condition coefficients
184 void updateCoeffs();
185
186 //- Evaluate boundary conditions for each patch field.
187 //- Uses specified or default comms.
189 (
191 );
192
193 //- Evaluate boundary conditions for patch fields matching the
194 //- given predicate. Uses specified or default comms.
195 template<class UnaryPredicate>
196 void evaluate_if
197 (
198 const UnaryPredicate& pred,
200 );
201
202 //- Evaluate boundary conditions after change in local values.
203 //- Uses specified or default comms.
204 void evaluateLocal
205 (
207 );
208
209 //- Evaluate boundary conditions on coupled patches of the given type,
210 //- using specified or default comms.
211 //
212 // \tparam CoupledPatchType The coupled \b patch type that should
213 // be evaluated. For a \c void type,
214 // all coupled patch fields will be evaluated.
215 template<class CoupledPatchType>
216 void evaluateCoupled
217 (
219 );
220
221 //- Evaluate boundary conditions for selected patches.
222 //- Uses non-blocking comms.
224
225 //- Return a list of the patch types
226 wordList types() const;
227
228 //- Return boundary field of values neighbouring the boundary
230
231 //- Return a list of pointers for each patch field with only those
232 //- pointing to interfaces being set
234
235 //- Return a list of pointers for each patch field with only those
236 //- pointing to interfaces being set
238
239 //- Helper: check if field has been evaluated. See instantiations.
240 bool check() const;
241
242
243 // Write
244
245 //- Write boundary field as dictionary entry
246 void writeEntry(const word& keyword, Ostream& os) const;
247
248 //- Write dictionary entries of the individual boundary fields.
249 void writeEntries(Ostream& os) const;
250
251
252 // Member Operators
253
254 //- Copy assignment from GeometricBoundaryField
255 void operator=(const GeometricBoundaryField& bf);
256
257 //- Copy assignment from FieldField<PatchField, Type>
259
260 //- Assignment to uniform value
261 void operator=(const Type& val);
262
263 //- Assignment to zero
264 void operator=(Foam::zero);
265
266 //- Forced assignment from GeometricBoundaryField
267 void operator==(const GeometricBoundaryField& bf);
268
269 //- Forced assignment from FieldField<PatchField, Type>
271
272 //- Forced assignment to uniform value
273 void operator==(const Type& val);
275 //- Forced assignment to zero
276 void operator==(Foam::zero) { *this == Type(Foam::zero{}); }
277
278 // Prevent automatic comparison rewriting (c++20)
279 bool operator!=(const GeometricBoundaryField&) = delete;
280 bool operator!=(const FieldField<PatchField, Type>&) = delete;
281 bool operator!=(const Type&) = delete;
282 bool operator!=(Foam::zero) = delete;
283};
284
286template<class Type, template<class> class PatchField, class GeoMesh>
287Ostream& operator<<
288(
289 Ostream&,
292
293
294// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
295
296} // End namespace Foam
297
298// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
299
300#ifdef NoRepository
301 #include "GeometricBoundaryField.C"
302#endif
303
304// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
305
306#endif
307
308// ************************************************************************* //
List of coupled interface fields to be used in coupling.
labelList patchIDs
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
Definition GeoMesh.H:46
MESH::BoundaryMesh BoundaryMesh
Definition GeoMesh.H:62
Generic GeometricBoundaryField class.
void operator=(Foam::zero)
Assignment to zero.
void evaluate_if(const UnaryPredicate &pred, const UPstream::commsTypes commsType=UPstream::defaultCommsType)
Evaluate boundary conditions for patch fields matching the given predicate. Uses specified or default...
GeometricBoundaryField(const BoundaryMesh &bmesh, const Internal &iField, const dictionary &dict)
Construct from dictionary.
lduInterfaceFieldPtrsList scalarInterfaces() const
Return a list of pointers for each patch field with only those pointing to interfaces being set.
void operator==(const Type &val)
Forced assignment to uniform value.
GeometricBoundaryField< Type, faPatchField, areaMesh > this_type
void evaluateSelected(const labelUList &patchIDs)
Evaluate boundary conditions for selected patches. Uses non-blocking comms.
wordList types() const
Return a list of the patch types.
this_type & constCast() const noexcept
Return non-const reference to this boundary field.
void operator=(const FieldField< PatchField, Type > &bf)
Copy assignment from FieldField<PatchField, Type>.
bool operator!=(const Type &)=delete
GeometricBoundaryField(const Internal &iField, const GeometricBoundaryField< Type, PatchField, GeoMesh > &btf, const labelList &patchIDs, const word &patchFieldName)
Construct as copy, setting the reference to the internal field and resetting type of field for given ...
LduInterfaceFieldPtrsList< Type > interfaces() const
Return a list of pointers for each patch field with only those pointing to interfaces being set.
void evaluateCoupled(const UPstream::commsTypes commsType=UPstream::defaultCommsType)
Evaluate boundary conditions on coupled patches of the given type, using specified or default comms.
void writeEntries(Ostream &os) const
Write dictionary entries of the individual boundary fields.
GeometricBoundaryField(const GeometricBoundaryField &btf)
Copy construct.
bool check() const
Helper: check if field has been evaluated. See instantiations.
GeometricBoundaryField< Type, faPatchField, areaMesh > Boundary
void writeEntry(const word &keyword, Ostream &os) const
Write boundary field as dictionary entry.
void updateCoeffs()
Update the boundary condition coefficients.
bool operator!=(const FieldField< PatchField, Type > &)=delete
GeometricBoundaryField(const BoundaryMesh &bmesh)
Construct from a BoundaryMesh, setting patches later.
bool operator!=(Foam::zero)=delete
void readField(const Internal &iField, const dictionary &dict)
Read the boundary field.
void operator==(Foam::zero)
Forced assignment to zero.
void evaluateLocal(const UPstream::commsTypes commsType=UPstream::defaultCommsType)
Evaluate boundary conditions after change in local values. Uses specified or default comms.
tmp< GeometricBoundaryField > boundaryInternalField() const
Return boundary field of values neighbouring the boundary.
GeometricBoundaryField(const BoundaryMesh &bmesh, const Internal &iField, const wordList &wantedPatchTypes, const wordList &actualPatchTypes=wordList())
Construct from a BoundaryMesh, reference to the internal field and a wordList of patch types and opti...
GeometricBoundaryField(const BoundaryMesh &bmesh, const Internal &iField, const PtrList< PatchField< Type > > &ptfl)
Construct from a BoundaryMesh, reference to the internal field and a PtrList<PatchField<Type>> (to be...
void operator=(const Type &val)
Assignment to uniform value.
GeometricBoundaryField(const Internal &iField, const GeometricBoundaryField< Type, PatchField, GeoMesh > &btf)
Construct as copy, setting the reference to the internal field.
void operator==(const FieldField< PatchField, Type > &bf)
Forced assignment from FieldField<PatchField, Type>.
void operator=(const GeometricBoundaryField &bf)
Copy assignment from GeometricBoundaryField.
void evaluate(const UPstream::commsTypes commsType=UPstream::defaultCommsType)
Evaluate boundary conditions for each patch field. Uses specified or default comms.
bool operator!=(const GeometricBoundaryField &)=delete
GeometricBoundaryField(const BoundaryMesh &bmesh, const Internal &iField, const word &patchFieldType=PatchField< Type >::calculatedType())
Construct from a BoundaryMesh, reference to the internal field and a patch type.
void operator==(const GeometricBoundaryField &bf)
Forced assignment from GeometricBoundaryField.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition PtrList.H:67
commsTypes
Communications types.
Definition UPstream.H:81
static commsTypes defaultCommsType
Default commsType.
Definition UPstream.H:1045
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A class for managing temporary objects.
Definition tmp.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition zero.H:58
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
List< word > wordList
List of word.
Definition fileName.H:60
List< label > labelList
A List of labels.
Definition List.H:62
const direction noexcept
Definition scalarImpl.H:265
UList< label > labelUList
A UList of labels.
Definition UList.H:75
UPtrList< const lduInterfaceField > lduInterfaceFieldPtrsList
List of coupled interface fields to be used in coupling.
UPtrList< const LduInterfaceField< Type > > LduInterfaceFieldPtrsList
Store lists of LduInterfaceField as a UPtrList.
dictionary dict