ensightFaces.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-2021 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::ensightFaces
28
29Description
30 Sorting/classification of faces (2D) into corresponding ensight types.
31
32 Some caution may be required when handling face addressing into a
33 boundaryField. Since the face addressing is absolute, it will be
34 necessary to work on a copy with local ids. For example,
35
36 \code
37 // Operate on a copy
38 ensightFaces localPart(part);
39
40 // Change from global faceIds to patch-local faceIds
41 localPart.decrFaceIds(patchStart);
42
43 // Can now address into boundaryField
44 \endcode
45
46 Additionally, for some uses (eg, finiteArea), the ordered
47 list of faces can be used for a direct local lookup into the field
48 instead of via the overall mesh face addressing.
49
50\*---------------------------------------------------------------------------*/
51
52#ifndef Foam_ensightFaces_H
53#define Foam_ensightFaces_H
54
55#include "ensightPart.H"
56#include "face.H"
57#include "FixedList.H"
58#include "bitSet.H"
59
60// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
61
62namespace Foam
63{
64
65// Forward Declarations
66class polyMesh;
67template<class T> class InfoProxy;
68
69/*---------------------------------------------------------------------------*\
70 Class ensightFaces Declaration
71\*---------------------------------------------------------------------------*/
73class ensightFaces
74:
75 public ensightPart
76{
77public:
78
79 // Public Data
80
81 //- Supported ensight 'Face' element types.
82 // Must be zero-based since they are also for internal bookkeeping.
83 enum elemType
84 {
85 TRIA3 = 0,
86 QUAD4,
88 };
89
90 //- Number of 'Face' element types (3)
91 static constexpr int nTypes = 3;
92
93 //- The ensight 'Face' element type names
94 static const char* elemNames[nTypes];
95
96
97 // Static Functions
98
99 //- The ensight element name for the specified 'Face' type
100 static inline const char* key(const elemType etype);
101
102
103private:
104
105 // Private Data
106
107 //- The input face order, for indirect face lists
108 labelList faceOrder_;
109
110 //- List of face-flips (optional)
111 boolList flipMap_;
112
113 //- Begin/end offsets for address/flips of each element type
115
116 //- List of global sizes for each element type.
117 // Used temporarily for local sizes when building the element lists.
119
120
121 // Private Member Functions
122
123 //- Low-level internal addition routine.
124 // \return insertion locaion
125 inline label add(const elemType etype, label id, bool flip=false);
126
127 //- Use temporarily stored sizes to redimension the element lists
128 void resizeAll();
129
130
131public:
132
133 //- Declare type-name, virtual type (with debug switch)
134 TypeName("ensightFaces");
135
136
137 // Constructors
138
139 //- Default construct, with part index 0
140 ensightFaces();
141
142 //- Default construct, with description/partName
143 explicit ensightFaces(const string& description);
144
145
146 //- Destructor
147 virtual ~ensightFaces() = default;
148
149
150 // Member Functions
151
152 // Access
153
154 //- Processor-local size of all elements.
155 using ensightPart::size;
156
157 //- Processor-local size of the specified element type.
158 inline label size(const elemType etype) const;
159
160 //- Processor-local offset/size of element type.
161 inline labelRange range(const elemType etype) const;
162
163 //- The global size of all element types.
164 // This value is only meaningful after a reduce operation.
165 label total() const;
166
167 //- The global size of the specified element type.
168 // This value is only meaningful after a reduce operation.
169 inline label total(const elemType etype) const;
170
171 //- The global sizes for each element type.
172 // This value is only meaningful after a reduce operation.
173 inline const FixedList<label, nTypes>& totals() const;
174
175 //- Processor-local sizes per element type.
177
178 //- Processor-local face ids of all elements
179 inline const labelList& faceIds() const noexcept;
180
181 //- Processor-local face ids of the specified element type
182 inline const labelUList faceIds(const elemType etype) const;
183
184 //- Processor-local flip-map of all elements
185 inline const boolList& flipMap() const;
186
187 //- True for non-zero flip-map that spans the addresses
188 inline bool usesFlipMap() const;
189
190 //- Processor-local face order
191 //- (where applicable)
192 inline const labelList& faceOrder() const noexcept;
193
194 //- Processor-local face order of specified element type
195 //- (where applicable)
196 inline const labelUList faceOrder(const elemType etype) const;
197
198
199 // Edit
200
201 //- Classify the face types and set the element lists.
202 void classify(const UList<face>& faces);
203
204 //- Classify face types (for a sublist) and set element lists.
205 void classify(const UList<face>& faces, const labelRange& range);
206
207 //- Classify the face types and set the element lists.
208 // The indirect addressing can be used when classifying groups of
209 // face (eg, from a faceZone etc) with an optional flipMap.
210 // The optional exclude marker can be used to skip faces on particular
211 // boundary types or regions.
212 void classify
213 (
214 const UList<face>& faces,
215 const labelUList& addr,
216 const boolList& flipMap = boolList(),
217 const bitSet& exclude = bitSet()
218 );
219
220
221 //- Clear any demand-driven data
222 void clearOut();
223
224 //- Set addressable sizes to zero, free up addressing memory.
225 void clear();
226
227 //- Sum element counts across all processes.
228 void reduce();
229
230 //- Inplace sort element lists numerically.
231 void sort();
232
233
234 // Advanced (use with caution)
235
236 //- Increase face ids by specified offset value
237 // Eg, to change patch local Ids to global Ids
238 void incrFaceIds(const label off);
239
240 //- Decrease face ids by specified offset value
241 // Eg, to change global Ids to patch local Ids
242 void decrFaceIds(const label off);
243
244
245 // Output
246
247 //- Return info proxy
248 InfoProxy<ensightFaces> info() const { return *this; }
249
250
251 //- Globally unique mesh points.
252 //- Required when writing point fields.
253 label uniqueMeshPoints
254 (
255 const polyMesh& mesh,
256 labelList& uniqueMeshPointLabels,
257 bool parallel
258 ) const;
259
260 //- Write information about the object as a dictionary,
261 //- optionally write all element addresses
262 virtual void writeDict(Ostream& os, const bool full=false) const;
263
264 //- Write geometry, using a mesh reference
265 virtual void write
266 (
268 const polyMesh& mesh,
269 bool parallel
270 ) const;
271};
272
273
274template<>
275Ostream& operator<<(Ostream&, const InfoProxy<ensightFaces>&);
276
277
278// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
279
280} // End namespace Foam
281
282// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
283
284#include "ensightFacesI.H"
285
286#endif
287
288// ************************************************************************* //
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
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 faces (2D) into corresponding ensight types.
Definition: ensightFaces.H:75
FixedList< label, nTypes > sizes() const
Processor-local sizes per element type.
Definition: ensightFaces.C:123
virtual ~ensightFaces()=default
Destructor.
bool usesFlipMap() const
True for non-zero flip-map that spans the addresses.
Definition: ensightFacesI.H:98
void decrFaceIds(const label off)
Decrease face ids by specified offset value.
label uniqueMeshPoints(const polyMesh &mesh, labelList &uniqueMeshPointLabels, bool parallel) const
void classify(const UList< face > &faces)
Classify the face types and set the element lists.
Definition: ensightFaces.C:219
const labelList & faceIds() const noexcept
Processor-local face ids of all elements.
Definition: ensightFacesI.H:79
const labelList & faceOrder() const noexcept
TypeName("ensightFaces")
Declare type-name, virtual type (with debug switch)
void reduce()
Sum element counts across all processes.
Definition: ensightFaces.C:164
void sort()
Inplace sort element lists numerically.
Definition: ensightFaces.C:175
static const char * key(const elemType etype)
The ensight element name for the specified 'Face' type.
Definition: ensightFacesI.H:49
void incrFaceIds(const label off)
Increase face ids by specified offset value.
static constexpr int nTypes
Number of 'Face' element types (3)
Definition: ensightFaces.H:90
virtual void writeDict(Ostream &os, const bool full=false) const
Definition: ensightFaces.C:325
static const char * elemNames[nTypes]
The ensight 'Face' element type names.
Definition: ensightFaces.H:93
elemType
Supported ensight 'Face' element types.
Definition: ensightFaces.H:83
ensightFaces()
Default construct, with part index 0.
Definition: ensightFaces.C:103
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: ensightFaces.C:136
void clear()
Set addressable sizes to zero, free up addressing memory.
Definition: ensightFaces.C:147
const boolList & flipMap() const
Processor-local flip-map of all elements.
Definition: ensightFacesI.H:92
void clearOut()
Clear any demand-driven data.
Definition: ensightFaces.C:160
InfoProxy< ensightFaces > info() const
Return info proxy.
Definition: ensightFaces.H:247
const FixedList< label, nTypes > & totals() const
The global sizes for each element type.
Definition: ensightFacesI.H:55
Specialized Ensight output with extra geometry file header.
Base class for ensightCells, ensightFaces, ensightOutputSurfaces.
Definition: ensightPart.H:54
label size() const noexcept
Processor-local size of all elements.
Definition: ensightPart.H:154
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
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