Skip to content

Commit 6571092

Browse files
author
Max Aehle
committed
Nodes is unique_ptr<unsigned long[]>
1 parent ac06f6f commit 6571092

12 files changed

Lines changed: 21 additions & 35 deletions

File tree

Common/include/geometry/primal_grid/CPrimalGrid.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <cstdlib>
3636
#include <limits>
3737
#include <bitset>
38+
#include <memory>
3839

3940
#include "../../CConfig.hpp"
4041

@@ -46,7 +47,7 @@
4647
*/
4748
class CPrimalGrid {
4849
protected:
49-
vector<unsigned long> Nodes; /*!< \brief Global node indices of the element. */
50+
unique_ptr<unsigned long[]> Nodes; /*!< \brief Global node indices of the element. */
5051
/*! If this is a domain element, store the global index.
5152
* If this is a boundary element, store the index of the incident domain element. */
5253
unsigned long GlobalIndex_DomainElement;
@@ -70,8 +71,9 @@ class CPrimalGrid {
7071
/*!
7172
* \brief Constructor of the class.
7273
* \param[in] FEM - Whether this is a FEM element.
74+
* \param[in] nNodes - Number of nodes.
7375
*/
74-
CPrimalGrid(bool FEM);
76+
CPrimalGrid(bool FEM, unsigned short nNodes);
7577

7678
/*!
7779
* \brief Destructor of the class.
@@ -461,7 +463,7 @@ template<typename Connectivity>
461463
class CPrimalGridWithConnectivity : public CPrimalGrid {
462464
public:
463465

464-
CPrimalGridWithConnectivity(bool FEM) : CPrimalGrid(FEM) {}
466+
CPrimalGridWithConnectivity(bool FEM) : CPrimalGrid(FEM, Connectivity::nNodes) {}
465467

466468
inline unsigned short GetnNodes() const final {
467469
return Connectivity::nNodes;

Common/src/geometry/primal_grid/CHexahedron.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ CHexahedron::CHexahedron(unsigned long val_point_0, unsigned long val_point_1,
4343
unsigned long val_point_6, unsigned long val_point_7):
4444
CPrimalGridWithConnectivity<CHexahedronConnectivity>(false)
4545
{
46-
/*--- Allocate and define face structure of the element ---*/
47-
Nodes.resize(GetnNodes());
46+
/*--- Define face structure of the element ---*/
4847
Nodes[0] = val_point_0; Nodes[1] = val_point_1;
4948
Nodes[2] = val_point_2; Nodes[3] = val_point_3;
5049
Nodes[4] = val_point_4; Nodes[5] = val_point_5;

Common/src/geometry/primal_grid/CLine.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,9 @@ constexpr unsigned short CLineConnectivity::VTK_Type;
4141
CLine::CLine(unsigned long val_point_0, unsigned long val_point_1):
4242
CPrimalGridWithConnectivity<CLineConnectivity>(false)
4343
{
44-
45-
/*--- Allocate and define face structure of the element ---*/
46-
47-
Nodes.resize(GetnNodes());
44+
/*--- Define face structure of the element ---*/
4845
Nodes[0] = val_point_0;
4946
Nodes[1] = val_point_1;
50-
5147
}
5248

5349
CLine::~CLine() {}

Common/src/geometry/primal_grid/CPrimalGrid.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
#include "../../../include/geometry/primal_grid/CPrimalGrid.hpp"
2929

30-
CPrimalGrid::CPrimalGrid(bool FEM) : FEM(FEM) {
30+
CPrimalGrid::CPrimalGrid(bool FEM, unsigned short nNodes) : FEM(FEM), Nodes(new unsigned long[nNodes]) {
3131

3232
GlobalIndex_DomainElement = 0;
3333
gi =true;

Common/src/geometry/primal_grid/CPrimalGridBoundFEM.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ CPrimalGridBoundFEM::CPrimalGridBoundFEM(unsigned long val_elemGlobalID,
3232
unsigned short val_VTK_Type,
3333
unsigned short val_nPolyGrid,
3434
unsigned short val_nDOFsGrid,
35-
vector<unsigned long> &val_nodes): CPrimalGrid(true)
35+
vector<unsigned long> &val_nodes): CPrimalGrid(true, val_nDOFsGrid)
3636
{
3737
/*--- Store the integer data in the member variables of this object. ---*/
3838
VTK_Type = val_VTK_Type;
@@ -44,10 +44,8 @@ CPrimalGridBoundFEM::CPrimalGridBoundFEM(unsigned long val_elemGlobalID,
4444
GlobalIndex_DomainElement = val_domainElementID;
4545
gi = false;
4646

47-
/*--- Allocate the memory for the global nodes of the element to define
48-
the geometry and copy them from val_nodes. ---*/
47+
/*--- Copy face structure of the element from val_nodes. ---*/
4948

50-
Nodes.resize(nDOFsGrid);
5149
for(unsigned short i=0; i<nDOFsGrid; i++)
5250
Nodes[i] = val_nodes[i];
5351

Common/src/geometry/primal_grid/CPrimalGridFEM.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
CPrimalGridFEM::CPrimalGridFEM(unsigned long val_elemGlobalID, unsigned short val_VTK_Type,
3131
unsigned short val_nPolyGrid, unsigned short val_nPolySol,
3232
unsigned short val_nDOFsGrid, unsigned short val_nDOFsSol,
33-
unsigned long val_offDOfsSol, istringstream &elem_line) : CPrimalGrid(true)
33+
unsigned long val_offDOfsSol, istringstream &elem_line) : CPrimalGrid(true, val_nDOFsGrid)
3434
{
3535
/*--- Store the integer data in the member variables of this object. ---*/
3636
VTK_Type = val_VTK_Type;
@@ -44,9 +44,8 @@ CPrimalGridFEM::CPrimalGridFEM(unsigned long val_elemGlobalID, unsigned short v
4444
elemIDGlobal = val_elemGlobalID;
4545
offsetDOFsSolGlobal = val_offDOfsSol;
4646

47-
/*--- Allocate the memory for the global nodes of the element to define
48-
the geometry and read them from elem_line. ---*/
49-
Nodes.resize(nDOFsGrid);
47+
/*--- Read face structure of the element from elem_line. ---*/
48+
5049
for(unsigned short i=0; i<nDOFsGrid; i++)
5150
elem_line >> Nodes[i];
5251

@@ -76,7 +75,7 @@ CPrimalGridFEM::CPrimalGridFEM(unsigned long val_elemGlobalID, unsigned short v
7675
CPrimalGridFEM::CPrimalGridFEM(unsigned long val_elemGlobalID, unsigned short val_VTK_Type,
7776
unsigned short val_nPolyGrid, unsigned short val_nPolySol,
7877
unsigned short val_nDOFsGrid, unsigned short val_nDOFsSol,
79-
unsigned long val_offDOfsSol, const unsigned long *connGrid): CPrimalGrid(true)
78+
unsigned long val_offDOfsSol, const unsigned long *connGrid): CPrimalGrid(true, val_nDOFsGrid)
8079
{
8180
/*--- Store the integer data in the member variables of this object. ---*/
8281
VTK_Type = val_VTK_Type;
@@ -90,9 +89,7 @@ CPrimalGridFEM::CPrimalGridFEM(unsigned long val_elemGlobalID, unsigned short v
9089
elemIDGlobal = val_elemGlobalID;
9190
offsetDOFsSolGlobal = val_offDOfsSol;
9291

93-
/*--- Allocate the memory for the global nodes of the element to define
94-
the geometry and copy the data from connGrid. ---*/
95-
Nodes.resize(nDOFsGrid);
92+
/*--- Copy face structure of the element from connGrid. ---*/
9693
for(unsigned short i=0; i<nDOFsGrid; i++)
9794
Nodes[i] = connGrid[i];
9895
}

Common/src/geometry/primal_grid/CPrism.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ CPrism::CPrism(unsigned long val_point_0, unsigned long val_point_1,
4343
CPrimalGridWithConnectivity<CPrismConnectivity>(false)
4444
{
4545

46-
/*--- Allocate and define face structure of the element ---*/
47-
Nodes.resize(GetnNodes());
46+
/*--- Define face structure of the element ---*/
4847
Nodes[0] = val_point_0;
4948
Nodes[1] = val_point_1;
5049
Nodes[2] = val_point_2;

Common/src/geometry/primal_grid/CPyramid.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ CPyramid::CPyramid(unsigned long val_point_0, unsigned long val_point_1,
4242
unsigned long val_point_4):
4343
CPrimalGridWithConnectivity<CPyramidConnectivity>(false)
4444
{
45-
/*--- Allocate and define face structure of the element ---*/
46-
Nodes.resize(GetnNodes());
45+
/*--- Define face structure of the element ---*/
4746
Nodes[0] = val_point_0;
4847
Nodes[1] = val_point_1;
4948
Nodes[2] = val_point_2;

Common/src/geometry/primal_grid/CQuadrilateral.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ CQuadrilateral::CQuadrilateral(unsigned long val_point_0, unsigned long val_poin
4141
unsigned long val_point_2, unsigned long val_point_3):
4242
CPrimalGridWithConnectivity<CQuadrilateralConnectivity>(false)
4343
{
44-
/*--- Allocate and define face structure of the element ---*/
45-
Nodes.resize(GetnNodes());
44+
/*--- Define face structure of the element ---*/
4645
Nodes[0] = val_point_0;
4746
Nodes[1] = val_point_1;
4847
Nodes[2] = val_point_2;

Common/src/geometry/primal_grid/CTetrahedron.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ CTetrahedron::CTetrahedron(unsigned long val_point_0, unsigned long val_point_1,
4141
unsigned long val_point_2, unsigned long val_point_3):
4242
CPrimalGridWithConnectivity<CTetrahedronConnectivity>(false)
4343
{
44-
/*--- Allocate and define face structure of the element ---*/
45-
Nodes.resize(GetnNodes());
44+
/*--- Define face structure of the element ---*/
4645
Nodes[0] = val_point_0;
4746
Nodes[1] = val_point_1;
4847
Nodes[2] = val_point_2;

0 commit comments

Comments
 (0)