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