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-2022 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;
78
79/*---------------------------------------------------------------------------*\
80 Class ensightMesh Declaration
81\*---------------------------------------------------------------------------*/
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.
179 {
180 return faceZoneParts_;
181 }
182
183 //- Face elements per selected patch, lookup by patch index
184 // Process in sorted order.
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 }
207
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 void write
221 (
223 bool parallel = Pstream::parRun()
224 ) const;
225
226 //- Write geometry to file. Normally in parallel
227 inline void write
228 (
230 bool parallel = Pstream::parRun()
231 ) const;
232};
233
234
235/*---------------------------------------------------------------------------*\
236 Class ensightMesh::options Declaration
237\*---------------------------------------------------------------------------*/
238
239//- Configuration options for the ensightMesh
241{
242 // Private Data
243
244 //- Create in 'expired' mode
245 bool lazy_;
246
247 //- Use the internal mesh
248 bool internal_;
249
250 //- Use the boundary mesh
251 bool boundary_;
252
253 //- Handle cellZones (if internal_ is true)
254 bool cellZones_;
255
256 //- Selected patches only
257 wordRes patchInclude_;
258
259 //- Deselected patches
260 wordRes patchExclude_;
261
262 //- Selected cellZones
263 wordRes cellZoneInclude_;
264
265 //- Selected faceZones
266 wordRes faceZoneInclude_;
267
268
269public:
270
271 // Constructors
272
273 //- Default construct. Non-lazy with internal/boundary/cellZones.
274 options();
275
276
277 // Member Functions
278
279 // Access
280
281 //- Lazy creation? (ie, starts as needsUpdate)
282 bool lazy() const noexcept;
283
284 //- Using internal?
285 bool useInternalMesh() const noexcept;
286
287 //- Using boundary?
288 bool useBoundaryMesh() const noexcept;
289
290 //- Using faceZones?
291 bool useFaceZones() const noexcept;
292
293 //- Using cellZones?
294 bool useCellZones() const noexcept;
295
296 //- Selection of patches. Empty if unspecified.
297 const wordRes& patchSelection() const noexcept
298 {
299 return patchInclude_;
300 }
301
302 //- Selection of black listed patches. Empty if unspecified.
303 const wordRes& patchExclude() const noexcept
304 {
305 return patchExclude_;
306 }
307
308 //- Selection of faceZones. Empty if unspecified.
309 const wordRes& faceZoneSelection() const noexcept
310 {
311 return faceZoneInclude_;
312 }
313
314 //- Selection of faceZones. Empty if unspecified.
315 const wordRes& cellZoneSelection() const noexcept
316 {
317 return cellZoneInclude_;
318 }
319
320
321 // Edit
322
323 //- Reset to defaults
324 void reset();
325
326 //- Lazy creation - ensightMesh starts as needsUpdate
327 // \return old value
328 bool lazy(bool on) noexcept;
329
330 //- Alter the useBoundaryMesh state
331 // \return old value
332 bool useInternalMesh(bool on) noexcept;
333
334 //- Alter the useBoundaryMesh state
335 // \return old value
336 bool useBoundaryMesh(bool on);
337
338 //- Alter the useCellZones state
339 // \return old value
340 bool useCellZones(bool on);
341
342 //- Define patch selection matcher
343 void patchSelection(const UList<wordRe>& patterns);
344
345 //- Define patch selection matcher
346 void patchSelection(List<wordRe>&& patterns);
347
348 //- Define patch selection to exclude
349 void patchExclude(const UList<wordRe>& patterns);
350
351 //- Define patch selection to exclude
352 void patchExclude(List<wordRe>&& patterns);
353
354 //- Define faceZone selection matcher
355 void faceZoneSelection(const UList<wordRe>& patterns);
356
357 //- Define faceZone selection matcher
358 void faceZoneSelection(List<wordRe>&& patterns);
359
360 //- Define cellZone selection matcher
361 void cellZoneSelection(const UList<wordRe>& patterns);
362
363 //- Define cellZone selection matcher
364 void cellZoneSelection(List<wordRe>&& patterns);
365
366
367 // Output
368
369 //- Report values
370 void print(Ostream& os) const;
371};
372
373
374// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
375
376} // End namespace Foam
377
378// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
379
380#include "ensightMeshI.H"
381
382#endif
383
384// ************************************************************************* //
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
A HashTable to objects of type <T> with a label key.
Definition: Map.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
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
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:433
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
Specialized Ensight output with extra geometry file header.
Configuration options for the ensightMesh.
Definition: ensightMesh.H:240
bool useBoundaryMesh() const noexcept
Using boundary?
const wordRes & faceZoneSelection() const noexcept
Selection of faceZones. Empty if unspecified.
Definition: ensightMesh.H:308
bool useInternalMesh() const noexcept
Using internal?
bool useFaceZones() const noexcept
Using faceZones?
void print(Ostream &os) const
Report values.
const wordRes & patchSelection() const noexcept
Selection of patches. Empty if unspecified.
Definition: ensightMesh.H:296
bool lazy() const noexcept
Lazy creation? (ie, starts as needsUpdate)
const wordRes & patchExclude() const noexcept
Selection of black listed patches. Empty if unspecified.
Definition: ensightMesh.H:302
void reset()
Reset to defaults.
options()
Default construct. Non-lazy with internal/boundary/cellZones.
bool useCellZones() const noexcept
Using cellZones?
const wordRes & cellZoneSelection() const noexcept
Selection of faceZones. Empty if unspecified.
Definition: ensightMesh.H:314
Encapsulation of volume meshes for writing in ensight format. It manages cellZones,...
Definition: ensightMesh.H:83
const Map< ensightFaces > & boundaryParts() const noexcept
Face elements per selected patch, lookup by patch index.
Definition: ensightMesh.H:184
bool needsUpdate() const noexcept
Does the content need an update?
Definition: ensightMesh.H:202
void correct()
Update for new mesh.
Definition: ensightMesh.C:139
int verbose() const noexcept
Output verbosity level.
Definition: ensightMesh.C:125
bool empty() const noexcept
Any parts?
Definition: ensightMeshI.H:51
const ensightMesh::options & option() const
Reference to the writer/mesh options.
Definition: ensightMeshI.H:30
label size() const noexcept
Number of parts.
Definition: ensightMeshI.H:62
bool expire()
Mark as needing an update.
Definition: ensightMeshI.H:36
const Map< ensightCells > & cellZoneParts() const noexcept
Face elements per selected patch, lookup by patch index.
Definition: ensightMesh.H:170
static const label internalZone
The zone-id for internal mesh or unzoned cells.
Definition: ensightMesh.H:90
const polyMesh & mesh() const noexcept
Reference to the underlying polyMesh.
Definition: ensightMesh.H:159
const Map< ensightFaces > & faceZoneParts() const noexcept
Face elements per faceZone, lookup by zone index.
Definition: ensightMesh.H:177
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:54
patchWriters clear()
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
const direction noexcept
Definition: Scalar.H:223
runTime write()