Loading...
Searching...
No Matches
ensightMesh.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-2025 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::ensightMesh
29
30Description
31 Encapsulation of volume meshes for writing in ensight format.
32 It manages cellZones, facesZone, patches.
33
34 When cellZones are present (and not disabled), the cells are grouped
35 in parts according to the zone.
36 Any remaining \em unzoned cells are placed into the "internalMesh" part,
37 which is always part 0. If cellZones are missing or disabled,
38 all cells are placed into the "internalMesh" part.
39
40 If one or more cellZones are explicitly requested, all other cells
41 (including any unzoned cells) are ignored.
42
43 The converted patch faces are restricted by the volume mesh coverage.
44 Except when the entire internal mesh has been explicitly suppressed.
45
46Note
47 The internal data management uses a Map for cellZones, faceZones and
48 patches. The internalMesh is treated as cellZone with a special index.
49
50 Since the patches are subsetted by the internal mesh coverage,
51 they are treated as indirect patches rather than regular poly patches.
52
53SourceFiles
54 ensightMesh.C
55 ensightMeshI.H
56 ensightMeshOptions.C
57
58\*---------------------------------------------------------------------------*/
59
60#ifndef Foam_ensightMesh_H
61#define Foam_ensightMesh_H
62
63#include "Map.H"
64#include "ensightCells.H"
65#include "ensightFaces.H"
66#include "wordRes.H"
67#include <memory>
68
69// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70
71namespace Foam
72{
73
74// Forward Declarations
75class polyMesh;
76class ensightGeoFile;
77class ensightMesh;
79/*---------------------------------------------------------------------------*\
80 Class ensightMesh Declaration
81\*---------------------------------------------------------------------------*/
82
83class ensightMesh
84{
85public:
86
87 // Forward Declarations
88 class options;
89
90 //- The zone-id for internal mesh or unzoned cells.
91 static const label internalZone;
92
93
94private:
95
96 // Private Data
97
98 //- Writer options
99 const std::unique_ptr<options> options_;
100
101 //- Reference to the OpenFOAM mesh
102 const polyMesh& mesh_;
103
104 //- Volume elements per cellZone, lookup by zone index.
105 // The zone -1 is reserved for internal mesh (unzoned cells)
106 Map<ensightCells> cellZoneParts_;
107
108 //- Face elements per faceZone, lookup by zone index.
109 Map<ensightFaces> faceZoneParts_;
110
111 //- Face elements per selected patch, lookup by patch index
112 Map<ensightFaces> boundaryParts_;
113
114 //- Track if it needs an update
115 mutable bool needsUpdate_;
116
117 //- Output verbosity level
118 int verbose_;
119
120
121 // Private Member Functions
122
123 //- Clear all storage
124 void clear();
125
126 //- Enforce consistent index/part numbering
127 void renumber();
128
129 //- No copy construct
130 ensightMesh(const ensightMesh&) = delete;
131
132 //- No copy assignment
133 void operator=(const ensightMesh&) = delete;
134
135
136public:
137
138 // Constructors
139
140 //- Construct from mesh with all default options
141 explicit ensightMesh(const polyMesh& mesh);
142
143 //- Construct from components
144 ensightMesh(const polyMesh& mesh, const options& opts);
145
146
147 // Member Functions
148
149 //- Output verbosity level
150 int verbose() const noexcept;
151
152 //- Change the output verbosity level.
153 // \return old level
154 int verbose(const int level) noexcept;
155
156
157 // Access
158
159 //- Reference to the underlying polyMesh
160 const polyMesh& mesh() const noexcept
161 {
162 return mesh_;
163 }
164
165 //- Reference to the writer/mesh options
166 inline const ensightMesh::options& option() const;
167
168 //- Face elements per selected patch, lookup by patch index
169 // Process in sorted order.
170 // May require special treatment for zone -1 (internal).
172 {
173 return cellZoneParts_;
174 }
175
176 //- Face elements per faceZone, lookup by zone index.
177 // Process in sorted order.
178 const Map<ensightFaces>& faceZoneParts() const noexcept
179 {
180 return faceZoneParts_;
181 }
182
183 //- Face elements per selected patch, lookup by patch index
184 // Process in sorted order.
185 const Map<ensightFaces>& boundaryParts() const noexcept
186 {
187 return boundaryParts_;
188 }
189
190
191 // Sizing Information
192
193 //- Any parts?
194 inline bool empty() const noexcept;
195
196 //- Number of parts
197 inline label size() const noexcept;
198
199
200 // Other
201
202 //- Does the content need an update?
203 bool needsUpdate() const noexcept
204 {
205 return needsUpdate_;
206 }
208 //- Mark as needing an update.
209 // May also free up unneeded data.
210 // Return false if already marked as expired.
211 inline bool expire();
212
213 //- Update for new mesh
214 void correct();
215
216
217 // Output
218
219 //- Write geometry to file (normally in parallel).
220 //- Adds beginGeometry() marker.
221 // If all geometry is disabled, it will simply writes the mesh
222 // bounding box (to ensure that the geometry file is non-empty)
223 void write
224 (
226 bool parallel = UPstream::parRun()
227 ) const;
228
229 //- Write geometry to file (normally in parallel).
230 //- Adds beginGeometry() marker.
231 FOAM_DEPRECATED_FOR(2024-05, "write(ensightGeoFile&, ...")
232 inline void write
233 (
235 bool parallel = UPstream::parRun()
236 ) const;
237};
238
239
240/*---------------------------------------------------------------------------*\
241 Class ensightMesh::options Declaration
242\*---------------------------------------------------------------------------*/
243
244//- Configuration options for the ensightMesh
245class ensightMesh::options
246{
247 // Private Data
248
249 //- Create in 'expired' mode
250 bool lazy_;
252 //- Use the internal mesh
253 bool internal_;
254
255 //- Use the boundary mesh
256 bool boundary_;
257
258 //- Handle cellZones (if internal_ is true)
259 bool cellZones_;
260
261 //- Selected patches only
262 wordRes patchInclude_;
263
264 //- Deselected patches
265 wordRes patchExclude_;
266
267 //- Selected cellZones
268 wordRes cellZoneInclude_;
269
270 //- Selected faceZones
271 wordRes faceZoneInclude_;
272
273
274public:
275
276 // Constructors
277
278 //- Default construct. Non-lazy with internal/boundary/cellZones.
279 options();
280
281
282 // Member Functions
283
284 // Access
285
286 //- Lazy creation? (ie, starts as needsUpdate)
287 bool lazy() const noexcept;
288
289 //- Using internal?
290 bool useInternalMesh() const noexcept;
291
292 //- Using boundary?
293 bool useBoundaryMesh() const noexcept;
294
295 //- Using cellZones?
296 bool useCellZones() const noexcept;
297
298 //- Using faceZones?
299 bool useFaceZones() const noexcept;
300
301 //- Selection of patches. Empty if unspecified.
302 const wordRes& patchSelection() const noexcept
303 {
304 return patchInclude_;
306
307 //- Excluded patches. Empty if unspecified.
308 const wordRes& patchExclude() const noexcept
309 {
310 return patchExclude_;
311 }
312
313 //- Selection of cell zones. Empty if unspecified.
314 const wordRes& cellZoneSelection() const noexcept
315 {
316 return cellZoneInclude_;
317 }
318
319 //- Excluded cell zones. Future use
320 const wordRes& cellZoneExclude() const noexcept
321 {
322 return wordRes::null();
323 }
324
325 //- Selection of face zones. Empty if unspecified.
326 const wordRes& faceZoneSelection() const noexcept
327 {
328 return faceZoneInclude_;
329 }
330
331 //- Excluded face zones. Future use
332 const wordRes& faceZoneExclude() const noexcept
333 {
334 return wordRes::null();
335 }
336
337
338 // Edit
339
340 //- Reset to defaults
341 void reset();
342
343 //- Lazy creation - ensightMesh starts as needsUpdate
344 // \return old value
345 bool lazy(bool on) noexcept;
346
347 //- Alter the useBoundaryMesh state
348 // \return old value
349 bool useInternalMesh(bool on) noexcept;
350
351 //- Alter the useBoundaryMesh state
352 // \return old value
353 bool useBoundaryMesh(bool on);
354
355 //- Alter the useCellZones state
356 // \return old value
357 bool useCellZones(bool on);
358
359 //- Define patch selection matcher
360 void patchSelection(const UList<wordRe>& patterns);
361
362 //- Define patch selection matcher
363 void patchSelection(List<wordRe>&& patterns);
364
365 //- Define patch selection to exclude
366 void patchExclude(const UList<wordRe>& patterns);
367
368 //- Define patch selection to exclude
369 void patchExclude(List<wordRe>&& patterns);
370
371 //- Define cellZone selection matcher
372 void cellZoneSelection(const UList<wordRe>& patterns);
373
374 //- Define cellZone selection matcher
375 void cellZoneSelection(List<wordRe>&& patterns);
376
377 //- Define faceZone selection matcher
378 void faceZoneSelection(const UList<wordRe>& patterns);
379
380 //- Define faceZone selection matcher
381 void faceZoneSelection(List<wordRe>&& patterns);
382
383
384 // Output
385
386 //- Report values
387 void print(Ostream& os) const;
388};
389
390
391// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
393} // End namespace Foam
394
395// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
396
397#include "ensightMeshI.H"
398
399#endif
401// ************************************************************************* //
writer write("magLe", fld)
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
A HashTable to objects of type <T> with a label key.
Definition Map.H:54
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
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
Inter-processor communications stream.
Definition UPstream.H:69
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
Definition UPstream.H:1669
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A variant of ensightFile (Ensight writing) that includes the extra geometry file header information.
Configuration options for the ensightMesh.
const wordRes & cellZoneExclude() const noexcept
Excluded cell zones. Future use.
bool useBoundaryMesh() const noexcept
Using boundary?
const wordRes & faceZoneSelection() const noexcept
Selection of face zones. Empty if unspecified.
bool useInternalMesh() const noexcept
Using internal?
bool useFaceZones() const noexcept
Using faceZones?
const wordRes & faceZoneExclude() const noexcept
Excluded face zones. Future use.
const wordRes & patchSelection() const noexcept
Selection of patches. Empty if unspecified.
bool lazy() const noexcept
Lazy creation? (ie, starts as needsUpdate).
const wordRes & patchExclude() const noexcept
Excluded patches. Empty if unspecified.
options()
Default construct. Non-lazy with internal/boundary/cellZones.
bool useCellZones() const noexcept
Using cellZones?
const wordRes & cellZoneSelection() const noexcept
Selection of cell zones. Empty if unspecified.
Encapsulation of volume meshes for writing in ensight format. It manages cellZones,...
Definition ensightMesh.H:79
const Map< ensightFaces > & boundaryParts() const noexcept
Face elements per selected patch, lookup by patch index.
bool needsUpdate() const noexcept
Does the content need an update?
void write(ensightGeoFile &os, bool parallel=UPstream::parRun()) const
Write geometry to file (normally in parallel). Adds beginGeometry() marker.
void correct()
Update for new mesh.
int verbose() const noexcept
Output verbosity level.
Definition ensightMesh.C:96
bool empty() const noexcept
Any parts?
const ensightMesh::options & option() const
Reference to the writer/mesh options.
label size() const noexcept
Number of parts.
bool expire()
Mark as needing an update.
const Map< ensightCells > & cellZoneParts() const noexcept
Face elements per selected patch, lookup by patch index.
static const label internalZone
The zone-id for internal mesh or unzoned cells.
Definition ensightMesh.H:88
const polyMesh & mesh() const noexcept
Reference to the underlying polyMesh.
const Map< ensightFaces > & faceZoneParts() const noexcept
Face elements per faceZone, lookup by zone index.
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
A List of wordRe with additional matching capabilities.
Definition wordRes.H:56
static const wordRes & null() noexcept
Return a null wordRes (reference to a nullObject). Behaves like a empty wordRes.
Definition wordRes.H:80
limits reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL))
OBJstream os(runTime.globalPath()/outputName)
surface1 clear()
Ostream & print(Ostream &os, UIntType value, char off='0', char on='1')
Print 0/1 bits in the (unsigned) integral type.
Definition BitOps.H:320
Namespace for OpenFOAM.
const direction noexcept
Definition scalarImpl.H:265
runTime write()
#define FOAM_DEPRECATED_FOR(since, replacement)
Definition stdFoam.H:43