Loading...
Searching...
No Matches
ensightCells.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) 2016-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::ensightCells
28
29Description
30 Sorting/classification of cells (3D) into corresponding ensight element
31 types.
32
33\*---------------------------------------------------------------------------*/
34
35#ifndef Foam_ensightCells_H
36#define Foam_ensightCells_H
37
38#include "ensightPart.H"
39#include "FixedList.H"
40#include "Map.H"
41
42// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43
44namespace Foam
45{
46
47// Forward Declarations
48class bitSet;
49class boundBox;
51template<class T> class InfoProxy;
52
53/*---------------------------------------------------------------------------*\
54 Class ensightCells Declaration
55\*---------------------------------------------------------------------------*/
56
57class ensightCells
58:
59 public ensightPart
60{
61public:
62
63 // Public Data
64
65 //- Supported ensight 'Cell' element types
66 // Must be zero-based since they are also for internal bookkeeping.
68 {
69 TETRA4 = 0,
70 PYRAMID5,
71 PENTA6,
72 HEXA8,
73 NFACED
74 };
76 //- Number of 'Cell' element types (5)
77 static constexpr int nTypes = 5;
78
79 //- The ensight 'Cell' element type names
80 static const char* elemNames[nTypes];
81
82
83 // Static Functions
84
85 //- The ensight element name for the specified 'Cell' type
86 inline static const char* key(const elemType etype) noexcept;
87
88
89private:
90
91 // Private Data
92
93 //- Manifold cells detected
94 bool manifold_;
95
96 //- Begin/end offsets for address of each element type
98
99 //- List of global sizes for each element type.
100 // Used temporarily for local sizes when building the element lists.
102
103
104 // Private Member Functions
105
106 //- Low-level internal addition routine
107 // \return insertion locaion
108 inline label add(const elemType etype, label id);
109
110 //- Use temporarily stored sizes to redimension the element lists
111 void resizeAll();
112
113 //- Classify cell types, set element lists for selection
114 // (implementation)
115 template<class Addressing>
116 void classifyImpl(const polyMesh& mesh, const Addressing& cellIds);
117
118
119 label meshPointMappings
120 (
121 const polyMesh& mesh,
122 labelList& pointToGlobal, // Can also be labelList::null()
123 labelList& uniqueMeshPointLabels,
124 bool parallel
125 ) const;
126
127
128 //- Write cell connectivity for polyhedral cells
129 static void writePolysConnectivity
130 (
132 const polyMesh& mesh,
133 const ensightCells& part,
134 const labelList& pointToGlobal,
135 bool parallel
136 );
137
138 //- Write cell connectivity for specified (non-poly) type
139 static void writeShapeConnectivity
140 (
142 const polyMesh& mesh,
143 const ensightCells::elemType etype,
144 const ensightCells& part,
145 const labelList& pointToGlobal,
146 bool parallel
147 );
148
149
150public:
151
152 //- Declare type-name, virtual type (with debug switch)
153 TypeName("ensightCells");
154
155
156 // Constructors
157
158 //- Default construct, with part index 0
159 ensightCells();
160
161 //- Default construct, with description/partName
162 explicit ensightCells(const string& description);
163
164
165 //- Destructor
166 virtual ~ensightCells() = default;
167
168
169 // Member Functions
170
171 // Access
172
173 //- Manifold mesh cells detected? Globally consistent quantity.
174 inline bool manifold() const noexcept;
175
176 //- Processor-local size of all elements.
177 using ensightPart::size;
178
179 //- Processor-local size of the specified element type.
180 inline label size(const elemType etype) const;
181
182 //- Processor-local offset/size of element type.
183 inline labelRange range(const elemType etype) const;
184
185 //- The global size of all element types.
186 // This value is only meaningful after a reduce operation.
187 label totalSize() const noexcept;
188
189 //- Same as totalSize()
190 label total() const noexcept { return totalSize(); }
191
192 //- The global size of the specified element type.
193 // This value is only meaningful after a reduce operation.
194 inline label total(const elemType etype) const;
196 //- The global sizes for each element type.
197 // This value is only meaningful after a reduce operation.
198 inline const FixedList<label, nTypes>& totals() const;
199
200 //- Processor-local sizes per element type.
202
203 //- Processor-local cell ids of all elements
204 inline const labelList& cellIds() const;
205
206 //- Processor-local cell ids of the specified element type
207 inline const labelUList cellIds(const elemType etype) const;
208
209
210 // Addressing
211
212 //- Mesh point map.
213 // Map mesh point index to local (compact) point index
214 Map<label> meshPointMap(const polyMesh& mesh) const;
215
216
217 // Edit
218
219 //- Classify cell types and set the element lists.
220 void classify(const polyMesh& mesh);
221
222 //- Classify cell types and set element lists,
223 //- using a subgroup of cells (eg, from a cellZone etc).
224 void classify(const polyMesh& mesh, const labelUList& cellIds);
225
226 //- Classify cell types and set element lists,
227 //- using a subgroup of cells
228 void classify(const polyMesh& mesh, const bitSet& selection);
229
230
231 //- Clear any demand-driven data
232 void clearOut();
233
234 //- Set addressable sizes to zero, free up addressing memory.
235 void clear();
236
237 //- Sum element counts across all processes.
238 void reduce();
239
240 //- Sort element lists numerically.
241 void sort();
242
243
244 // Advanced (use with caution)
245
246 //- Increase cell ids by specified offset value
247 // Eg, to change zone local Ids to global Ids
248 inline void incrCellIds(const label off);
249
250 //- Decrease face ids by specified offset value
251 // Eg, to change global Ids to zone local Ids
252 inline void decrCellIds(const label off);
253
254
255
256 // Output
257
258 //- Return info proxy,
259 //- used to print information to a stream
260 InfoProxy<ensightCells> info() const noexcept { return *this; }
261
262
263 //- Globally unique mesh points. Required when writing point fields.
264 label uniqueMeshPoints
265 (
266 const polyMesh& mesh,
267 labelList& uniqueMeshPointLabels,
268 bool parallel
269 ) const;
270
271
272 //- Write information about the object as a dictionary,
273 //- optionally write all element addresses
274 virtual void writeDict(Ostream& os, const bool full=false) const;
275
276 //- Write geometry, using a mesh reference (serial only)
277 //- No beginGeometry() marker.
278 virtual void write
279 (
281 const polyMesh& mesh,
282 bool parallel
283 ) const;
284
285 //- Write bounding box geometry.
286 //- All parameters are only relevant on master
287 //- No beginGeometry() marker.
288 static void writeBox
289 (
291 const boundBox& bb,
292 const label partIndex = 0,
293 const word& partName = "geometry-box"
294 );
295};
296
297
298//- Print information via proxy
299template<>
300Ostream& operator<<(Ostream&, const InfoProxy<ensightCells>&);
301
302
303// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
304
305} // End namespace Foam
306
307// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
308
309#include "ensightCellsI.H"
310
311#endif
312
313// ************************************************************************* //
A 1D vector of objects of type <T> with a fixed length <N>.
Definition FixedList.H:73
A helper class for outputting values to Ostream.
Definition InfoProxy.H:49
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 bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition bitSet.H:61
A bounding box defined in terms of min/max extrema points.
Definition boundBox.H:71
static void writeBox(ensightGeoFile &os, const boundBox &bb, const label partIndex=0, const word &partName="geometry-box")
Write bounding box geometry. All parameters are only relevant on master No beginGeometry() marker.
label uniqueMeshPoints(const polyMesh &mesh, labelList &uniqueMeshPointLabels, bool parallel) const
Globally unique mesh points. Required when writing point fields.
labelRange range(const elemType etype) const
Processor-local offset/size of element type.
static const char * key(const elemType etype) noexcept
The ensight element name for the specified 'Cell' type.
Map< label > meshPointMap(const polyMesh &mesh) const
Mesh point map.
label totalSize() const noexcept
The global size of all element types.
label total() const noexcept
Same as totalSize().
virtual ~ensightCells()=default
Destructor.
void reduce()
Sum element counts across all processes.
bool manifold() const noexcept
Manifold mesh cells detected? Globally consistent quantity.
void sort()
Sort element lists numerically.
void classify(const polyMesh &mesh)
Classify cell types and set the element lists.
static constexpr int nTypes
Number of 'Cell' element types (5).
TypeName("ensightCells")
Declare type-name, virtual type (with debug switch).
virtual void writeDict(Ostream &os, const bool full=false) const
Write information about the object as a dictionary, optionally write all element addresses.
void incrCellIds(const label off)
Increase cell ids by specified offset value.
label size(const elemType etype) const
Processor-local size of the specified element type.
ensightCells()
Default construct, with part index 0.
static const char * elemNames[nTypes]
The ensight 'Cell' element type names.
elemType
Supported ensight 'Cell' element types.
@ PYRAMID5
"pyramid5"
InfoProxy< ensightCells > info() const noexcept
Return info proxy, used to print information to a stream.
void clear()
Set addressable sizes to zero, free up addressing memory.
void decrCellIds(const label off)
Decrease face ids by specified offset value.
const FixedList< label, nTypes > & totals() const
The global sizes for each element type.
FixedList< label, nTypes > sizes() const
Processor-local sizes per element type.
const labelList & cellIds() const
Processor-local cell ids of all elements.
void clearOut()
Clear any demand-driven data.
A variant of ensightFile (Ensight writing) that includes the extra geometry file header information.
ensightPart()
Default construct. Index=0, identifier = -1.
Definition ensightPart.C:54
A range or interval of labels defined by a start and a size.
Definition labelRange.H:66
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
A class for handling words, derived from Foam::string.
Definition word.H:66
dynamicFvMesh & mesh
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
const direction noexcept
Definition scalarImpl.H:265
UList< label > labelUList
A UList of labels.
Definition UList.H:75
runTime write()
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68