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