Loading...
Searching...
No Matches
surfMesh.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-2016 OpenFOAM Foundation
9 Copyright (C) 2016-2024 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::surfMesh
29
30Description
31 A surface mesh consisting of general polygon faces that has
32 IO capabilities and a registry for storing fields.
33
34Note
35 In many places the Foam::polySurface class may be more flexible.
36
37SourceFiles
38 surfMesh.C
39 surfMeshClear.C
40 surfMeshIO.C
41
42\*---------------------------------------------------------------------------*/
43
44#ifndef Foam_surfMesh_H
45#define Foam_surfMesh_H
46
47#include "surfaceRegistry.H"
49#include "primitivePatch.H"
50#include "surfZoneIOList.H"
51#include "surfFieldsFwd.H"
52
53// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54
55namespace Foam
56{
57
58// Forward Declarations
59class dimensionSet;
60class meshedSurf;
61template<class Face> class MeshedSurface;
63/*---------------------------------------------------------------------------*\
64 Class surfMesh Declaration
65\*---------------------------------------------------------------------------*/
66
67class surfMesh
68:
69 public surfaceRegistry,
71 public PrimitivePatch<::Foam::UList<face>, const pointField&>
72{
73public:
74
75 // Public Data Types
76
77 //- Enumeration defining the state of the mesh after a read update.
78 // Used for post-processing applications, where the mesh
79 // needs to update based on the files written in time directories
81 {
86 };
87
88
89private:
90
91 // Private Typedefs
92
93 //- Memory and IO management
94 typedef
96 Allocator;
97
98 //- Internal mesh storage type
99 typedef
101 MeshReference;
102
103
104 // Private Data
105
106 //- The surface zones
107 surfZoneIOList surfZones_;
108
109
110protected:
111
112 // Protected Member Functions
113
114 //- Non-const access to global points
116 {
118 }
119
120 //- Non-const access to the faces
122 {
124 }
125
126 //- Non-const access to the surface zones
128 {
129 return surfZones_;
130 }
131
132 //- Update point/face references
133 void updateRefs();
134
135
136public:
138 // Public Typedefs
139
140 //- Typedef required for GeoMesh
141 typedef surfMesh Mesh;
142
143 //- Placeholder only, but do not remove - it is needed for GeoMesh
144 typedef bool BoundaryMesh;
145
146
147 //- Declare type-name, virtual type (with debug switch)
148 TypeName("surfMesh");
149
150 //- Return the mesh sub-directory name (normally "surfMesh")
151 static word meshSubDir;
152
153
154 // Generated Methods
156 //- No copy construct
157 surfMesh(const surfMesh&) = delete;
158
159 //- No copy assignment
160 void operator=(const surfMesh&) = delete;
161
162
163 // Constructors
164
165 //- Read construct from IOobject.
166 // Writing = NO_WRITE
167 explicit surfMesh(const IOobject& io);
168
169 //- Read construct from IOobject, with alternative surface name
170 // Writing = NO_WRITE
171 surfMesh(const IOobject& io, const word& surfName);
172
173 //- Construct empty with specified name on the given registry.
174 surfMesh(const word& surfName, const objectRegistry& obr);
175
176 //- Copy construct from MeshedSurface<face>
178 (
179 const IOobject& io,
180 const MeshedSurface<face>& surf,
181 const word& surfName = word::null
182 );
183
184 //- Move construct from MeshedSurface<face>
186 (
187 const IOobject& io,
188 MeshedSurface<face>&& surf,
189 const word& surfName = word::null
190 );
191
192
193 //- Destructor
194 virtual ~surfMesh();
195
196
197 // Member Functions
198
199 // Database
200
201 //- Return the local mesh directory (dbDir()/meshSubDir)
202 fileName meshDir() const;
203
204 //- Return the current instance directory for points
205 // Used when constructing geometric mesh data dependent on points
206 const fileName& pointsInstance() const;
207
208 //- Return the current instance directory for faces
209 const fileName& facesInstance() const;
210
211 //- Set the instance for mesh files
212 void setInstance
213 (
214 const fileName& inst,
216 );
217
218 //- Adjust the write option for all components
220
221
222 // Access
223
224 //- Return the number of raw points
225 virtual label nPoints() const;
226
227 //- Return the number of raw faces
228 virtual label nFaces() const;
229
230 //- Return number of faces
231 virtual label size() const
232 {
233 return nFaces();
234 }
235
236
237 //- Return points
238 virtual const pointField& points() const;
239
240 //- Return faces
241 virtual const faceList& faces() const;
242
243 //- Return surface zones
244 virtual const surfZoneList& surfZones() const
245 {
246 return surfZones_;
247 }
248
249 //- Return face area vectors (normals)
250 const vectorField& Sf() const
251 {
253 }
254
255 //- Return face area magnitudes
256 const scalarField& magSf() const
257 {
259 }
260
261 //- Face centres
262 const vectorField& Cf() const
263 {
265 }
266
267
268 // Zones
269
270 //- Add surface zones, optionally validating the zone coverage
271 void addZones
272 (
273 const surfZoneList& zones,
274 bool validate = true
275 );
276
277 //- Remove surface zones
278 void removeZones();
279
280 //- Check the surface zone definitions
281 void checkZones(const bool verbose=true);
282
283
284 // Modification
285
286 //- Update with new contents
287 void copySurface
288 (
289 const pointField& points,
290 const faceList& faces,
291 bool validate=false
292 );
293
294 //- Update with new contents
295 void copySurface
296 (
297 const meshedSurf& surf,
298 bool validate=false
299 );
300
301 //- Update with new contents
302 void copySurface
303 (
304 const MeshedSurface<face>& surf,
305 bool validate=false
306 );
307
308 //- Transfer the contents of the argument and annul the argument
309 // Optionally validate the zone coverage.
310 void transfer
311 (
313 bool validate=false
314 );
315
316 //- Update mesh based on the files saved in time directories
317 virtual readUpdateState readUpdate();
318
319
320 // Fields
322 //- Create/store named zero field as face or point data
323 //- (template parameter).
324 //
325 // - Default is face-data (surfGeoMesh as template).
326 // - For point-data use surfPointGeoMesh as template.
327 //
328 // \return reference to the field
329 template<class Type, class GeoMeshType = surfGeoMesh>
332 (
333 const word& fieldName,
334 const dimensionSet& dims
335 );
336
337 //- Copy/store named field as face or point data (template parameter).
338 //
339 // - Default is face-data (surfGeoMesh as template).
340 // - For point-data use surfPointGeoMesh as template.
341 //
342 // \return reference to the field
343 template<class Type, class GeoMeshType = surfGeoMesh>
346 (
347 const word& fieldName,
348 const dimensionSet& dims,
349 const Field<Type>& values
350 );
351
352 //- Move/store named field as face or point data (template parameter).
353 //
354 // - Default is face-data (surfGeoMesh as template).
355 // - For point-data use surfPointGeoMesh as template.
356 //
357 // \return reference to the field
358 template<class Type, class GeoMeshType = surfGeoMesh>
361 (
362 const word& fieldName,
363 const dimensionSet& dims,
364 Field<Type>&& values
365 );
366
367
368 // Writing
369
370 //- Avoid masking the normal objectRegistry write
372
373 //- Write all components using given format, version and compression
374 virtual bool writeObject
375 (
376 IOstreamOption streamOpt,
377 const bool writeOnProc
378 ) const;
379
380
381 //- Write to file, choosing writer based on its extension.
382 // Uses MeshedSurfaceProxy for writing.
383 void write
384 (
385 const fileName& name,
386 IOstreamOption streamOpt = IOstreamOption(),
387 const dictionary& options = dictionary::null
388 ) const;
389
390 //- Write to file, choosing writer for given fileType.
391 // Uses MeshedSurfaceProxy for writing.
392 void write
393 (
394 const fileName& name,
395 const word& fileType,
396 IOstreamOption streamOpt = IOstreamOption(),
397 const dictionary& options = dictionary::null
398 ) const;
399
400
401 // Storage Management
402
403 //- Release the geometry and return as a MeshedSurface<face>.
405
406 //- Clear geometry
407 void clearGeom();
408
409 //- Clear addressing
410 void clearAddressing();
411
412 //- Clear all geometry and addressing unnecessary for CFD
413 void clearOut();
414
415 //- Clear primitive data (points, faces and cells)
416 void clearPrimitives();
417
418 //- Clear stored fields
419 void clearFields();
420
421 //- Remove all files from mesh instance
422 void removeFiles(const fileName& instanceDir) const;
423
424 //- Remove all files from mesh instance()
425 void removeFiles() const;
426};
427
428
429// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
430
431} // End namespace Foam
432
433// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
434
435#ifdef NoRepository
436 #include "surfMeshTemplates.C"
437#endif
438
439// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
440
441#endif
442
443// ************************************************************************* //
A helper class for storing points and faces with IO capabilities.
faceCompactIOList & storedIOFaces() noexcept
Non-const access to the faces.
pointIOField & storedIOPoints() noexcept
Non-const access to the points.
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
writeOption
Enumeration defining write preferences.
@ AUTO_WRITE
Automatically write from objectRegistry::writeObject().
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::UList< face > &faces, const const pointField &&points)
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
Definition dictionary.H:487
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
A class for handling file names.
Definition fileName.H:75
Abstract definition of a meshed surface defined by faces and points.
Definition meshedSurf.H:44
Registry of regIOobjects.
virtual bool write(const bool writeOnProc=true) const
Write using setting from DB.
virtual label size() const
Return number of faces.
Definition surfMesh.H:286
autoPtr< MeshedSurface< face > > releaseGeom()
Release the geometry and return as a MeshedSurface<face>.
Definition surfMesh.C:400
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc) const
Write all components using given format, version and compression.
Definition surfMeshIO.C:188
surfZoneList & storedZones()
Non-const access to the surface zones.
Definition surfMesh.H:137
const fileName & facesInstance() const
Return the current instance directory for faces.
Definition surfMesh.C:431
void copySurface(const pointField &points, const faceList &faces, bool validate=false)
Update with new contents.
Definition surfMesh.C:291
fileName meshDir() const
Return the local mesh directory (dbDir()/meshSubDir).
Definition surfMesh.C:419
const vectorField & Sf() const
Return face area vectors (normals).
Definition surfMesh.H:313
surfMesh Mesh
Typedef required for GeoMesh.
Definition surfMesh.H:155
pointField & storedPoints()
Non-const access to global points.
Definition surfMesh.H:121
virtual const faceList & faces() const
Return faces.
Definition surfMesh.C:455
void clearGeom()
Clear geometry.
faceList & storedFaces()
Non-const access to the faces.
Definition surfMesh.H:129
const scalarField & magSf() const
Return face area magnitudes.
Definition surfMesh.H:321
readUpdateState
Enumeration defining the state of the mesh after a read update.
Definition surfMesh.H:79
void clearPrimitives()
Clear primitive data (points, faces and cells).
virtual ~surfMesh()
Destructor.
Definition surfMesh.C:282
virtual readUpdateState readUpdate()
Update mesh based on the files saved in time directories.
Definition surfMeshIO.C:51
void operator=(const surfMesh &)=delete
No copy assignment.
void updateRefs()
Update point/face references.
Definition surfMesh.C:63
surfMesh(const surfMesh &)=delete
No copy construct.
const fileName & pointsInstance() const
Return the current instance directory for points.
Definition surfMesh.C:425
const vectorField & Cf() const
Face centres.
Definition surfMesh.H:329
TypeName("surfMesh")
Declare type-name, virtual type (with debug switch).
void checkZones(const bool verbose=true)
Check the surface zone definitions.
Definition surfMesh.C:461
void setInstance(const fileName &inst, IOobjectOption::writeOption wOpt=IOobjectOption::AUTO_WRITE)
Set the instance for mesh files.
Definition surfMeshIO.C:28
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).
DimensionedField< Type, GeoMeshType > & storeField(const word &fieldName, const dimensionSet &dims, Field< Type > &&values)
Move/store named field as face or point data (template parameter).
virtual const pointField & points() const
Return points.
Definition surfMesh.C:449
void clearFields()
Clear stored fields.
void removeFiles() const
Remove all files from mesh instance().
Definition surfMesh.C:553
virtual label nPoints() const
Return the number of raw points.
Definition surfMesh.C:437
virtual const surfZoneList & surfZones() const
Return surface zones.
Definition surfMesh.H:305
static word meshSubDir
Return the mesh sub-directory name (normally "surfMesh").
Definition surfMesh.H:171
bool BoundaryMesh
Placeholder only, but do not remove - it is needed for GeoMesh.
Definition surfMesh.H:160
void removeZones()
Remove surface zones.
void clearOut()
Clear all geometry and addressing unnecessary for CFD.
void transfer(MeshedSurface< face > &surf, bool validate=false)
Transfer the contents of the argument and annul the argument.
Definition surfMesh.C:379
void addZones(const surfZoneList &zones, bool validate=true)
Add surface zones, optionally validating the zone coverage.
Definition surfMesh.C:523
virtual label nFaces() const
Return the number of raw faces.
Definition surfMesh.C:443
DimensionedField< Type, GeoMeshType > & newField(const word &fieldName, const dimensionSet &dims)
Create/store named zero field as face or point data (template parameter).
void setWriteOption(IOobjectOption::writeOption wOpt)
Adjust the write option for all components.
Definition surfMeshIO.C:43
IOobject for a surfZoneList.
surfaceRegistry(const surfaceRegistry &)=delete
No copy construct.
A class for handling words, derived from Foam::string.
Definition word.H:66
static const word null
An empty word.
Definition word.H:84
const auto & io
const pointField & points
Namespace for OpenFOAM.
List< surfZone > surfZoneList
List of surfZone.
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.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
vectorField pointField
pointField is a vectorField.
runTime write()
thermo validate(args.executable(), "h")
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68