Skip to content

Commit 5fa720c

Browse files
authored
Merge pull request #1352 from su2code/fix_primalgrid_const
Refactor CPrimalGrid classes
2 parents 76fa1e9 + 36c25c2 commit 5fa720c

32 files changed

Lines changed: 655 additions & 1461 deletions

Common/include/fem/fem_cgns_elements.hpp

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ class CBoundaryFace;
4545

4646
/*!
4747
* \class CCGNSElementType
48-
* \brief Class which stores the CGNS element type info for a connectivity
49-
section.
50-
* \version 7.2.0 "Blackbird"
48+
* \brief Class which stores the CGNS element type info for a connectivity section.
5149
*/
5250

5351
class CCGNSElementType {
@@ -59,7 +57,7 @@ class CCGNSElementType {
5957
cgsize_t indEnd; /*!< \brief Index of the last element in the CGNS connectivity. */
6058
cgsize_t nElem; /*!< \brief Number of elements present for this element type. */
6159

62-
string connName; /*!< \brief Name of this connectivity. */
60+
std::string connName; /*!< \brief Name of this connectivity. */
6361

6462
bool volumeConn; /*!< \brief Whether or not this is a volume connectivity. */
6563
bool surfaceConn; /*!< \brief Whether or not this is a surface connectivity. */
@@ -85,7 +83,7 @@ class CCGNSElementType {
8583
const unsigned long nBoundElemRank,
8684
const unsigned long startingBoundElemIDRank,
8785
unsigned long &locBoundElemCount,
88-
vector<CBoundaryFace> &boundElems);
86+
std::vector<CBoundaryFace> &boundElems);
8987

9088
/*--- Member function, which reads the required connectivity range. ---*/
9189
void ReadConnectivityRange(const int fn,
@@ -104,7 +102,7 @@ class CCGNSElementType {
104102
unsigned short &VTK_Type,
105103
unsigned short &nPoly,
106104
unsigned short &nDOFs,
107-
vector<unsigned short> &SU2ToCGNS);
105+
std::vector<unsigned short> &SU2ToCGNS);
108106

109107
/*--- Member function, which determines the element dimension, i.e. the
110108
number of parametric coordinates. ---*/
@@ -122,158 +120,158 @@ class CCGNSElementType {
122120
given element in the stored types. If not present, a new index
123121
is created. ---*/
124122
unsigned short IndexInStoredTypes(const ElementType_t typeElem,
125-
vector<ElementType_t> &CGNS_Type,
126-
vector<unsigned short> &VTK_Type,
127-
vector<unsigned short> &nPoly,
128-
vector<unsigned short> &nDOFs,
129-
vector<vector<unsigned short> > &SU2ToCGNS);
123+
std::vector<ElementType_t> &CGNS_Type,
124+
std::vector<unsigned short> &VTK_Type,
125+
std::vector<unsigned short> &nPoly,
126+
std::vector<unsigned short> &nDOFs,
127+
std::vector<std::vector<unsigned short> > &SU2ToCGNS);
130128

131129
/*--- Functions to create the conversion data from CGNS format to SU2 format
132130
for all the supported CGNS elements. ---*/
133131
void CreateDataNODE(unsigned short &VTK_Type,
134132
unsigned short &nPoly,
135133
unsigned short &nDOFs,
136-
vector<unsigned short> &SU2ToCGNS);
134+
std::vector<unsigned short> &SU2ToCGNS);
137135

138136
void CreateDataBAR_2(unsigned short &VTK_Type,
139137
unsigned short &nPoly,
140138
unsigned short &nDOFs,
141-
vector<unsigned short> &SU2ToCGNS);
139+
std::vector<unsigned short> &SU2ToCGNS);
142140

143141
void CreateDataBAR_3(unsigned short &VTK_Type,
144142
unsigned short &nPoly,
145143
unsigned short &nDOFs,
146-
vector<unsigned short> &SU2ToCGNS);
144+
std::vector<unsigned short> &SU2ToCGNS);
147145

148146
void CreateDataBAR_4(unsigned short &VTK_Type,
149147
unsigned short &nPoly,
150148
unsigned short &nDOFs,
151-
vector<unsigned short> &SU2ToCGNS);
149+
std::vector<unsigned short> &SU2ToCGNS);
152150

153151
void CreateDataBAR_5(unsigned short &VTK_Type,
154152
unsigned short &nPoly,
155153
unsigned short &nDOFs,
156-
vector<unsigned short> &SU2ToCGNS);
154+
std::vector<unsigned short> &SU2ToCGNS);
157155

158156
void CreateDataTRI_3(unsigned short &VTK_Type,
159157
unsigned short &nPoly,
160158
unsigned short &nDOFs,
161-
vector<unsigned short> &SU2ToCGNS);
159+
std::vector<unsigned short> &SU2ToCGNS);
162160

163161
void CreateDataTRI_6(unsigned short &VTK_Type,
164162
unsigned short &nPoly,
165163
unsigned short &nDOFs,
166-
vector<unsigned short> &SU2ToCGNS);
164+
std::vector<unsigned short> &SU2ToCGNS);
167165

168166
void CreateDataTRI_10(unsigned short &VTK_Type,
169167
unsigned short &nPoly,
170168
unsigned short &nDOFs,
171-
vector<unsigned short> &SU2ToCGNS);
169+
std::vector<unsigned short> &SU2ToCGNS);
172170

173171
void CreateDataTRI_15(unsigned short &VTK_Type,
174172
unsigned short &nPoly,
175173
unsigned short &nDOFs,
176-
vector<unsigned short> &SU2ToCGNS);
174+
std::vector<unsigned short> &SU2ToCGNS);
177175

178176
void CreateDataQUAD_4(unsigned short &VTK_Type,
179177
unsigned short &nPoly,
180178
unsigned short &nDOFs,
181-
vector<unsigned short> &SU2ToCGNS);
179+
std::vector<unsigned short> &SU2ToCGNS);
182180

183181
void CreateDataQUAD_9(unsigned short &VTK_Type,
184182
unsigned short &nPoly,
185183
unsigned short &nDOFs,
186-
vector<unsigned short> &SU2ToCGNS);
184+
std::vector<unsigned short> &SU2ToCGNS);
187185

188186
void CreateDataQUAD_16(unsigned short &VTK_Type,
189187
unsigned short &nPoly,
190188
unsigned short &nDOFs,
191-
vector<unsigned short> &SU2ToCGNS);
189+
std::vector<unsigned short> &SU2ToCGNS);
192190

193191
void CreateDataQUAD_25(unsigned short &VTK_Type,
194192
unsigned short &nPoly,
195193
unsigned short &nDOFs,
196-
vector<unsigned short> &SU2ToCGNS);
194+
std::vector<unsigned short> &SU2ToCGNS);
197195

198196
void CreateDataTETRA_4(unsigned short &VTK_Type,
199197
unsigned short &nPoly,
200198
unsigned short &nDOFs,
201-
vector<unsigned short> &SU2ToCGNS);
199+
std::vector<unsigned short> &SU2ToCGNS);
202200

203201
void CreateDataTETRA_10(unsigned short &VTK_Type,
204202
unsigned short &nPoly,
205203
unsigned short &nDOFs,
206-
vector<unsigned short> &SU2ToCGNS);
204+
std::vector<unsigned short> &SU2ToCGNS);
207205

208206
void CreateDataTETRA_20(unsigned short &VTK_Type,
209207
unsigned short &nPoly,
210208
unsigned short &nDOFs,
211-
vector<unsigned short> &SU2ToCGNS);
209+
std::vector<unsigned short> &SU2ToCGNS);
212210

213211
void CreateDataTETRA_35(unsigned short &VTK_Type,
214212
unsigned short &nPoly,
215213
unsigned short &nDOFs,
216-
vector<unsigned short> &SU2ToCGNS);
214+
std::vector<unsigned short> &SU2ToCGNS);
217215

218216
void CreateDataPYRA_5(unsigned short &VTK_Type,
219217
unsigned short &nPoly,
220218
unsigned short &nDOFs,
221-
vector<unsigned short> &SU2ToCGNS);
219+
std::vector<unsigned short> &SU2ToCGNS);
222220

223221
void CreateDataPYRA_14(unsigned short &VTK_Type,
224222
unsigned short &nPoly,
225223
unsigned short &nDOFs,
226-
vector<unsigned short> &SU2ToCGNS);
224+
std::vector<unsigned short> &SU2ToCGNS);
227225

228226
void CreateDataPYRA_30(unsigned short &VTK_Type,
229227
unsigned short &nPoly,
230228
unsigned short &nDOFs,
231-
vector<unsigned short> &SU2ToCGNS);
229+
std::vector<unsigned short> &SU2ToCGNS);
232230

233231
void CreateDataPYRA_55(unsigned short &VTK_Type,
234232
unsigned short &nPoly,
235233
unsigned short &nDOFs,
236-
vector<unsigned short> &SU2ToCGNS);
234+
std::vector<unsigned short> &SU2ToCGNS);
237235

238236
void CreateDataPENTA_6(unsigned short &VTK_Type,
239237
unsigned short &nPoly,
240238
unsigned short &nDOFs,
241-
vector<unsigned short> &SU2ToCGNS);
239+
std::vector<unsigned short> &SU2ToCGNS);
242240

243241
void CreateDataPENTA_18(unsigned short &VTK_Type,
244242
unsigned short &nPoly,
245243
unsigned short &nDOFs,
246-
vector<unsigned short> &SU2ToCGNS);
244+
std::vector<unsigned short> &SU2ToCGNS);
247245

248246
void CreateDataPENTA_40(unsigned short &VTK_Type,
249247
unsigned short &nPoly,
250248
unsigned short &nDOFs,
251-
vector<unsigned short> &SU2ToCGNS);
249+
std::vector<unsigned short> &SU2ToCGNS);
252250

253251
void CreateDataPENTA_75(unsigned short &VTK_Type,
254252
unsigned short &nPoly,
255253
unsigned short &nDOFs,
256-
vector<unsigned short> &SU2ToCGNS);
254+
std::vector<unsigned short> &SU2ToCGNS);
257255

258256
void CreateDataHEXA_8(unsigned short &VTK_Type,
259257
unsigned short &nPoly,
260258
unsigned short &nDOFs,
261-
vector<unsigned short> &SU2ToCGNS);
259+
std::vector<unsigned short> &SU2ToCGNS);
262260

263261
void CreateDataHEXA_27(unsigned short &VTK_Type,
264262
unsigned short &nPoly,
265263
unsigned short &nDOFs,
266-
vector<unsigned short> &SU2ToCGNS);
264+
std::vector<unsigned short> &SU2ToCGNS);
267265

268266
void CreateDataHEXA_64(unsigned short &VTK_Type,
269267
unsigned short &nPoly,
270268
unsigned short &nDOFs,
271-
vector<unsigned short> &SU2ToCGNS);
269+
std::vector<unsigned short> &SU2ToCGNS);
272270

273271
void CreateDataHEXA_125(unsigned short &VTK_Type,
274272
unsigned short &nPoly,
275273
unsigned short &nDOFs,
276-
vector<unsigned short> &SU2ToCGNS);
274+
std::vector<unsigned short> &SU2ToCGNS);
277275
};
278276
#endif
279277
#endif

Common/include/geometry/CGeometry.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ class CGeometry {
191191
/*--- Main geometric elements of the grid. ---*/
192192

193193
CPrimalGrid** elem{nullptr}; /*!< \brief Element vector (primal grid information). */
194-
CPrimalGrid** face{nullptr}; /*!< \brief Face vector (primal grid information). */
195194
CPrimalGrid*** bound{nullptr}; /*!< \brief Boundary vector (primal grid information). */
196195
CPoint* nodes{nullptr}; /*!< \brief Node vector (dual grid information). */
197196
CEdge* edges{nullptr}; /*!< \brief Edge vector (dual grid information). */

Common/include/geometry/primal_grid/CHexahedron.hpp

Lines changed: 17 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,28 @@
3030

3131
#include "CPrimalGrid.hpp"
3232

33+
/*! \class CHexahedronConnectivity
34+
* Defines the connectivity of a hexahedron element.
35+
* See CPrimalGridWithConnectivity.
36+
*/
37+
struct CHexahedronConnectivity {
38+
enum { nNodes = N_POINTS_HEXAHEDRON };
39+
enum { nFaces = N_FACES_HEXAHEDRON };
40+
enum { maxNodesFace = N_POINTS_QUADRILATERAL };
41+
enum { VTK_Type = HEXAHEDRON };
42+
static constexpr unsigned short nNodesFace[6] = {4,4,4,4,4,4};
43+
static constexpr unsigned short Faces[6][4] = {{0,1,5,4},{1,2,6,5},{2,3,7,6},{3,0,4,7},{0,3,2,1},{4,5,6,7}};
44+
static constexpr unsigned short nNeighbor_Nodes[8] = {3,3,3,3,3,3,3,3};
45+
static constexpr unsigned short Neighbor_Nodes[8][3] = {{1,3,4},{0,2,5},{1,3,6},{0,2,7},{0,5,7},{4,6,1},{2,5,7},{4,3,6}};
46+
};
47+
3348
/*!
3449
* \class CHexahedron
3550
* \brief Class for hexahedron element definition.
3651
* \author F. Palacios
3752
*/
38-
class CHexahedron : public CPrimalGrid {
39-
private:
40-
static unsigned short Faces[6][4]; /*!< \brief Matrix to store the local nodes of all the faces. */
41-
static unsigned short Neighbor_Nodes[8][3]; /*!< \brief Neighbor to a nodes in the element. */
42-
static unsigned short nNodesFace[6]; /*!< \brief Number of nodes of each face of the element. */
43-
static unsigned short nNeighbor_Nodes[8]; /*!< \brief Number of Neighbor to a nodes in the element. */
44-
static unsigned short nFaces; /*!< \brief Number of faces of the element. */
45-
static unsigned short nNodes; /*!< \brief Number of nodes of the element. */
46-
static unsigned short VTK_Type; /*!< \brief Type of element using VTK nomenclature. */
47-
static unsigned short maxNodesFace; /*!< \brief Maximum number of nodes for a face. */
48-
static unsigned short nNeighbor_Elements; /*!< \brief Number of neighbor elements. */
49-
53+
class CHexahedron : public CPrimalGridWithConnectivity<CHexahedronConnectivity> {
5054
public:
51-
5255
/*!
5356
* \brief Constructor using the nodes and index.
5457
* \param[in] val_point_0 - Index of the 1st point read from the grid file.
@@ -65,88 +68,8 @@ class CHexahedron : public CPrimalGrid {
6568
unsigned long val_point_4, unsigned long val_point_5,
6669
unsigned long val_point_6, unsigned long val_point_7);
6770

68-
/*!
69-
* \brief Destructor of the class.
70-
*/
71-
~CHexahedron(void) override;
72-
73-
/*!
74-
* \brief Get the nodes shared by the triangle.
75-
* \param[in] val_node - Local (to the triangle) index of the node (a triangle has 3 nodes).
76-
* \return Global index of the triangle node.
77-
*/
78-
inline unsigned long GetNode(unsigned short val_node) override { return Nodes[val_node]; }
79-
80-
/*!
81-
* \brief Set the point associated at a node.
82-
* \param[in] val_node - Local index of a node.
83-
* \param[in] val_point - Point associated to the node.
84-
*/
85-
inline void SetNode(unsigned short val_node, unsigned long val_point) override { Nodes[val_node] = val_point; }
86-
87-
/*!
88-
* \brief Get the face index of and element.
89-
* \param[in] val_face - Local index of the face.
90-
* \param[in] val_index - Local (to the face) index of the nodes that compose the face.
91-
* \return Local (to the element) index of the nodes that compose the face.
92-
*/
93-
inline unsigned short GetFaces(unsigned short val_face, unsigned short val_index) override { return Faces[val_face][val_index]; }
94-
95-
/*!
96-
* \brief Get the local index of the neighbors to a node (given the local index).
97-
* \param[in] val_node - Local (to the element) index of a node.
98-
* \param[in] val_index - Local (to the neighbor nodes of val_node) index of the nodes
99-
* that are neighbor to val_node.
100-
* \return Local (to the element) index of the nodes that are neighbor to val_node.
101-
*/
102-
inline unsigned short GetNeighbor_Nodes(unsigned short val_node, unsigned short val_index) override { return Neighbor_Nodes[val_node][val_index]; }
103-
104-
/*!
105-
* \brief Get the number of neighbors nodes of a node.
106-
* \param[in] val_node - Local (to the element) index of a node.
107-
* \return Number if neighbors of a node val_node.
108-
*/
109-
inline unsigned short GetnNeighbor_Nodes(unsigned short val_node) override { return nNeighbor_Nodes[val_node]; }
110-
111-
/*!
112-
* \brief Get the number of nodes that composes a face of an element.
113-
* \param[in] val_face - Local index of the face.
114-
* \return Number of nodes that composes a face of an element.
115-
*/
116-
inline unsigned short GetnNodesFace(unsigned short val_face) override { return nNodesFace[val_face]; }
117-
118-
/*!
119-
* \brief Get the number of nodes of an element.
120-
* \return Number of nodes that composes an element.
121-
*/
122-
inline unsigned short GetnNodes(void) override { return nNodes; }
123-
124-
/*!
125-
* \brief Get the number of faces of an element.
126-
* \return Number of faces of an element.
127-
*/
128-
inline unsigned short GetnFaces(void) override { return nFaces; }
129-
130-
/*!
131-
* \brief Get the Maximum number of nodes of a face of an element.
132-
* \return Maximum number of nodes of a face of an element.
133-
*/
134-
inline unsigned short GetMaxNodesFace(void) override { return maxNodesFace; }
135-
136-
/*!
137-
* \brief Get the type of the element using VTK nomenclature.
138-
* \return Type of the element using VTK nomenclature.
139-
*/
140-
inline unsigned short GetVTK_Type(void) override { return VTK_Type; }
141-
142-
/*!
143-
* \brief Get the number of element that are neighbor to this element.
144-
* \return Number of neighbor elements.
145-
*/
146-
inline unsigned short GetnNeighbor_Elements(void) override { return nNeighbor_Elements; }
147-
14871
/*!
14972
* \brief Change the orientation of an element.
15073
*/
151-
void Change_Orientation(void) override;
74+
void Change_Orientation() override;
15275
};

0 commit comments

Comments
 (0)