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-2024 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::GeometricBoundaryField
29 
30 Description
31  Generic GeometricBoundaryField class.
32 
33 SourceFiles
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 
49 namespace Foam
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class GeometricBoundaryField Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 template<class Type, template<class> class PatchField, class GeoMesh>
58 :
59  public FieldField<PatchField, Type>
60 {
61 public:
62 
63  // Public Typedefs
64 
65  //- The boundary mesh type for the boundary fields
66  typedef typename GeoMesh::BoundaryMesh BoundaryMesh;
67 
68  //- The internal field type associated with the boundary fields
70 
71  //- This boundary field type
73 
74  //- The patch field type for the boundary fields
75  typedef PatchField<Type> Patch;
76 
77 
78 private:
79 
80  // Private Data
81 
82  //- Reference to BoundaryMesh for which this field is defined
83  const BoundaryMesh& bmesh_;
84 
85 
86  // Private Member Functions
87 
88  //- Helper: check if patchfields have been evaluated. If not:
89  // exit = true : FatalError
90  // exit = false : return bool
91  template<class CheckPatchField>
92  bool checkConsistency(const scalar tol, const bool exitIfBad) const;
93 
94 
95 public:
96 
97  //- Enable debug
98  static int debug;
99 
100  //- User-defined tolerance (for consistency checks)
101  static scalar tolerance;
102 
103  //- Enable local consistency
104  static int localConsistency;
105 
106 
107  // Constructors
109  //- Construct from a BoundaryMesh, setting patches later
110  explicit GeometricBoundaryField(const BoundaryMesh& bmesh);
111 
112  //- Construct from a BoundaryMesh, reference to the internal field
113  //- and a patch type
115  (
116  const BoundaryMesh& bmesh,
117  const Internal& iField,
118  const word& patchFieldType = PatchField<Type>::calculatedType()
119  );
120 
121  //- Construct from a BoundaryMesh, reference to the internal field
122  //- and a wordList of patch types and optional the actual patch
123  //- types (to override constraint patches)
125  (
126  const BoundaryMesh& bmesh,
127  const Internal& iField,
128  const wordList& wantedPatchTypes,
129  const wordList& actualPatchTypes = wordList()
130  );
131 
132  //- Construct from a BoundaryMesh, reference to the internal field
133  //- and a PtrList<PatchField<Type>> (to be cloned)
135  (
136  const BoundaryMesh& bmesh,
137  const Internal& iField,
138  const PtrList<PatchField<Type>>& ptfl
139  );
140 
141  //- Construct as copy, setting the reference to the internal field
143  (
144  const Internal& iField,
146  );
147 
148  //- Construct as copy, setting the reference to the internal field
149  //- and resetting type of field for given patch IDs
151  (
152  const Internal& iField,
154  const labelList& patchIDs,
155  const word& patchFieldName
156  );
157 
158  //- Copy construct
159  // Dangerous because Field may be set to a field which gets deleted
160  // Need new type of BoundaryField, one which is part of a geometric
161  // field for which snGrad etc. may be called and a free standing
162  // BoundaryField for which such operations are unavailable.
164 
165  //- Construct from dictionary
167  (
168  const BoundaryMesh& bmesh,
169  const Internal& iField,
170  const dictionary& dict
171  );
172 
173 
174  // Member Functions
175 
176  //- Read the boundary field
177  void readField(const Internal& iField, const dictionary& dict);
178 
179  //- Update the boundary condition coefficients
180  void updateCoeffs();
181 
182  //- Evaluate boundary conditions for each patch field.
183  //- Uses specified or default comms.
184  void evaluate
185  (
187  );
188 
189  //- Evaluate boundary conditions for patch fields matching the
190  //- given predicate. Uses specified or default comms.
191  template<class UnaryPredicate>
192  void evaluate_if
193  (
194  const UnaryPredicate& pred,
196  );
197 
198  //- Evaluate boundary conditions after change in local values.
199  //- Uses specified or default comms.
200  void evaluateLocal
201  (
203  );
204 
205  //- Evaluate boundary conditions on coupled patches of given type.
206  //- Uses specified or default comms.
207  template<class CoupledPatchType>
208  void evaluateCoupled
209  (
211  );
212 
213  //- Evaluate boundary conditions for selected patches.
214  //- Uses non-blocking comms.
215  void evaluateSelected(const labelUList& patchIDs);
216 
217  //- Return a list of the patch types
218  wordList types() const;
219 
220  //- Return boundary field of values neighbouring the boundary
222 
223  //- Return a list of pointers for each patch field with only those
224  //- pointing to interfaces being set
226 
227  //- Return a list of pointers for each patch field with only those
228  //- pointing to interfaces being set
230 
231  //- Helper: check if field has been evaluated. See instantiations.
232  bool check() const;
233 
234 
235  // Write
236 
237  //- Write boundary field as dictionary entry
238  void writeEntry(const word& keyword, Ostream& os) const;
239 
240  //- Write dictionary entries of the individual boundary fields.
241  void writeEntries(Ostream& os) const;
242 
243 
244  // Member Operators
245 
246  //- Copy assignment from GeometricBoundaryField
247  void operator=(const GeometricBoundaryField& bf);
248 
249  //- Copy assignment from FieldField<PatchField, Type>
250  void operator=(const FieldField<PatchField, Type>& bf);
251 
252  //- Assignment to uniform value
253  void operator=(const Type& val);
254 
255  //- Forced assignment from GeometricBoundaryField
256  void operator==(const GeometricBoundaryField& bf);
257 
258  //- Forced assignment from FieldField<PatchField, Type>
260 
261  //- Forced assignment to uniform value
262  void operator==(const Type& val);
263 
264  // Prevent automatic comparison rewriting (c++20)
265  bool operator!=(const GeometricBoundaryField&) = delete;
266  bool operator!=(const FieldField<PatchField, Type>&) = delete;
267  bool operator!=(const Type&) = delete;
268 };
269 
270 
271 template<class Type, template<class> class PatchField, class GeoMesh>
272 Ostream& operator<<
273 (
274  Ostream&,
276 );
277 
278 
279 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
280 
281 } // End namespace Foam
282 
283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
284 
285 #ifdef NoRepository
286  #include "GeometricBoundaryField.C"
287 #endif
288 
289 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
290 
291 #endif
292 
293 // ************************************************************************* //
const labelList patchIDs(pbm.indices(polyPatchNames, true))
dictionary dict
PatchField< Type > Patch
The patch field type for the boundary fields.
static int localConsistency
Enable local consistency.
GeometricBoundaryField(const BoundaryMesh &bmesh)
Construct from a BoundaryMesh, setting patches later.
tmp< GeometricBoundaryField > boundaryInternalField() const
Return boundary field of values neighbouring the boundary.
commsTypes
Communications types.
Definition: UPstream.H:77
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
void evaluate(const UPstream::commsTypes commsType=UPstream::defaultCommsType)
Evaluate boundary conditions for each patch field. Uses specified or default comms.
MESH::BoundaryMesh BoundaryMesh
Definition: GeoMesh.H:59
lduInterfaceFieldPtrsList scalarInterfaces() const
Return a list of pointers for each patch field with only those pointing to interfaces being set...
wordList types() const
Return a list of the patch types.
GeometricBoundaryField< Type, PatchField, GeoMesh > Boundary
This boundary field type.
static scalar tolerance
User-defined tolerance (for consistency checks)
void evaluateCoupled(const UPstream::commsTypes commsType=UPstream::defaultCommsType)
Evaluate boundary conditions on coupled patches of given type. Uses specified or default comms...
void evaluateLocal(const UPstream::commsTypes commsType=UPstream::defaultCommsType)
Evaluate boundary conditions after change in local values. Uses specified or default comms...
A field of fields is a PtrList of fields with reference counting.
Definition: FieldField.H:51
bool operator!=(const GeometricBoundaryField &)=delete
const word calculatedType
A calculated patch field type.
GeoMesh::BoundaryMesh BoundaryMesh
The boundary mesh type for the boundary fields.
A class for handling words, derived from Foam::string.
Definition: word.H:63
void operator==(const GeometricBoundaryField &bf)
Forced assignment from GeometricBoundaryField.
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...
void evaluateSelected(const labelUList &patchIDs)
Evaluate boundary conditions for selected patches. Uses non-blocking comms.
void operator=(const GeometricBoundaryField &bf)
Copy assignment from GeometricBoundaryField.
void readField(const Internal &iField, const dictionary &dict)
Read the boundary field.
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: HashTable.H:106
bool check() const
Helper: check if field has been evaluated. See instantiations.
void updateCoeffs()
Update the boundary condition coefficients.
DimensionedField< Type, GeoMesh > Internal
The internal field type associated with the boundary fields.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
OBJstream os(runTime.globalPath()/outputName)
Generic GeometricBoundaryField class.
List< word > wordList
List of word.
Definition: fileName.H:59
static commsTypes defaultCommsType
Default commsType.
Definition: UPstream.H:397
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
void writeEntry(const word &keyword, Ostream &os) const
Write boundary field as dictionary entry.
static int debug
Enable debug.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
LduInterfaceFieldPtrsList< Type > interfaces() const
Return a list of pointers for each patch field with only those pointing to interfaces being set...
void writeEntries(Ostream &os) const
Write dictionary entries of the individual boundary fields.
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
Definition: GeoMesh.H:42
A class for managing temporary objects.
Definition: HashPtrTable.H:50
List of coupled interface fields to be used in coupling.
Namespace for OpenFOAM.