Skip to content

Commit 2fcd09a

Browse files
author
Max Aehle
committed
Neighbor_Elements is unique_ptr<long[]>
1 parent 6571092 commit 2fcd09a

10 files changed

Lines changed: 19 additions & 28 deletions

File tree

Common/include/geometry/primal_grid/CPrimalGrid.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class CPrimalGrid {
5252
* If this is a boundary element, store the index of the incident domain element. */
5353
unsigned long GlobalIndex_DomainElement;
5454
bool gi;
55-
vector<long> Neighbor_Elements; /*!< \brief Vector to store the elements surronding an element. */
55+
unique_ptr<long[]> Neighbor_Elements; /*!< \brief Vector to store the elements surronding an element. */
5656
su2double Coord_CG[3] = {0.0}; /*!< \brief Coordinates of the center-of-gravity of the element. */
5757

5858
su2double Volume; /*!< \brief Volume of the element. */
@@ -72,8 +72,9 @@ class CPrimalGrid {
7272
* \brief Constructor of the class.
7373
* \param[in] FEM - Whether this is a FEM element.
7474
* \param[in] nNodes - Number of nodes.
75+
* \param[in] nNeighbor_Elements - Number of neighbor elements.
7576
*/
76-
CPrimalGrid(bool FEM, unsigned short nNodes);
77+
CPrimalGrid(bool FEM, unsigned short nNodes, unsigned short nNeighbor_Elements);
7778

7879
/*!
7980
* \brief Destructor of the class.
@@ -463,7 +464,7 @@ template<typename Connectivity>
463464
class CPrimalGridWithConnectivity : public CPrimalGrid {
464465
public:
465466

466-
CPrimalGridWithConnectivity(bool FEM) : CPrimalGrid(FEM, Connectivity::nNodes) {}
467+
CPrimalGridWithConnectivity(bool FEM) : CPrimalGrid(FEM, Connectivity::nNodes, Connectivity::nFaces) {}
467468

468469
inline unsigned short GetnNodes() const final {
469470
return Connectivity::nNodes;

Common/src/geometry/primal_grid/CHexahedron.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ CHexahedron::CHexahedron(unsigned long val_point_0, unsigned long val_point_1,
4848
Nodes[2] = val_point_2; Nodes[3] = val_point_3;
4949
Nodes[4] = val_point_4; Nodes[5] = val_point_5;
5050
Nodes[6] = val_point_6; Nodes[7] = val_point_7;
51-
52-
/*--- Allocate and define neighbor elements to a element ---*/
53-
Neighbor_Elements.resize(GetnFaces(),-1);
5451
}
5552

5653
CHexahedron::~CHexahedron() {}

Common/src/geometry/primal_grid/CPrimalGrid.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,15 @@
2727

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

30-
CPrimalGrid::CPrimalGrid(bool FEM, unsigned short nNodes) : FEM(FEM), Nodes(new unsigned long[nNodes]) {
30+
CPrimalGrid::CPrimalGrid(bool FEM, unsigned short nNodes, unsigned short nNeighbor_Elements) :
31+
FEM(FEM),
32+
Nodes(new unsigned long[nNodes]),
33+
Neighbor_Elements(new long[nNeighbor_Elements])
34+
{
3135

3236
GlobalIndex_DomainElement = 0;
37+
for(unsigned short i=0; i<nNeighbor_Elements; i++)
38+
Neighbor_Elements[i] = -1;
3339
gi =true;
3440

3541
}
@@ -47,10 +53,11 @@ void CPrimalGrid::GetAllNeighbor_Elements() const {
4753

4854
void CPrimalGrid::InitializeNeighbors(unsigned short val_nFaces) {
4955

50-
/*--- Allocate the memory for Neighbor_Elements and
51-
initialize the arrays to -1 to indicate that no neighbor is present and
56+
/*--- Initialize arrays to -1/false to indicate that no neighbor is present and
5257
that no periodic transformation is needed to the neighbor. ---*/
53-
Neighbor_Elements.resize(val_nFaces,-1);
54-
for(size_t i=0; i<val_nFaces; i++) PeriodIndexNeighbors[i] = -1;
58+
for(size_t i=0; i<val_nFaces; i++){
59+
Neighbor_Elements[i] = -1;
60+
PeriodIndexNeighbors[i] = -1;
61+
}
5562
ElementOwnsFace.reset();
5663
}

Common/src/geometry/primal_grid/CPrimalGridBoundFEM.cpp

Lines changed: 1 addition & 1 deletion
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, val_nDOFsGrid)
35+
vector<unsigned long> &val_nodes): CPrimalGrid(true, val_nDOFsGrid, 1)
3636
{
3737
/*--- Store the integer data in the member variables of this object. ---*/
3838
VTK_Type = val_VTK_Type;

Common/src/geometry/primal_grid/CPrimalGridFEM.cpp

Lines changed: 2 additions & 2 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, val_nDOFsGrid)
33+
unsigned long val_offDOfsSol, istringstream &elem_line) : CPrimalGrid(true, val_nDOFsGrid, nFacesOfElementType(val_VTK_Type))
3434
{
3535
/*--- Store the integer data in the member variables of this object. ---*/
3636
VTK_Type = val_VTK_Type;
@@ -75,7 +75,7 @@ CPrimalGridFEM::CPrimalGridFEM(unsigned long val_elemGlobalID, unsigned short v
7575
CPrimalGridFEM::CPrimalGridFEM(unsigned long val_elemGlobalID, unsigned short val_VTK_Type,
7676
unsigned short val_nPolyGrid, unsigned short val_nPolySol,
7777
unsigned short val_nDOFsGrid, unsigned short val_nDOFsSol,
78-
unsigned long val_offDOfsSol, const unsigned long *connGrid): CPrimalGrid(true, val_nDOFsGrid)
78+
unsigned long val_offDOfsSol, const unsigned long *connGrid): CPrimalGrid(true, val_nDOFsGrid, nFacesOfElementType(val_VTK_Type))
7979
{
8080
/*--- Store the integer data in the member variables of this object. ---*/
8181
VTK_Type = val_VTK_Type;

Common/src/geometry/primal_grid/CPrism.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ CPrism::CPrism(unsigned long val_point_0, unsigned long val_point_1,
5050
Nodes[3] = val_point_3;
5151
Nodes[4] = val_point_4;
5252
Nodes[5] = val_point_5;
53-
54-
/*--- Allocate and define neighbor elements to a element ---*/
55-
Neighbor_Elements.resize(GetnFaces(),-1);
5653
}
5754

5855
CPrism::~CPrism() {}

Common/src/geometry/primal_grid/CPyramid.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ CPyramid::CPyramid(unsigned long val_point_0, unsigned long val_point_1,
4848
Nodes[2] = val_point_2;
4949
Nodes[3] = val_point_3;
5050
Nodes[4] = val_point_4;
51-
52-
/*--- Allocate and define neighbor elements to a element ---*/
53-
Neighbor_Elements.resize(GetnFaces(),-1);
5451
}
5552

5653
CPyramid::~CPyramid() {}

Common/src/geometry/primal_grid/CQuadrilateral.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ CQuadrilateral::CQuadrilateral(unsigned long val_point_0, unsigned long val_poin
4646
Nodes[1] = val_point_1;
4747
Nodes[2] = val_point_2;
4848
Nodes[3] = val_point_3;
49-
50-
Neighbor_Elements.resize(GetnFaces(),-1);
5149
}
5250

5351
CQuadrilateral::~CQuadrilateral() {}

Common/src/geometry/primal_grid/CTetrahedron.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ CTetrahedron::CTetrahedron(unsigned long val_point_0, unsigned long val_point_1,
4646
Nodes[1] = val_point_1;
4747
Nodes[2] = val_point_2;
4848
Nodes[3] = val_point_3;
49-
50-
/*--- Allocate and define neighbor elements to a element ---*/
51-
Neighbor_Elements.resize(GetnFaces(),-1);
5249
}
5350

5451
CTetrahedron::~CTetrahedron() {}

Common/src/geometry/primal_grid/CTriangle.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ CTriangle::CTriangle(unsigned long val_point_0, unsigned long val_point_1,
4545
Nodes[0] = val_point_0;
4646
Nodes[1] = val_point_1;
4747
Nodes[2] = val_point_2;
48-
49-
/*--- Allocate and define neighbor elements to a element ---*/
50-
Neighbor_Elements.resize(GetnFaces(),-1);
5148
}
5249

5350
CTriangle::~CTriangle() {}

0 commit comments

Comments
 (0)