polySurface.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) 2019-2022 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::polySurface
28
29Description
30 A surface mesh consisting of general polygon faces and capable of
31 holding fields.
32
33SourceFiles
34 polySurface.C
35 polySurfaceClear.C
36 polySurfaceIO.C
37 polySurfaceTemplates.C
38
39\*---------------------------------------------------------------------------*/
40
41#ifndef Foam_polySurface_H
42#define Foam_polySurface_H
43
44#include "objectRegistry.H"
45#include "PrimitivePatch.H"
46#include "meshedSurf.H"
48
49// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50
51namespace Foam
52{
53
54// Forward Declarations
55class dimensionSet;
56class surfZone;
57class polySurfaceGeoMesh;
58class polySurfacePointGeoMesh;
59
60template<class Face> class MeshedSurface;
61
62
63/*---------------------------------------------------------------------------*\
64 Class polySurface Declaration
65\*---------------------------------------------------------------------------*/
67class polySurface
68:
69 public objectRegistry,
70 public PrimitivePatch<::Foam::List<face>, pointField>,
71 public meshedSurf
72{
73public:
74
75 //- Enumeration for the field association
77 {
78 NO_DATA = 0,
80 POINT_DATA = 2,
82 };
83
84
85private:
86
87 // Private Typedefs
88
89 //- Internal mesh storage type
91 MeshReference;
92
93
94 // Private Data
95
96 //- Per-face zone/region information
97 labelList zoneIds_;
98
99
100 // Private Member Functions
101
102 //- Calculate per-face zone/region information
103 void calculateZoneIds(const UList<surfZone>& zones);
104
105 //- No copy construct
106 polySurface(const polySurface&) = delete;
107
108 //- No copy assignment
109 void operator=(const polySurface&) = delete;
110
111
112protected:
113
114 // Protected Member Functions
115
116 //- Non-const access to points
118 {
119 return const_cast<pointField&>(MeshReference::points());
120 }
121
122 //- Non-const access to the faces
124 {
125 return static_cast<faceList&>(static_cast<MeshReference&>(*this));
126 }
127
128 //- Const access to the faces
129 const faceList& storedFaces() const
130 {
131 return
132 static_cast<const faceList&>
133 (
134 static_cast<const MeshReference&>(*this)
135 );
136 }
137
138
139public:
140
141 // Public Typedefs
142
143 //- Typedef required for GeoMesh
144 typedef polySurface Mesh;
145
146 //- Placeholder only, for GeoMesh
147 typedef bool BoundaryMesh;
148
149 //- Name for point fields sub-registry
150 static const word pointDataName;
151
152
153 //- Runtime type information
154 TypeName("polySurface");
155
156
157 // Constructors
158
159 //- Construct null with NO_READ, NO_WRITE
160 //- optionally with a checkIn on the parent registry.
161 // Created without a PointData sub-registry
162 explicit polySurface(const IOobject& io, bool doCheckIn = false);
163
164 //- Construct null with specified name on the given registry,
165 //- optionally with a checkIn on the parent registry.
166 // Created without a PointData sub-registry
168 (
169 const word& surfName,
170 const objectRegistry& obr,
171 bool doCheckIn = false
172 );
173
174 //- Copy construct from MeshedSurface<face> contents
175 //- with NO_READ, NO_WRITE
176 //- optionally with a checkIn on the parent registry.
177 // Created without a PointData sub-registry
179 (
180 const IOobject& io,
181 const MeshedSurface<face>& surf,
182 bool doCheckIn = false
183 );
184
185 //- Move construct from MeshedSurface<face> contents
186 //- with NO_READ, NO_WRITE
187 //- optionally with a checkIn on the parent registry.
188 // Created without a PointData sub-registry
190 (
191 const IOobject& io,
192 MeshedSurface<face>&& surf,
193 bool doCheckIn = false
194 );
195
196
197 //- Destructor
198 virtual ~polySurface();
199
200
201 // Member Functions
202
203 // Resolve iterator ambiguity in favour of Patch (not registry)
204
205 using MeshReference::end;
209
210
211 // Access
212
213 //- Return the number of points
214 virtual label nPoints() const
215 {
216 return MeshReference::points().size();
217 }
218
219 //- Return the number of faces
220 virtual label nFaces() const
221 {
222 return MeshReference::size();
223 }
224
225 //- Return number of faces
226 virtual label size() const
227 {
228 return MeshReference::size();
229 }
230
231
232 //- Return points
233 virtual const pointField& points() const
234 {
235 return MeshReference::points();
236 }
237
238 //- Return faces
239 virtual const faceList& faces() const
240 {
241 return this->storedFaces();
242 }
243
244 //- Const access to per-face zone/region information (demand-driven)
245 virtual const labelList& zoneIds() const
246 {
247 return zoneIds_;
248 }
249
250 //- Return face area vectors (normals)
251 const vectorField& Sf() const
252 {
254 }
255
256 //- Return face area magnitudes
257 const scalarField& magSf() const
258 {
260 }
261
262 //- Face centres
263 const vectorField& Cf() const
264 {
266 }
267
268
269 // Modification
270
271 //- Update with new contents
272 void copySurface
273 (
274 const pointField& points,
275 const faceList& faces,
276 bool unused=false
277 );
278
279 //- Update with new contents
280 void copySurface
281 (
282 const meshedSurf& surf,
283 bool unused=false
284 );
285
286 //- Update with new contents
287 void copySurface
288 (
289 const MeshedSurface<face>& surf,
290 bool unused=false
291 );
292
293 //- Transfer the contents of the argument and annul the argument
294 // Optionally validate the zone coverage.
295 void transfer
296 (
298 faceList&& faces,
300 );
301
302 //- Transfer the contents of the argument and annul the argument
303 // Optionally validate the zone coverage.
304 void transfer
305 (
307 bool validate=false
308 );
309
310
311 // Fields
312
313 //- Number of main entries, without PointData sub-registry
314 label nFaceData() const;
315
316 //- Number of entries on PointData sub-registry (if it exists)
317 label nPointData() const;
318
319 //- Query the field association (FACE or POINT)
320 FieldAssociation queryFieldAssociation(const word& fieldName) const;
321
322 //- Find the field object with the given name and required
323 //- FieldAssociation (FACE or POINT).
324 // For FACE_POINT_DATA, face data are checked first.
325 // \return nullptr is the field was not found
327 (
328 const word& fieldName,
329 const FieldAssociation association
330 ) const;
331
332 //- General finding of the field object (FACE or POINT)
333 // Later specializations are used to restrict the scope.
334 // \return nullptr is the field was not found
335 template<class GeoMeshType = void>
336 const regIOobject* findFieldObject(const word& fieldName) const;
337
338 //- General finding of the registry with the field object
339 //- (FACE or POINT).
340 // Later specializations are used to restrict the scope.
341 // \return nullptr is the field was not found
342 template<class GeoMeshType = void>
343 const objectRegistry* whichRegistry(const word& fieldName) const;
344
345 //- Regular data are stored directly on the registry
346 template<class DataType>
347 inline const objectRegistry& fieldData() const
348 {
349 return static_cast<const objectRegistry&>(*this);
350 }
351
352 //- Face data are stored directly on the registry
353 const objectRegistry& faceData() const;
354
355 //- Point data are stored in a sub-registry
356 // Note that this method with automatically create the corresponding
357 // sub-registry if it did not previously exist.
358 // Use the nPointData() methods instead if you wish to test for
359 // content without this side-effect.
360 const objectRegistry& pointData() const;
361
362
363 //- Copy/store named field as face or point data (template parameter).
364 //
365 // Default is face-data (polySurfaceGeoMesh as template).
366 // For point data use (polySurfacePointGeoMesh as template).
367 template<class Type, class GeoMeshType = polySurfaceGeoMesh>
368 void storeField
369 (
370 const word& fieldName,
371 const dimensionSet& dims,
372 const Field<Type>& values
373 );
374
375 //- Move/store named field as face or point data (template parameter).
376 //
377 // Default is face-data (polySurfaceGeoMesh as template).
378 // For point data use (polySurfacePointGeoMesh as template).
379 template<class Type, class GeoMeshType = polySurfaceGeoMesh>
380 void storeField
381 (
382 const word& fieldName,
383 const dimensionSet& dims,
384 Field<Type>&& values
385 );
386
387
388 // Writing
389
390 //- Write - this is a no-op
391 virtual bool writeObject
392 (
393 IOstreamOption streamOpt,
394 const bool valid
395 ) const;
396
397
398 // Storage Management
399
400 //- Clear geometry
401 void clearGeom();
402
403 //- Clear addressing
404 void clearAddressing();
405
406 //- Clear all geometry and addressing unnecessary for CFD
407 void clearOut();
408
409 //- Clear primitive data (points, faces and cells)
410 void clearPrimitives();
411
412 //- Clear stored fields
413 void clearFields();
414};
415
416
417//- Find face field object (on main registry).
418template<>
419const regIOobject* polySurface::findFieldObject<polySurfaceGeoMesh>
420(
421 const word& fieldName
422) const;
423
424
425//- Find point field object (on sub-registry)
426template<>
427const regIOobject* polySurface::findFieldObject<polySurfacePointGeoMesh>
428(
429 const word& fieldName
430) const;
431
432
433//- Return field object (on main registry).
434//- Face data field found on main registry?
435template<>
436const objectRegistry* polySurface::whichRegistry<polySurfaceGeoMesh>
437(
438 const word& fieldName
439) const;
440
441
442//- Point data field found on sub-registry?
443template<>
444const objectRegistry* polySurface::whichRegistry<polySurfaceGeoMesh>
445(
446 const word& fieldName
447) const;
448
449
450//- Point data are stored in a sub-registry
451template<>
452inline const objectRegistry&
454{
455 return pointData();
456}
457
458
459// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
460
461} // End namespace Foam
462
463// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
464
465#ifdef NoRepository
466 #include "polySurfaceTemplates.C"
467#endif
468
469// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
470
471#endif
472
473// ************************************************************************* //
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
The IOstreamOption is a simple container for options an IOstream can normally have.
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
Definition: MeshedSurface.H:99
A list of faces which address into the list of points.
const Field< point_type > & points() const noexcept
Return reference to global points.
const Field< point_type > & faceAreas() const
Return face area vectors for patch.
const Field< point_type > & faceCentres() const
Return face centres for patch.
const Field< scalar > & magFaceAreas() const
Return face area magnitudes for patch.
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
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Definition: dimensionSet.H:109
const edgeFaceCirculator cend() const
edgeFaceCirculator cbegin() const
edgeFaceCirculator begin() const
Iterator set to the beginning face. For internal edges this is.
The field association for mesh (patch/volume) values.
Abstract definition of a meshed surface defined by faces and points.
Definition: meshedSurf.H:50
Registry of regIOobjects.
A surface mesh consisting of general polygon faces and capable of holding fields.
Definition: polySurface.H:71
virtual label size() const
Return number of faces.
Definition: polySurface.H:225
virtual const pointField & points() const
Return points.
Definition: polySurface.H:232
const objectRegistry & faceData() const
Face data are stored directly on the registry.
Definition: polySurface.C:198
void copySurface(const pointField &points, const faceList &faces, bool unused=false)
Update with new contents.
Definition: polySurface.C:280
const vectorField & Sf() const
Return face area vectors (normals)
Definition: polySurface.H:250
pointField & storedPoints()
Non-const access to points.
Definition: polySurface.H:116
label nFaceData() const
Number of main entries, without PointData sub-registry.
Definition: polySurface.C:170
void clearGeom()
Clear geometry.
virtual ~polySurface()
Destructor.
Definition: polySurface.C:162
faceList & storedFaces()
Non-const access to the faces.
Definition: polySurface.H:122
const scalarField & magSf() const
Return face area magnitudes.
Definition: polySurface.H:256
void clearPrimitives()
Clear primitive data (points, faces and cells)
virtual label nFaces() const
Return the number of faces.
Definition: polySurface.H:219
TypeName("polySurface")
Runtime type information.
const objectRegistry * whichRegistry(const word &fieldName) const
const objectRegistry & pointData() const
Point data are stored in a sub-registry.
Definition: polySurface.C:204
virtual const faceList & faces() const
Return faces.
Definition: polySurface.H:238
virtual const labelList & zoneIds() const
Const access to per-face zone/region information (demand-driven)
Definition: polySurface.H:244
label nPointData() const
Number of entries on PointData sub-registry (if it exists)
Definition: polySurface.C:184
const vectorField & Cf() const
Face centres.
Definition: polySurface.H:262
polySurface Mesh
Typedef required for GeoMesh.
Definition: polySurface.H:143
virtual bool writeObject(IOstreamOption streamOpt, const bool valid) const
Write - this is a no-op.
Definition: polySurfaceIO.C:33
void clearAddressing()
Clear addressing.
FieldAssociation
Enumeration for the field association.
Definition: polySurface.H:76
@ FACE_DATA
Data associated with faces.
Definition: polySurface.H:78
@ POINT_DATA
Data associated with points.
Definition: polySurface.H:79
@ FACE_OR_POINT_DATA
Data associated with faces or points.
Definition: polySurface.H:80
@ NO_DATA
No associated data.
Definition: polySurface.H:77
void transfer(pointField &&points, faceList &&faces, labelList &&zoneIds=labelList())
Transfer the contents of the argument and annul the argument.
Definition: polySurface.C:371
void storeField(const word &fieldName, const dimensionSet &dims, const Field< Type > &values)
Copy/store named field as face or point data (template parameter).
void clearFields()
Clear stored fields.
const objectRegistry & fieldData() const
Regular data are stored directly on the registry.
Definition: polySurface.H:346
virtual label nPoints() const
Return the number of points.
Definition: polySurface.H:213
FieldAssociation queryFieldAssociation(const word &fieldName) const
Query the field association (FACE or POINT)
Definition: polySurface.C:212
const regIOobject * findFieldObject(const word &fieldName) const
General finding of the field object (FACE or POINT)
bool BoundaryMesh
Placeholder only, for GeoMesh.
Definition: polySurface.H:146
void clearOut()
Clear all geometry and addressing unnecessary for CFD.
static const word pointDataName
Name for point fields sub-registry.
Definition: polySurface.H:149
const faceList & storedFaces() const
Const access to the faces.
Definition: polySurface.H:128
const regIOobject * findFieldObject(const word &fieldName, const FieldAssociation association) const
Definition: polySurface.C:242
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:76
A class for handling words, derived from Foam::string.
Definition: word.H:68
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition: List.H:66
thermo validate(args.executable(), "h")
Simple convenient storage of field residuals.
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73