Loading...
Searching...
No Matches
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-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::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
67template<class T> class InfoProxy;
68
69/*---------------------------------------------------------------------------*\
70 Class ensightFaces Declaration
71\*---------------------------------------------------------------------------*/
72
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.
84 {
85 TRIA3 = 0,
86 QUAD4,
87 NSIDED
88 };
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) noexcept;
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 totalSize() const noexcept;
166
167 //- Same as totalSize
168 label total() const noexcept { return totalSize(); }
169
170 //- The global size of the specified element type.
171 // This value is only meaningful after a reduce operation.
172 inline label total(const elemType etype) const;
173
174 //- The global sizes for each element type.
175 // This value is only meaningful after a reduce operation.
176 inline const FixedList<label, nTypes>& totals() const;
177
178 //- Processor-local sizes per element type.
180
181 //- Processor-local face ids of all elements
182 inline const labelList& faceIds() const noexcept;
183
184 //- Processor-local face ids of the specified element type
185 inline const labelUList faceIds(const elemType etype) const;
186
187 //- Processor-local flip-map of all elements
188 inline const boolList& flipMap() const;
189
190 //- True for non-zero flip-map that spans the addresses
191 inline bool usesFlipMap() const;
192
193 //- Processor-local face order
194 //- (where applicable)
195 inline const labelList& faceOrder() const noexcept;
196
197 //- Processor-local face order of specified element type
198 //- (where applicable)
199 inline const labelUList faceOrder(const elemType etype) const;
200
201
202 // Edit
204 //- Classify the face types and set the element lists.
205 void classify(const UList<face>& faces);
206
207 //- Classify face types (for a sublist) and set element lists.
208 void classify(const UList<face>& faces, const labelRange& range);
209
210 //- Classify the face types and set the element lists.
211 // The indirect addressing can be used when classifying groups of
212 // face (eg, from a faceZone etc) with an optional flipMap.
213 // The optional exclude marker can be used to skip faces on particular
214 // boundary types or regions.
215 void classify
216 (
217 const UList<face>& faces,
218 const labelUList& addr,
219 const boolList& flipMap = boolList(),
220 const bitSet& exclude = bitSet()
221 );
222
223
224 //- Clear any demand-driven data
225 void clearOut();
226
227 //- Set addressable sizes to zero, free up addressing memory.
228 void clear();
229
230 //- Sum element counts across all processes.
231 void reduce();
232
233 //- Inplace sort element lists numerically.
234 void sort();
235
236
237 // Advanced (use with caution)
238
239 //- Increase face ids by specified offset value
240 // Eg, to change patch local Ids to global Ids
241 void incrFaceIds(const label off);
242
243 //- Decrease face ids by specified offset value
244 // Eg, to change global Ids to patch local Ids
245 void decrFaceIds(const label off);
246
247
248 // Output
249
250 //- Return info proxy,
251 //- used to print information to a stream
252 InfoProxy<ensightFaces> info() const noexcept { return *this; }
253
254
255 //- Globally unique mesh points.
256 //- Required when writing point fields.
257 label uniqueMeshPoints
258 (
259 const polyMesh& mesh,
260 labelList& uniqueMeshPointLabels,
261 bool parallel
262 ) const;
263
264 //- Write information about the object as a dictionary,
265 //- optionally write all element addresses
266 virtual void writeDict(Ostream& os, const bool full=false) const;
267
268 //- Write geometry, using a mesh reference
269 //- No beginGeometry() marker.
270 virtual void write
271 (
273 const polyMesh& mesh,
274 bool parallel
275 ) const;
276};
277
278
279//- Print information via proxy
280template<>
281Ostream& operator<<(Ostream&, const InfoProxy<ensightFaces>&);
282
283
284// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
285
286} // End namespace Foam
287
288// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
289
290#include "ensightFacesI.H"
291
292#endif
293
294// ************************************************************************* //
scalar range
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
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
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition bitSet.H:61
FixedList< label, nTypes > sizes() const
Processor-local sizes per element type.
virtual ~ensightFaces()=default
Destructor.
bool usesFlipMap() const
True for non-zero flip-map that spans the addresses.
void decrFaceIds(const label off)
Decrease face ids by specified offset value.
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 'Face' type.
void classify(const UList< face > &faces)
Classify the face types and set the element lists.
const labelList & faceIds() const noexcept
Processor-local face ids of all elements.
const labelList & faceOrder() const noexcept
Processor-local face order (where applicable).
label totalSize() const noexcept
The global size of all element types.
label total() const noexcept
Same as totalSize.
TypeName("ensightFaces")
Declare type-name, virtual type (with debug switch).
void reduce()
Sum element counts across all processes.
void sort()
Inplace sort element lists numerically.
void incrFaceIds(const label off)
Increase face ids by specified offset value.
static constexpr int nTypes
Number of 'Face' element types (3).
virtual void writeDict(Ostream &os, const bool full=false) const
Write information about the object as a dictionary, optionally write all element addresses.
static const char * elemNames[nTypes]
The ensight 'Face' element type names.
elemType
Supported ensight 'Face' element types.
ensightFaces()
Default construct, with part index 0.
InfoProxy< ensightFaces > info() const noexcept
Return info proxy, used to print information to a stream.
label size() const noexcept
Processor-local size of all elements.
void clear()
Set addressable sizes to zero, free up addressing memory.
const boolList & flipMap() const
Processor-local flip-map of all elements.
void clearOut()
Clear any demand-driven data.
const FixedList< label, nTypes > & totals() const
The global sizes for each element type.
A variant of ensightFile (Ensight writing) that includes the extra geometry file header information.
label size() const noexcept
Processor-local size of all elements.
ensightPart()
Default construct. Index=0, identifier = -1.
Definition ensightPart.C:54
A face is a list of labels corresponding to mesh vertices.
Definition face.H:71
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
dynamicFvMesh & mesh
OBJstream os(runTime.globalPath()/outputName)
surface1 clear()
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).
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
void sort(UList< T > &list)
Sort the list.
Definition UList.C:283
List< bool > boolList
A List of bools.
Definition List.H:60
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