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-2019 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::ensightCells
28 
29 Description
30  Sorting/classification of cells (3D) into corresponding ensight element
31  types.
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef ensightCells_H
36 #define ensightCells_H
37 
38 #include "labelList.H"
39 #include "FixedList.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 // Forward declarations
47 class bitSet;
48 class polyMesh;
49 
50 /*---------------------------------------------------------------------------*\
51  Class ensightCells Declaration
52 \*---------------------------------------------------------------------------*/
53 
54 class ensightCells
55 {
56 public:
57 
58  // Public data
59 
60  //- Addressable ensight element types
61  enum elemType
62  {
67  NFACED
68  };
69 
70  //- Number of element types (5)
71  static constexpr int nTypes = 5;
72 
73  //- The ensight element type names
74  static const char* elemNames[5];
75 
76 
77  // Static Member Functions
78 
79  //- Return the ensight element name for the specified type
80  inline static const char* key(const enum elemType);
81 
82 
83 private:
84 
85  // Private Data
86 
87  //- Location within a list.
88  // The ensight part number is typically this value +1.
89  label index_;
90 
91  //- Linear list of ids, sub-sectioned per element type by sub-lists
92  labelList address_;
93 
94  //- Slices (sub-lists) of the address ids for each element type.
96 
97  //- List of global sizes for each element type.
98  // Used temporarily for local sizes when building the element lists.
99  FixedList<label, 5> sizes_;
100 
101 
102  // Private Member Functions
103 
104  //- Use temporarily stored sizes to redimension the element lists
105  void resizeAll();
106 
107  //- Classify cell types, set element lists for selection (implemention)
108  template<class Addressing>
109  void classifyImpl(const polyMesh& mesh, const Addressing& cellIds);
110 
111  //- No copy assignment
112  void operator=(const ensightCells&) = delete;
113 
114 
115 public:
116 
117  // Constructors
118 
119  //- Construct null, with part index 0
120  ensightCells();
121 
122  //- Construct null, with specified part index
123  explicit ensightCells(const label partIndex);
124 
125  //- Copy constructor. Needed for lists etc.
126  ensightCells(const ensightCells& obj);
127 
128 
129  //- Destructor
130  ~ensightCells() = default;
131 
132 
133  // Member Functions
134 
135  // Access
136 
137  //- The index in a list.
138  inline label index() const;
139 
140  //- The index in a list, non-const access.
141  inline label& index();
142 
143  //- The processor local size of all elements.
144  inline label size() const;
145 
146  //- The processor local size of the specified element type.
147  inline label size(const enum elemType) const;
148 
149  //- The global number of the specified element type.
150  // This value is only meaningful after a reduce operation.
151  inline label total(const enum elemType) const;
152 
153  //- The global number of all element types.
154  // This value is only meaningful after a reduce operation.
155  label total() const;
156 
157  //- The global numbers per element type.
158  // This value is only meaningful after a reduce operation.
159  inline const FixedList<label, 5>& totals() const;
160 
161  //- The processor local sizes per element type.
162  FixedList<label, 5> sizes() const;
163 
164  //- Processor local starting offset of element type.
165  inline label offset(const enum elemType what) const;
166 
167  //- Return the (local) cell ids of the specified element type
168  inline const labelUList cellIds(const enum elemType) const;
169 
170  //- Return the cell ids of all elements
171  inline const labelUList& cellIds() const;
172 
173 
174  // Edit
175 
176  //- Classify cell types and set the element lists.
177  void classify(const polyMesh& mesh);
178 
179  //- Classify cell types and set element lists,
180  //- using a subgroup of cells (eg, from a cellZone etc).
181  void classify(const polyMesh& mesh, const labelUList& cellIds);
182 
183  //- Classify cell types and set element lists,
184  //- using a subgroup of cells
185  void classify(const polyMesh& mesh, const bitSet& selection);
186 
187  //- Set addressable sizes to zero, free up addressing memory.
188  void clear();
189 
190  //- Sum element counts across all processes.
191  void reduce();
192 
193  //- Sort element lists numerically.
194  void sort();
195 
196 
197  // Member Operators
198 
199  //- Return id from linear list of addressing.
200  inline label operator[](const label i) const;
201 
202 };
203 
204 
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 
207 } // End namespace Foam
208 
209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 
211 #include "ensightCellsI.H"
212 
213 #endif
214 
215 // ************************************************************************* //
Foam::ensightCells::elemNames
static const char * elemNames[5]
The ensight element type names.
Definition: ensightCells.H:73
Foam::bitSet
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:64
Foam::ensightCells::cellIds
const labelUList & cellIds() const
Return the cell ids of all elements.
Definition: ensightCellsI.H:89
Foam::ensightCells::sort
void sort()
Sort element lists numerically.
Definition: ensightCells.C:146
Foam::ensightCells::PYRAMID5
"pyramid5"
Definition: ensightCells.H:63
Foam::ensightCells::index
label index() const
The index in a list.
Definition: ensightCellsI.H:38
Foam::ensightCells::PENTA6
"penta6"
Definition: ensightCells.H:64
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
Foam::ensightCells::nTypes
static constexpr int nTypes
Number of element types (5)
Definition: ensightCells.H:70
labelList.H
Foam::ensightCells::ensightCells
ensightCells()
Construct null, with part index 0.
Definition: ensightCells.C:66
Foam::ensightCells::key
static const char * key(const enum elemType)
Return the ensight element name for the specified type.
Definition: ensightCellsI.H:32
Foam::ensightCells::total
label total() const
The global number of all element types.
Definition: ensightCells.C:117
Foam::ensightCells
Sorting/classification of cells (3D) into corresponding ensight element types.
Definition: ensightCells.H:53
ensightCellsI.H
Foam::ensightCells::operator[]
label operator[](const label i) const
Return id from linear list of addressing.
Definition: ensightCellsI.H:95
Foam::ensightCells::TETRA4
"tetra4"
Definition: ensightCells.H:62
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::ensightCells::elemType
elemType
Addressable ensight element types.
Definition: ensightCells.H:60
Foam::ensightCells::NFACED
"nfaced"
Definition: ensightCells.H:66
Foam::ensightCells::offset
label offset(const enum elemType what) const
Processor local starting offset of element type.
Definition: ensightCellsI.H:74
Foam::List< label >
Foam::FixedList
A 1D vector of objects of type <T> with a fixed length <N>.
Definition: HashTable.H:104
Foam::UList< label >
Foam::ensightCells::size
label size() const
The processor local size of all elements.
Definition: ensightCellsI.H:50
FixedList.H
Foam::ensightCells::classify
void classify(const polyMesh &mesh)
Classify cell types and set the element lists.
Definition: ensightCells.C:238
Foam::ensightCells::sizes
FixedList< label, 5 > sizes() const
The processor local sizes per element type.
Definition: ensightCells.C:105
Foam::ensightCells::~ensightCells
~ensightCells()=default
Destructor.
Foam::ensightCells::reduce
void reduce()
Sum element counts across all processes.
Definition: ensightCells.C:135
Foam::ensightCells::clear
void clear()
Set addressable sizes to zero, free up addressing memory.
Definition: ensightCells.C:128
Foam::ensightCells::totals
const FixedList< label, 5 > & totals() const
The global numbers per element type.
Definition: ensightCellsI.H:56
Foam::ensightCells::HEXA8
"hexa8"
Definition: ensightCells.H:65