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-2020 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
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 
26 Class
27  Foam::ensightFaces
28 
29 Description
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 \*---------------------------------------------------------------------------*/
47 
48 #ifndef ensightFaces_H
49 #define ensightFaces_H
50 
51 #include "ensightPart.H"
52 #include "boolList.H"
53 #include "faceList.H"
54 #include "FixedList.H"
55 #include "bitSet.H"
56 
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 
59 namespace Foam
60 {
61 
62 // Forward Declarations
63 class polyMesh;
64 
65 /*---------------------------------------------------------------------------*\
66  Class ensightFaces Declaration
67 \*---------------------------------------------------------------------------*/
68 
69 class ensightFaces
70 :
71  public ensightPart
72 {
73 public:
74 
75  // Public Data
76 
77  //- Supported ensight 'Face' element types.
78  // Must be zero-based since they are also for internal bookkeeping.
79  enum elemType
80  {
81  TRIA3 = 0,
83  NSIDED
84  };
85 
86  //- Number of 'Face' element types (3)
87  static constexpr int nTypes = 3;
88 
89  //- The ensight 'Face' element type names
90  static const char* elemNames[nTypes];
91 
92 
93  // Static Functions
94 
95  //- The ensight element name for the specified 'Face' type
96  static inline const char* key(const elemType etype);
97 
98 
99 private:
100 
101  // Private Data
102 
103  //- Linear list of face-flips
104  boolList flipMap_;
105 
106  //- Begin/end offsets for address/flips of each element type
108 
109  //- List of global sizes for each element type.
110  // Used temporarily for local sizes when building the element lists.
112 
113 
114  // Private Member Functions
115 
116  //- Low-level internal addition routine
117  inline void add(const elemType etype, label id, bool flip=false);
118 
119  //- Use temporarily stored sizes to redimension the element lists
120  void resizeAll();
121 
122 
123 public:
124 
125  //- Declare type-name, virtual type (with debug switch)
126  TypeName("ensightFaces");
127 
128 
129  // Constructors
130 
131  //- Default construct, with part index 0
132  ensightFaces();
133 
134  //- Default construct, with description/partName
135  explicit ensightFaces(const string& description);
136 
137 
138  //- Destructor
139  virtual ~ensightFaces() = default;
140 
141 
142  // Member Functions
143 
144  // Access
145 
146  //- Processor-local size of all elements.
147  using ensightPart::size;
148 
149  //- Processor-local size of the specified element type.
150  inline label size(const elemType etype) const;
151 
152  //- Processor-local offset/size of element type.
153  inline labelRange range(const elemType etype) const;
154 
155  //- The global size of all element types.
156  // This value is only meaningful after a reduce operation.
157  label total() const;
158 
159  //- The global size of the specified element type.
160  // This value is only meaningful after a reduce operation.
161  inline label total(const elemType etype) const;
162 
163  //- The global sizes for each element type.
164  // This value is only meaningful after a reduce operation.
165  inline const FixedList<label, nTypes>& totals() const;
166 
167  //- Processor-local sizes per element type.
169 
170  //- Processor-local face ids of all elements
171  inline const labelList& faceIds() const;
172 
173  //- Processor-local face ids of the specified element type
174  inline const labelUList faceIds(const elemType etype) const;
175 
176  //- Processor-local flip-map of all elements
177  inline const boolList& flipMap() const;
178 
179  //- True for non-zero flip-map that spans the addresses
180  inline bool usesFlipMap() const;
181 
182 
183  // Edit
184 
185  //- Classify the face types and set the element lists.
186  void classify(const UList<face>& faces);
187 
188  //- Classify face types (for a sublist) and set element lists.
189  void classify(const UList<face>& faces, const labelRange& range);
190 
191  //- Classify the face types and set the element lists.
192  // The indirect addressing can be used when classifying groups of
193  // face (eg, from a faceZone etc) with an optional flipMap.
194  // The optional exclude marker can be used to skip faces on particular
195  // boundary types or regions.
196  void classify
197  (
198  const UList<face>& faces,
199  const labelUList& addr,
200  const boolList& flipMap = boolList(),
201  const bitSet& exclude = bitSet()
202  );
203 
204 
205  //- Clear any demand-driven data
206  void clearOut();
207 
208  //- Set addressable sizes to zero, free up addressing memory.
209  void clear();
210 
211  //- Sum element counts across all processes.
212  void reduce();
213 
214  //- Sort element lists numerically.
215  void sort();
216 
217 
218  // Advanced (use with caution)
219 
220  //- Increase face ids by specified offset value
221  // Eg, to change patch local Ids to global Ids
222  void incrFaceIds(const label off);
223 
224  //- Decrease face ids by specified offset value
225  // Eg, to change global Ids to patch local Ids
226  void decrFaceIds(const label off);
227 
228 
229  // Output
230 
231  //- Globally unique mesh points.
232  //- Required when writing point fields.
233  label uniqueMeshPoints
234  (
235  const polyMesh& mesh,
236  labelList& uniqueMeshPointLabels,
237  bool parallel
238  ) const;
239 
240  //- Write information about the object as a dictionary,
241  //- optionally write all element addresses
242  virtual void writeDict(Ostream& os, const bool full=false) const;
243 
244  //- Write geometry, using a mesh reference
245  virtual void write
246  (
247  ensightGeoFile& os,
248  const polyMesh& mesh,
249  bool parallel
250  ) const;
251 };
252 
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 } // End namespace Foam
257 
258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259 
260 #include "ensightFacesI.H"
261 
262 #endif
263 
264 // ************************************************************************* //
Foam::ensightFaces::flipMap
const boolList & flipMap() const
Processor-local flip-map of all elements.
Definition: ensightFacesI.H:89
Foam::ensightFaces::decrFaceIds
void decrFaceIds(const label off)
Decrease face ids by specified offset value.
Definition: ensightFacesI.H:107
Foam::ensightFaces::nTypes
static constexpr int nTypes
Number of 'Face' element types (3)
Definition: ensightFaces.H:86
boolList.H
Foam::ensightPart::size
label size() const
Processor-local size of all elements.
Definition: ensightPart.H:154
Foam::bitSet
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:64
Foam::ensightFaces::NSIDED
"nsided"
Definition: ensightFaces.H:82
Foam::ensightFaces::key
static const char * key(const elemType etype)
The ensight element name for the specified 'Face' type.
Definition: ensightFacesI.H:46
Foam::ensightFaces::TypeName
TypeName("ensightFaces")
Declare type-name, virtual type (with debug switch)
Foam::ensightFaces::usesFlipMap
bool usesFlipMap() const
True for non-zero flip-map that spans the addresses.
Definition: ensightFacesI.H:95
Foam::boolList
List< bool > boolList
A List of bools.
Definition: List.H:69
Foam::ensightFaces::clearOut
void clearOut()
Clear any demand-driven data.
Definition: ensightFaces.C:153
faceList.H
bitSet.H
Foam::ensightFaces
Sorting/classification of faces (2D) into corresponding ensight types.
Definition: ensightFaces.H:68
Foam::ensightFaces::writeDict
virtual void writeDict(Ostream &os, const bool full=false) const
Definition: ensightFaces.C:313
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::ensightFaces::range
labelRange range(const elemType etype) const
Processor-local offset/size of element type.
Definition: ensightFacesI.H:70
Foam::ensightFaces::write
virtual void write(ensightGeoFile &os, const polyMesh &mesh, bool parallel) const
Write geometry, using a mesh reference.
Definition: ensightFacesIO.C:39
Foam::ensightFaces::total
label total() const
The global size of all element types.
Definition: ensightFaces.C:130
Foam::ensightGeoFile
Specialized Ensight output with extra geometry file header.
Definition: ensightGeoFile.H:48
Foam::ensightFaces::TRIA3
"tria3"
Definition: ensightFaces.H:80
Foam::ensightFaces::~ensightFaces
virtual ~ensightFaces()=default
Destructor.
Foam::ensightFaces::reduce
void reduce()
Sum element counts across all processes.
Definition: ensightFaces.C:157
Foam::ensightFaces::sizes
FixedList< label, nTypes > sizes() const
Processor-local sizes per element type.
Definition: ensightFaces.C:117
Foam::labelRange
A range or interval of labels defined by a start and a size.
Definition: labelRange.H:58
Foam::ensightFaces::faceIds
const labelList & faceIds() const
Processor-local face ids of all elements.
Definition: ensightFacesI.H:76
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::ensightFaces::ensightFaces
ensightFaces()
Default construct, with part index 0.
Definition: ensightFaces.C:98
ensightFacesI.H
Foam::ensightFaces::uniqueMeshPoints
label uniqueMeshPoints(const polyMesh &mesh, labelList &uniqueMeshPointLabels, bool parallel) const
Definition: ensightFacesAddr.C:39
Foam::ensightFaces::totals
const FixedList< label, nTypes > & totals() const
The global sizes for each element type.
Definition: ensightFacesI.H:52
Foam::ensightFaces::incrFaceIds
void incrFaceIds(const label off)
Increase face ids by specified offset value.
Definition: ensightFacesI.H:101
Foam::ensightFaces::QUAD4
"quad4"
Definition: ensightFaces.H:81
Foam::ensightFaces::elemType
elemType
Supported ensight 'Face' element types.
Definition: ensightFaces.H:78
Foam::List< bool >
Foam::ensightPart
Base class for ensightCells, ensightFaces, ensightOutputSurfaces.
Definition: ensightPart.H:53
Foam::ensightFaces::clear
void clear()
Set addressable sizes to zero, free up addressing memory.
Definition: ensightFaces.C:141
Foam::FixedList< label, nTypes+1 >
Foam::UList< label >
Foam::ensightFaces::sort
void sort()
Sort element lists numerically.
Definition: ensightFaces.C:168
Foam::ensightFaces::elemNames
static const char * elemNames[nTypes]
The ensight 'Face' element type names.
Definition: ensightFaces.H:89
ensightPart.H
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
FixedList.H
Foam::ensightFaces::classify
void classify(const UList< face > &faces)
Classify the face types and set the element lists.
Definition: ensightFaces.C:212