Loading...
Searching...
No Matches
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-2024 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;
59
60template<class Face> class MeshedSurface;
61
63/*---------------------------------------------------------------------------*\
64 Class polySurface Declaration
65\*---------------------------------------------------------------------------*/
66
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,
79 FACE_DATA = 1,
80 POINT_DATA = 2,
82 };
83
84
85private:
86
87 // Private Typedefs
88
89 //- Internal mesh storage type
90 typedef
92 MeshReference;
93
94
95 // Private Data
96
97 //- Per-face zone/region information
98 labelList zoneIds_;
99
100
101 // Private Member Functions
102
103 //- Calculate per-face zone/region information
104 void calculateZoneIds(const UList<surfZone>& zones);
105
106
107protected:
108
109 // Protected Member Functions
110
111 //- Non-const access to points
113 {
114 return const_cast<pointField&>(MeshReference::points());
115 }
116
117 //- Non-const access to the faces
119 {
120 return
121 static_cast<faceList&>
122 (
123 static_cast<MeshReference&>(*this)
124 );
126
127 //- Const access to the faces
128 const faceList& storedFaces() const
129 {
130 return
131 static_cast<const faceList&>
132 (
133 static_cast<const MeshReference&>(*this)
134 );
135 }
136
138public:
139
140 // Public Typedefs
141
142 //- Typedef required for GeoMesh
143 typedef polySurface Mesh;
144
145 //- Placeholder only, for GeoMesh
146 typedef bool BoundaryMesh;
147
148 //- Name for point fields sub-registry
149 static const word pointDataName;
150
151
152 //- Runtime type information
153 TypeName("polySurface");
155
156 // Generated Methods
157
158 //- No copy construct
159 polySurface(const polySurface&) = delete;
160
161 //- No copy assignment
162 void operator=(const polySurface&) = delete;
163
165 // Constructors
166
167 //- Default construct with NO_READ, NO_WRITE
168 //- optionally with a checkIn on the parent registry.
169 // Created without a PointData sub-registry
170 explicit polySurface(const IOobject& io, bool doCheckIn = false);
171
172 //- Default construct with specified name on the given registry,
173 //- optionally with a checkIn on the parent registry.
174 // Created without a PointData sub-registry
176 (
177 const word& surfName,
178 const objectRegistry& obr,
179 bool doCheckIn = false
180 );
181
182 //- Copy construct from MeshedSurface<face> contents
183 //- with NO_READ, NO_WRITE
184 //- optionally with a checkIn on the parent registry.
185 // Created without a PointData sub-registry
187 (
188 const IOobject& io,
189 const MeshedSurface<face>& surf,
190 bool doCheckIn = false
191 );
192
193 //- Move construct from MeshedSurface<face> contents
194 //- with NO_READ, NO_WRITE
195 //- optionally with a checkIn on the parent registry.
196 // Created without a PointData sub-registry
198 (
199 const IOobject& io,
200 MeshedSurface<face>&& surf,
201 bool doCheckIn = false
202 );
203
204
205 //- Destructor
206 virtual ~polySurface();
207
208
209 // Factory Methods
210
211 //- Get or create (NO_READ, NO_WRITE) named surface on registry
212 static polySurface& New(const word& surfName, const objectRegistry&);
213
214 //- Remove named surface from specified registry
215 static bool Delete(const word& surfName, const objectRegistry&);
216
217
218 // Member Functions
219
220 // Resolve iterator ambiguity in favour of Patch (not registry)
221
222 using MeshReference::end;
226
227
228 // Access
229
230 //- Return the number of points
231 virtual label nPoints() const
232 {
233 return MeshReference::points().size();
234 }
235
236 //- Return the number of faces
237 virtual label nFaces() const
238 {
239 return MeshReference::size();
240 }
241
242 //- Return number of faces
243 virtual label size() const
244 {
245 return MeshReference::size();
246 }
247
248
249 //- Return points
250 virtual const pointField& points() const
251 {
252 return MeshReference::points();
253 }
254
255 //- Return faces
256 virtual const faceList& faces() const
257 {
258 return this->storedFaces();
259 }
260
261 //- Const access to per-face zone/region information (demand-driven)
262 virtual const labelList& zoneIds() const
263 {
264 return zoneIds_;
265 }
266
267 //- Return face area vectors (normals)
268 const vectorField& Sf() const
269 {
271 }
273 //- Return face area magnitudes
274 const scalarField& magSf() const
275 {
277 }
278
279 //- Face centres
280 const vectorField& Cf() const
281 {
283 }
284
285
286 // Modification
287
288 //- Update with new contents.
289 //- Removes existing fields if sizes have changed
290 void copySurface
291 (
292 const pointField& points,
293 const faceList& faces,
295 bool unused=false
296 );
298 //- Update with new contents.
299 //- Removes existing fields if sizes have changed
300 void copySurface
301 (
302 const meshedSurf& surf,
304 bool unused=false
305 );
306
307 //- Update with new contents.
308 //- Removes existing fields if sizes have changed
309 void copySurface
310 (
311 const MeshedSurface<face>& surf,
313 bool unused=false
314 );
315
316 //- Transfer the contents (and annul the parameters).
317 //- Removes existing fields.
318 void transfer
319 (
323 );
324
325 //- Transfer the contents (and annul the parameters).
326 //- Removes existing fields.
327 void transfer
328 (
331 bool validate=false
332 );
333
334
335 // Fields
336
337 //- Number of main entries, without PointData sub-registry
338 label nFaceData() const;
339
340 //- Number of entries on PointData sub-registry (if it exists)
341 label nPointData() const;
342
343 //- Query the field association (FACE or POINT)
344 FieldAssociation queryFieldAssociation(const word& fieldName) const;
345
346 //- Find the field object with the given name and required
347 //- FieldAssociation (FACE or POINT).
348 // For FACE_POINT_DATA, face data are checked first.
349 // \return nullptr is the field was not found
351 (
352 const word& fieldName,
353 const FieldAssociation association
354 ) const;
355
356 //- General finding of the field object (FACE or POINT)
357 // Later specializations are used to restrict the scope.
358 // \return nullptr is the field was not found
359 template<class GeoMeshType = void>
360 const regIOobject* findFieldObject(const word& fieldName) const;
361
362 //- General finding of the registry with the field object
363 //- (FACE or POINT).
364 // Later specializations are used to restrict the scope.
365 // \return nullptr is the field was not found
366 template<class GeoMeshType = void>
367 const objectRegistry* whichRegistry(const word& fieldName) const;
368
369 //- Regular data are stored directly on the registry
370 template<class DataType>
371 inline const objectRegistry& fieldData() const
372 {
373 return static_cast<const objectRegistry&>(*this);
374 }
375
376 //- Face data are stored directly on the registry
377 const objectRegistry& faceData() const;
378
379 //- Point data are stored in a sub-registry
380 // Note that this method will automatically create the corresponding
381 // sub-registry if it did not previously exist.
382 // Use the nPointData() methods instead if you wish to test for
383 // content without this side-effect.
384 const objectRegistry& pointData() const;
385
386
387 //- Create/store named zero field as face or point data
388 //- (template parameter).
389 //
390 // - Default is face-data (polySurfaceGeoMesh as template).
391 // - For point-data use polySurfacePointGeoMesh as template.
392 //
393 // \return reference to the field
394 template<class Type, class GeoMeshType = polySurfaceGeoMesh>
397 (
398 const word& fieldName,
399 const dimensionSet& dims
400 );
401
402 //- Copy/store named field as face or point data (template parameter).
403 //
404 // - Default is face-data (polySurfaceGeoMesh as template).
405 // - For point-data use polySurfacePointGeoMesh as template.
406 //
407 // \return reference to the field
408 template<class Type, class GeoMeshType = polySurfaceGeoMesh>
411 (
412 const word& fieldName,
413 const dimensionSet& dims,
414 const Field<Type>& values
415 );
416
417 //- Move/store named field as face or point data (template parameter).
418 //
419 // - Default is face-data (polySurfaceGeoMesh as template).
420 // - For point-data use polySurfacePointGeoMesh as template.
421 //
422 // \return reference to the field
423 template<class Type, class GeoMeshType = polySurfaceGeoMesh>
426 (
427 const word& fieldName,
428 const dimensionSet& dims,
429 Field<Type>&& values
430 );
431
432
433 // Writing
434
435 //- Write - this is a no-op
436 virtual bool writeObject
437 (
438 IOstreamOption streamOpt,
439 const bool writeOnProc
440 ) const;
441
442
443 // Storage Management
444
445 //- Clear geometry
446 void clearGeom();
447
448 //- Clear addressing
450
451 //- Clear all geometry and addressing unnecessary for CFD
452 void clearOut();
453
454 //- Clear primitive data (points, faces and cells)
456
457 //- Clear stored fields
458 void clearFields();
459};
460
461
462//- Find face field object (on main registry).
463template<>
465(
466 const word& fieldName
467) const;
468
469
470//- Find point field object (on sub-registry)
471template<>
473(
474 const word& fieldName
475) const;
476
477
478//- Return field object (on main registry).
479//- Face data field found on main registry?
480template<>
482(
483 const word& fieldName
484) const;
485
486
487//- Point data field found on sub-registry?
488template<>
490(
491 const word& fieldName
492) const;
493
494
495//- Point data are stored in a sub-registry
496template<>
497inline const objectRegistry&
499{
500 return pointData();
501}
502
503
504// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
506} // End namespace Foam
507
508// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
509
510#ifdef NoRepository
511 #include "polySurfaceTemplates.C"
512#endif
513
514// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
515
516#endif
517
518// ************************************************************************* //
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
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
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...
A list of faces which address into the list of points.
PrimitivePatch(const ::Foam::List< face > &faces, const pointField &points)
const Field< point_type > & points() const noexcept
const Field< point_type > & faceAreas() const
const Field< point_type > & faceCentres() const
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
iterator begin() noexcept
iterator end() noexcept
const_iterator cend() const noexcept
const_iterator cbegin() const noexcept
label size() const noexcept
Definition UList.H:706
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
The field association for mesh (patch/volume) values.
Abstract definition of a meshed surface defined by faces and points.
Definition meshedSurf.H:44
constexpr meshedSurf() noexcept=default
Default construct.
Registry of regIOobjects.
The polySurface GeoMesh for face fields.
The polySurface GeoMesh for point fields.
virtual label size() const
Return number of faces.
virtual const pointField & points() const
Return points.
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc) const
Write - this is a no-op.
const objectRegistry & faceData() const
Face data are stored directly on the registry.
void copySurface(const pointField &points, const faceList &faces, bool unused=false)
Update with new contents. Removes existing fields if sizes have changed.
static polySurface & New(const word &surfName, const objectRegistry &)
Get or create (NO_READ, NO_WRITE) named surface on registry.
const vectorField & Sf() const
Return face area vectors (normals).
pointField & storedPoints()
Non-const access to points.
label nFaceData() const
Number of main entries, without PointData sub-registry.
void clearGeom()
Clear geometry.
virtual ~polySurface()
Destructor.
faceList & storedFaces()
Non-const access to the faces.
const scalarField & magSf() const
Return face area magnitudes.
polySurface(const polySurface &)=delete
No copy construct.
void clearPrimitives()
Clear primitive data (points, faces and cells).
virtual label nFaces() const
Return the number of faces.
TypeName("polySurface")
Runtime type information.
const objectRegistry * whichRegistry(const word &fieldName) const
General finding of the registry with the field object (FACE or POINT).
const objectRegistry & pointData() const
Point data are stored in a sub-registry.
virtual const faceList & faces() const
Return faces.
virtual const labelList & zoneIds() const
Const access to per-face zone/region information (demand-driven).
label nPointData() const
Number of entries on PointData sub-registry (if it exists).
const vectorField & Cf() const
Face centres.
polySurface Mesh
Typedef required for GeoMesh.
static bool Delete(const word &surfName, const objectRegistry &)
Remove named surface from specified registry.
void clearAddressing()
Clear addressing.
DimensionedField< Type, GeoMeshType > & storeField(const word &fieldName, const dimensionSet &dims, const Field< Type > &values)
Copy/store named field as face or point data (template parameter).
FieldAssociation
Enumeration for the field association.
Definition polySurface.H:74
@ FACE_DATA
Data associated with faces.
Definition polySurface.H:76
@ POINT_DATA
Data associated with points.
Definition polySurface.H:77
@ FACE_OR_POINT_DATA
Data associated with faces or points.
Definition polySurface.H:78
@ NO_DATA
No associated data.
Definition polySurface.H:75
DimensionedField< Type, GeoMeshType > & storeField(const word &fieldName, const dimensionSet &dims, Field< Type > &&values)
Move/store named field as face or point data (template parameter).
void transfer(pointField &&points, faceList &&faces, labelList &&zoneIds=labelList())
Transfer the contents (and annul the parameters). Removes existing fields.
void clearFields()
Clear stored fields.
const objectRegistry & fieldData() const
Regular data are stored directly on the registry.
void operator=(const polySurface &)=delete
No copy assignment.
virtual label nPoints() const
Return the number of points.
FieldAssociation queryFieldAssociation(const word &fieldName) const
Query the field association (FACE or POINT).
const regIOobject * findFieldObject(const word &fieldName) const
General finding of the field object (FACE or POINT).
bool BoundaryMesh
Placeholder only, for GeoMesh.
void clearOut()
Clear all geometry and addressing unnecessary for CFD.
static const word pointDataName
Name for point fields sub-registry.
DimensionedField< Type, GeoMeshType > & newField(const word &fieldName, const dimensionSet &dims)
Create/store named zero field as face or point data (template parameter).
const faceList & storedFaces() const
Const access to the faces.
const regIOobject * findFieldObject(const word &fieldName, const FieldAssociation association) const
Find the field object with the given name and required FieldAssociation (FACE or POINT).
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition regIOobject.H:71
A surface zone on a MeshedSurface.
Definition surfZone.H:55
A class for handling words, derived from Foam::string.
Definition word.H:66
const auto & io
const pointField & points
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
List< face > faceList
List of faces.
Definition faceListFwd.H:41
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Field< vector > vectorField
Specialisation of Field<T> for vector.
vectorField pointField
pointField is a vectorField.
thermo validate(args.executable(), "h")
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68