Skip to content

Commit 44e75c5

Browse files
author
Max Aehle
committed
Fix memory leaks related to CAdjEulerSolver::DonorGlobalIndex
1 parent b77c0c6 commit 44e75c5

3 files changed

Lines changed: 5 additions & 13 deletions

File tree

SU2_CFD/include/solvers/CAdjEulerSolver.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class CAdjEulerSolver : public CSolver {
6363
su2double Gamma_Minus_One; /*!< \brief Fluids's Gamma - 1.0 . */
6464
su2double *FlowPrimVar_i, /*!< \brief Store the flow solution at point i. */
6565
*FlowPrimVar_j; /*!< \brief Store the flow solution at point j. */
66-
unsigned long **DonorGlobalIndex; /*!< \brief Value of the donor global index. */
66+
vector<vector<unsigned long>> DonorGlobalIndex; /*!< \brief Value of the donor global index. */
6767

6868
su2double pnorm,
6969
Area_Monitored; /*!< \brief Store the total area of the monitored outflow surface (used for normalization in continuous adjoint outflow conditions) */

SU2_CFD/src/solvers/CAdjEulerSolver.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ CAdjEulerSolver::CAdjEulerSolver() : CSolver() {
4343
CSensitivity = nullptr;
4444
FlowPrimVar_i = nullptr;
4545
FlowPrimVar_j = nullptr;
46-
DonorGlobalIndex = nullptr;
4746

4847
}
4948

@@ -84,7 +83,6 @@ CAdjEulerSolver::CAdjEulerSolver(CGeometry *geometry, CConfig *config, unsigned
8483
CSensitivity = nullptr;
8584
FlowPrimVar_i = nullptr;
8685
FlowPrimVar_j = nullptr;
87-
DonorGlobalIndex = nullptr;
8886

8987
/*--- Set the gamma value ---*/
9088
Gamma = config->GetGamma();
@@ -196,12 +194,9 @@ CAdjEulerSolver::CAdjEulerSolver(CGeometry *geometry, CConfig *config, unsigned
196194

197195
/*--- Store the value of the characteristic primitive variables index at the boundaries ---*/
198196

199-
DonorGlobalIndex = new unsigned long* [nMarker];
197+
DonorGlobalIndex.resize(nMarker);
200198
for (iMarker = 0; iMarker < nMarker; iMarker++) {
201-
DonorGlobalIndex[iMarker] = new unsigned long [geometry->nVertex[iMarker]];
202-
for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) {
203-
DonorGlobalIndex[iMarker][iVertex] = 0;
204-
}
199+
DonorGlobalIndex[iMarker].resize(geometry->nVertex[iMarker],0);
205200
}
206201

207202
Sens_Geo = new su2double[nMarker];

SU2_CFD/src/solvers/CAdjNSSolver.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,9 @@ CAdjNSSolver::CAdjNSSolver(CGeometry *geometry, CConfig *config, unsigned short
164164

165165
/*--- Store the value of the characteristic primitive variables at the boundaries ---*/
166166

167-
DonorGlobalIndex = new unsigned long* [nMarker];
167+
DonorGlobalIndex.resize(nMarker);
168168
for (iMarker = 0; iMarker < nMarker; iMarker++) {
169-
DonorGlobalIndex[iMarker] = new unsigned long [geometry->nVertex[iMarker]];
170-
for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) {
171-
DonorGlobalIndex[iMarker][iVertex] = 0;
172-
}
169+
DonorGlobalIndex[iMarker].resize(geometry->nVertex[iMarker],0);
173170
}
174171

175172
Sens_Geo = new su2double[nMarker];

0 commit comments

Comments
 (0)