Skip to content

Commit 91fdb3f

Browse files
authored
Merge branch 'develop' into improve_heat_flux
2 parents 0fc99e9 + fbf39d3 commit 91fdb3f

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

SU2_CFD/src/solvers/CSolver.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3163,7 +3163,8 @@ void CSolver::InterpolateRestartData(const CGeometry *geometry, const CConfig *c
31633163
const unsigned long nFields = Restart_Vars[1];
31643164
const unsigned long nPointFile = Restart_Vars[2];
31653165
const auto t0 = SU2_MPI::Wtime();
3166-
auto nRecurse = 0;
3166+
int nRecurse = 0;
3167+
const int maxNRecurse = 128;
31673168

31683169
if (rank == MASTER_NODE) {
31693170
cout << "\nThe number of points in the restart file (" << nPointFile << ") does not match "
@@ -3262,7 +3263,7 @@ void CSolver::InterpolateRestartData(const CGeometry *geometry, const CConfig *c
32623263
bool done = false;
32633264

32643265
SU2_OMP_PARALLEL
3265-
while (!done) {
3266+
while (!done && nRecurse < maxNRecurse) {
32663267
SU2_OMP_FOR_DYN(roundUpDiv(nPointDomain,2*omp_get_num_threads()))
32673268
for (auto iPoint = 0ul; iPoint < nPointDomain; ++iPoint) {
32683269
/*--- Do not change points that are already interpolated. ---*/
@@ -3273,7 +3274,8 @@ void CSolver::InterpolateRestartData(const CGeometry *geometry, const CConfig *c
32733274

32743275
for (const auto jPoint : geometry->nodes->GetPoints(iPoint)) {
32753276
if (!isMapped[jPoint]) continue;
3276-
if (boundary_i != geometry->nodes->GetSolidBoundary(jPoint)) continue;
3277+
/*--- Take data from anywhere if we are looping too many times. ---*/
3278+
if (boundary_i != geometry->nodes->GetSolidBoundary(jPoint) && nRecurse < 8) continue;
32773279

32783280
nDonor[iPoint]++;
32793281

@@ -3315,6 +3317,10 @@ void CSolver::InterpolateRestartData(const CGeometry *geometry, const CConfig *c
33153317

33163318
} // everything goes out of scope except "localVars"
33173319

3320+
if (nRecurse == maxNRecurse) {
3321+
SU2_MPI::Error("Limit number of recursions reached, the meshes may be too different.", CURRENT_FUNCTION);
3322+
}
3323+
33183324
/*--- Move to Restart_Data in ascending order of global index, which is how a matching restart would have been read. ---*/
33193325

33203326
Restart_Data.resize(nPointDomain*nFields);
@@ -3329,9 +3335,11 @@ void CSolver::InterpolateRestartData(const CGeometry *geometry, const CConfig *c
33293335
counter++;
33303336
}
33313337
}
3338+
int nRecurseMax = 0;
3339+
SU2_MPI::Reduce(&nRecurse, &nRecurseMax, 1, MPI_INT, MPI_MAX, MASTER_NODE, SU2_MPI::GetComm());
33323340

33333341
if (rank == MASTER_NODE) {
3334-
cout << "Number of recursions: " << nRecurse << ".\n"
3342+
cout << "Number of recursions: " << nRecurseMax << ".\n"
33353343
"Elapsed time: " << SU2_MPI::Wtime()-t0 << "s.\n" << endl;
33363344
}
33373345
}

0 commit comments

Comments
 (0)