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-2023 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 // Forward Declarations
53 class dictionary;
54 
55 template<class Type, template<class> class PatchField, class GeoMesh>
56 class GeometricField;
57 
58 /*---------------------------------------------------------------------------*\
59  Class GeometricBoundaryField Declaration
60 \*---------------------------------------------------------------------------*/
61 
62 template<class Type, template<class> class PatchField, class GeoMesh>
63 class GeometricBoundaryField
64 :
65  public FieldField<PatchField, Type>
66 {
67 public:
68 
69  // Public Typedefs
70 
71  //- The boundary mesh type for the boundary fields
72  typedef typename GeoMesh::BoundaryMesh BoundaryMesh;
73 
74  //- The internal field type associated with the boundary fields
76 
77  //- The patch field type for the boundary fields
78  typedef PatchField<Type> Patch;
79 
80 
81 private:
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  //- Helper: check if patchfields have been evaluated. If not:
92  // exit = true : FatalError
93  // exit = false : return bool
94  template<class CheckPatchField>
95  bool checkConsistency(const scalar tol, const bool exitIfBad) const;
96 
97 
98 public:
99 
100  //- Enable debug
101  static int debug;
102 
103  //- User-defined tolerance (for consistency checks)
104  static scalar tolerance;
105 
106  //- Enable local consistency
107  static int localConsistency;
108 
110  // Constructors
111 
112  //- Construct from a BoundaryMesh, setting patches later
113  explicit GeometricBoundaryField(const BoundaryMesh& bmesh);
115  //- Construct from a BoundaryMesh, reference to the internal field
116  //- and a patch type
118  (
119  const BoundaryMesh& bmesh,
121  const word& patchFieldType = PatchField<Type>::calculatedType()
122  );
123 
124  //- Construct from a BoundaryMesh, reference to the internal field
125  //- and a wordList of patch types and optional the actual patch
126  //- types (to override constraint patches)
128  (
129  const BoundaryMesh& bmesh,
131  const wordList& wantedPatchTypes,
132  const wordList& actualPatchTypes = wordList()
133  );
134 
135  //- Construct from a BoundaryMesh, reference to the internal field
136  //- and a PtrList<PatchField<Type>> (to be cloned)
138  (
139  const BoundaryMesh& bmesh,
141  const PtrList<PatchField<Type>>& ptfl
142  );
143 
144  //- Construct as copy, setting the reference to the internal field
146  (
149  );
150 
151  //- Construct as copy, setting the reference to the internal field
152  //- and resetting type of field for given patch IDs
154  (
157  const labelList& patchIDs,
158  const word& patchFieldName
159  );
160 
161  //- Copy construct
162  // Dangerous because Field may be set to a field which gets deleted
163  // Need new type of BoundaryField, one which is part of a geometric
164  // field for which snGrad etc. may be called and a free standing
165  // BoundaryField for which such operations are unavailable.
167 
168  //- Construct from dictionary
170  (
171  const BoundaryMesh& bmesh,
173  const dictionary& dict
174  );
175 
176 
177  // Member Functions
178 
179  //- Read the boundary field
180  void readField
181  (
183  const dictionary& dict
184  );
185 
186  //- Update the boundary condition coefficients
187  void updateCoeffs();
188 
189  //- Evaluate boundary conditions
190  void evaluate();
191 
192  //- Evaluate boundary conditions after change in local values
193  void evaluateLocal();
194 
195  //- Evaluate boundary conditions on a subset of coupled patches
196  template<class CoupledPatchType>
197  void evaluateCoupled();
198 
199  //- Evaluate boundary conditions for selected patches
201 
202  //- Return a list of the patch types
203  wordList types() const;
204 
205  //- Return boundary field of values neighbouring the boundary
207 
208  //- Return a list of pointers for each patch field with only those
209  //- pointing to interfaces being set
211 
212  //- Return a list of pointers for each patch field with only those
213  //- pointing to interfaces being set
215 
216  //- Write boundary field as dictionary entry
217  void writeEntry(const word& keyword, Ostream& os) const;
218 
219  //- Write dictionary entries of the individual boundary fields.
220  void writeEntries(Ostream& os) const;
221 
222  //- Helper: check if field has been evaluated. See instantiations.
223  bool check() const;
224 
225 
226  // Member Operators
227 
228  //- Copy assignment from GeometricBoundaryField
229  void operator=(const GeometricBoundaryField& bf);
230 
231  //- Copy assignment from FieldField<PatchField, Type>
232  void operator=(const FieldField<PatchField, Type>& bf);
233 
234  //- Assignment to uniform value
235  void operator=(const Type& val);
236 
237  //- Forced assignment from GeometricBoundaryField
238  void operator==(const GeometricBoundaryField& bf);
239 
240  //- Forced assignment from FieldField<PatchField, Type>
242 
243  //- Forced assignment to uniform value
244  void operator==(const Type& val);
245 
246  // Prevent automatic comparison rewriting (c++20)
247  bool operator!=(const GeometricBoundaryField&) = delete;
248  bool operator!=(const FieldField<PatchField, Type>&) = delete;
249  bool operator!=(const Type&) = delete;
250 };
251 
252 
253 template<class Type, template<class> class PatchField, class GeoMesh>
254 Ostream& operator<<
255 (
256  Ostream&,
258 );
259 
260 
261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
262 
263 } // End namespace Foam
264 
265 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
266 
267 #ifdef NoRepository
268  #include "GeometricBoundaryField.C"
269 #endif
270 
271 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
272 
273 #endif
274 
275 // ************************************************************************* //
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.
rDeltaTY field()
GeometricBoundaryField(const BoundaryMesh &bmesh)
Construct from a BoundaryMesh, setting patches later.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
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.
static scalar tolerance
User-defined tolerance (for consistency checks)
bool operator!=(const GeometricBoundaryField &)=delete
const word calculatedType
A calculated patch field type.
void evaluate()
Evaluate boundary conditions.
GeoMesh::BoundaryMesh BoundaryMesh
The boundary mesh type for the boundary fields.
void evaluateLocal()
Evaluate boundary conditions after change in local values.
A class for handling words, derived from Foam::string.
Definition: word.H:63
void operator==(const GeometricBoundaryField &bf)
Forced assignment from GeometricBoundaryField.
void evaluateSelected(const UList< label > &patchIDs)
Evaluate boundary conditions for selected patches.
void operator=(const GeometricBoundaryField &bf)
Copy assignment from GeometricBoundaryField.
void evaluateCoupled()
Evaluate boundary conditions on a subset of coupled patches.
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.
Definition: areaFieldsFwd.H:46
List< word > wordList
List of word.
Definition: fileName.H:59
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.
void readField(const DimensionedField< Type, GeoMesh > &field, const dictionary &dict)
Read the boundary field.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
LduInterfaceFieldPtrsList< Type > interfaces() const
Return a list of pointers for each patch field with only those pointing to interfaces being set...
GeometricBoundaryField boundaryInternalField() const
Return boundary field of values neighbouring the boundary.
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
List of coupled interface fields to be used in coupling.
Namespace for OpenFOAM.