Skip to content

Commit 25ba4e3

Browse files
committed
revise some shared readings and add others
1 parent 2830dea commit 25ba4e3

7 files changed

Lines changed: 44 additions & 46 deletions

File tree

SU2_CFD/src/solvers/CEulerSolver.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,6 +1886,8 @@ unsigned long CEulerSolver::SetPrimitive_Variables(CSolver **solver_container, c
18861886
* further reduction if function is called in parallel ---*/
18871887
unsigned long nonPhysicalPoints = 0;
18881888

1889+
AD::StartNoSharedReading();
1890+
18891891
SU2_OMP_FOR_STAT(omp_chunk_size)
18901892
for (unsigned long iPoint = 0; iPoint < nPoint; iPoint ++) {
18911893

@@ -1900,6 +1902,8 @@ unsigned long CEulerSolver::SetPrimitive_Variables(CSolver **solver_container, c
19001902
}
19011903
END_SU2_OMP_FOR
19021904

1905+
AD::EndNoSharedReading();
1906+
19031907
return nonPhysicalPoints;
19041908
}
19051909

@@ -2291,11 +2295,10 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain
22912295
unsigned short iVar;
22922296
unsigned long iPoint;
22932297

2294-
AD::StartNoSharedReading();
2295-
22962298
if (body_force) {
22972299

22982300
/*--- Loop over all points ---*/
2301+
AD::StartNoSharedReading();
22992302
SU2_OMP_FOR_STAT(omp_chunk_size)
23002303
for (iPoint = 0; iPoint < nPointDomain; iPoint++) {
23012304

@@ -2314,6 +2317,7 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain
23142317

23152318
}
23162319
END_SU2_OMP_FOR
2320+
AD::EndNoSharedReading();
23172321
}
23182322

23192323
if (rotating_frame) {
@@ -2324,6 +2328,7 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain
23242328
SetRotatingFrame_GCL(geometry, config);
23252329

23262330
/*--- Loop over all points ---*/
2331+
AD::StartNoSharedReading();
23272332
SU2_OMP_FOR_DYN(omp_chunk_size)
23282333
for (iPoint = 0; iPoint < nPointDomain; iPoint++) {
23292334

@@ -2345,20 +2350,18 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain
23452350

23462351
}
23472352
END_SU2_OMP_FOR
2353+
AD::EndNoSharedReading();
23482354
}
23492355

2350-
AD::EndNoSharedReading();
2351-
23522356
if (axisymmetric) {
23532357

23542358
/*--- For viscous problems, we need an additional gradient. ---*/
23552359
if (viscous) {
23562360
ComputeAxisymmetricAuxGradients(geometry, config);
23572361
}
23582362

2359-
AD::StartNoSharedReading();
2360-
23612363
/*--- loop over points ---*/
2364+
AD::StartNoSharedReading();
23622365
SU2_OMP_FOR_DYN(omp_chunk_size)
23632366
for (iPoint = 0; iPoint < nPointDomain; iPoint++) {
23642367

@@ -2480,8 +2483,6 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain
24802483
END_SU2_OMP_FOR
24812484
}
24822485

2483-
AD::EndNoSharedReading();
2484-
24852486
/*--- Check if a verification solution is to be computed. ---*/
24862487

24872488
if ( VerificationSolution ) {
@@ -2491,8 +2492,6 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain
24912492
su2double time = 0.0;
24922493
if (config->GetTime_Marching() != TIME_MARCHING::STEADY) time = config->GetPhysicalTime();
24932494

2494-
AD::StartNoSharedReading();
2495-
24962495
/*--- Loop over points ---*/
24972496
SU2_OMP_FOR_DYN(omp_chunk_size)
24982497
for (iPoint = 0; iPoint < nPointDomain; iPoint++) {
@@ -2513,11 +2512,10 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain
25132512
}
25142513
}
25152514
END_SU2_OMP_FOR
2516-
2517-
AD::EndNoSharedReading();
25182515
}
25192516
}
25202517

2518+
AD::EndNoSharedReading();
25212519
}
25222520

25232521
void CEulerSolver::Source_Template(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics,

SU2_CFD/src/solvers/CIncEulerSolver.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,8 @@ unsigned long CIncEulerSolver::SetPrimitive_Variables(CSolver **solver_container
938938

939939
unsigned long iPoint, nonPhysicalPoints = 0;
940940

941+
AD::StartNoSharedReading();
942+
941943
SU2_OMP_FOR_STAT(omp_chunk_size)
942944
for (iPoint = 0; iPoint < nPoint; iPoint ++) {
943945

@@ -951,6 +953,8 @@ unsigned long CIncEulerSolver::SetPrimitive_Variables(CSolver **solver_container
951953
}
952954
END_SU2_OMP_FOR
953955

956+
AD::EndNoSharedReading();
957+
954958
return nonPhysicalPoints;
955959
}
956960

@@ -1634,8 +1638,6 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont
16341638
/*--- Set delta_p, m_dot, inlet_T, integrated_heat ---*/
16351639
second_numerics->SetStreamwisePeriodicValues(SPvals);
16361640

1637-
AD::StartNoSharedReading();
1638-
16391641
/*--- This bit acts as a boundary condition rather than a source term. But logically it fits better here. ---*/
16401642
for (auto iMarker = 0ul; iMarker < config->GetnMarker_All(); iMarker++) {
16411643

@@ -1670,9 +1672,6 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont
16701672
END_SU2_OMP_FOR
16711673
}// if periodic inlet boundary
16721674
}// for iMarker
1673-
1674-
AD::EndNoSharedReading();
1675-
16761675
}// if !streamwise_periodic_temperature
16771676
}// if streamwise_periodic
16781677

SU2_CFD/src/solvers/CIncNSSolver.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,8 @@ unsigned long CIncNSSolver::SetPrimitive_Variables(CSolver **solver_container, c
327327

328328
bool tkeNeeded = ((turb_model == SST) || (turb_model == SST_SUST));
329329

330+
AD::StartNoSharedReading();
331+
330332
SU2_OMP_FOR_STAT(omp_chunk_size)
331333
for (iPoint = 0; iPoint < nPoint; iPoint++) {
332334

@@ -356,6 +358,8 @@ unsigned long CIncNSSolver::SetPrimitive_Variables(CSolver **solver_container, c
356358
}
357359
END_SU2_OMP_FOR
358360

361+
AD::EndNoSharedReading();
362+
359363
return nonPhysicalPoints;
360364

361365
}

SU2_CFD/src/solvers/CNSSolver.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ unsigned long CNSSolver::SetPrimitive_Variables(CSolver **solver_container, cons
135135
const unsigned short turb_model = config->GetKind_Turb_Model();
136136
const bool tkeNeeded = (turb_model == SST) || (turb_model == SST_SUST);
137137

138+
AD::StartNoSharedReading();
139+
138140
SU2_OMP_FOR_STAT(omp_chunk_size)
139141
for (unsigned long iPoint = 0; iPoint < nPoint; iPoint ++) {
140142

@@ -164,6 +166,8 @@ unsigned long CNSSolver::SetPrimitive_Variables(CSolver **solver_container, cons
164166
}
165167
END_SU2_OMP_FOR
166168

169+
AD::EndNoSharedReading();
170+
167171
return nonPhysicalPoints;
168172
}
169173

SU2_CFD/src/solvers/CSolver.cpp

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,8 +1929,6 @@ void CSolver::SetResidual_RMS(const CGeometry *geometry, const CConfig *config)
19291929

19301930
if (geometry->GetMGLevel() != MESH_0) return;
19311931

1932-
AD::StartNoSharedReading();
1933-
19341932
SU2_OMP_MASTER {
19351933

19361934
/*--- Set the L2 Norm residual in all the processors. ---*/
@@ -1987,16 +1985,12 @@ void CSolver::SetResidual_RMS(const CGeometry *geometry, const CConfig *config)
19871985
}
19881986
END_SU2_OMP_MASTER
19891987
SU2_OMP_BARRIER
1990-
1991-
AD::EndNoSharedReading();
19921988
}
19931989

19941990
void CSolver::SetResidual_BGS(const CGeometry *geometry, const CConfig *config) {
19951991

19961992
if (geometry->GetMGLevel() != MESH_0) return;
19971993

1998-
AD::StartNoSharedReading();
1999-
20001994
SU2_OMP_MASTER {
20011995

20021996
/*--- Set the L2 Norm residual in all the processors. ---*/
@@ -2034,8 +2028,6 @@ void CSolver::SetResidual_BGS(const CGeometry *geometry, const CConfig *config)
20342028
}
20352029
END_SU2_OMP_MASTER
20362030
SU2_OMP_BARRIER
2037-
2038-
AD::EndNoSharedReading();
20392031
}
20402032

20412033
void CSolver::SetRotatingFrame_GCL(CGeometry *geometry, const CConfig *config) {
@@ -4119,8 +4111,6 @@ void CSolver::ComputeResidual_Multizone(const CGeometry *geometry, const CConfig
41194111

41204112
SU2_OMP_PARALLEL {
41214113

4122-
AD::StartNoSharedReading();
4123-
41244114
/*--- Set Residuals to zero ---*/
41254115
SU2_OMP_MASTER
41264116
for (unsigned short iVar = 0; iVar < nVar; iVar++){
@@ -4162,8 +4152,6 @@ void CSolver::ComputeResidual_Multizone(const CGeometry *geometry, const CConfig
41624152
END_SU2_OMP_CRITICAL
41634153
SU2_OMP_BARRIER
41644154

4165-
AD::EndNoSharedReading();
4166-
41674155
SetResidual_BGS(geometry, config);
41684156

41694157
}
@@ -4225,7 +4213,7 @@ void CSolver::BasicLoadRestart(CGeometry *geometry, const CConfig *config, const
42254213
}
42264214

42274215
void CSolver::SavelibROM(CGeometry *geometry, CConfig *config, bool converged) {
4228-
4216+
42294217
#if defined(HAVE_LIBROM) && !defined(CODI_FORWARD_TYPE) && !defined(CODI_REVERSE_TYPE)
42304218
const bool unsteady = config->GetTime_Domain();
42314219
const string filename = config->GetlibROMbase_FileName();
@@ -4237,38 +4225,38 @@ void CSolver::SavelibROM(CGeometry *geometry, CConfig *config, bool converged) {
42374225
bool incremental = false;
42384226

42394227
if (!u_basis_generator) {
4240-
4228+
42414229
/*--- Define SVD basis generator ---*/
42424230
auto timesteps = static_cast<int>(nTimeIter - TimeIter);
42434231
CAROM::Options svd_options = CAROM::Options(dim, timesteps, -1,
42444232
false, true).setMaxBasisDimension(int(maxBasisDim));
4245-
4233+
42464234
if (config->GetKind_PODBasis() == POD_KIND::STATIC) {
42474235
if (rank == MASTER_NODE) std::cout << "Creating static basis generator." << std::endl;
4248-
4236+
42494237
if (unsteady) {
42504238
if (rank == MASTER_NODE) std::cout << "Incremental basis generator recommended for unsteady simulations." << std::endl;
42514239
}
42524240
}
42534241
else {
42544242
if (rank == MASTER_NODE) std::cout << "Creating incremental basis generator." << std::endl;
4255-
4243+
42564244
svd_options.setIncrementalSVD(1.0e-3, config->GetDelta_UnstTime(),
42574245
1.0e-2, config->GetDelta_UnstTime()*nTimeIter, true).setDebugMode(false);
42584246
incremental = true;
42594247
}
4260-
4248+
42614249
u_basis_generator.reset(new CAROM::BasisGenerator(
42624250
svd_options, incremental,
42634251
filename));
4264-
4252+
42654253
// Save mesh ordering
42664254
std::ofstream f;
42674255
f.open(filename + "_mesh_" + to_string(rank) + ".csv");
42684256
for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) {
42694257
unsigned long globalPoint = geometry->nodes->GetGlobalIndex(iPoint);
42704258
auto Coord = geometry->nodes->GetCoord(iPoint);
4271-
4259+
42724260
for (unsigned long iDim; iDim < nDim; iDim++) {
42734261
f << Coord[iDim] << ", ";
42744262
}
@@ -4283,31 +4271,31 @@ void CSolver::SavelibROM(CGeometry *geometry, CConfig *config, bool converged) {
42834271
su2double t = config->GetCurrent_UnstTime();
42844272
u_basis_generator->takeSample(const_cast<su2double*>(base_nodes->GetSolution().data()), t, dt);
42854273
}
4286-
4274+
42874275
/*--- End collection of data and save POD ---*/
4288-
4276+
42894277
if (converged) {
4290-
4278+
42914279
if (!unsteady) {
42924280
// dt is different for each node, so just use a placeholder dt
42934281
su2double dt = base_nodes->GetDelta_Time(0);
42944282
su2double t = dt*TimeIter;
42954283
u_basis_generator->takeSample(const_cast<su2double*>(base_nodes->GetSolution().data()), t, dt);
42964284
}
4297-
4285+
42984286
if (config->GetKind_PODBasis() == POD_KIND::STATIC) {
42994287
u_basis_generator->writeSnapshot();
43004288
}
4301-
4289+
43024290
if (rank == MASTER_NODE) std::cout << "Computing SVD" << std::endl;
43034291
int rom_dim = u_basis_generator->getSpatialBasis()->numColumns();
4304-
4292+
43054293
if (rank == MASTER_NODE) std::cout << "Basis dimension: " << rom_dim << std::endl;
43064294
u_basis_generator->endSamples();
4307-
4295+
43084296
if (rank == MASTER_NODE) std::cout << "ROM Sampling ended" << std::endl;
43094297
}
4310-
4298+
43114299
#else
43124300
SU2_MPI::Error("SU2 was not compiled with libROM support.", CURRENT_FUNCTION);
43134301
#endif

SU2_CFD/src/solvers/CTurbSASolver.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ void CTurbSASolver::Postprocessing(CGeometry *geometry, CSolver **solver_contain
255255

256256
/*--- Compute eddy viscosity ---*/
257257

258+
AD::StartNoSharedReading();
259+
258260
SU2_OMP_FOR_STAT(omp_chunk_size)
259261
for (unsigned long iPoint = 0; iPoint < nPoint; iPoint ++) {
260262

@@ -284,6 +286,7 @@ void CTurbSASolver::Postprocessing(CGeometry *geometry, CSolver **solver_contain
284286
}
285287
END_SU2_OMP_FOR
286288

289+
AD::EndNoSharedReading();
287290
}
288291

289292

@@ -297,7 +300,6 @@ void CTurbSASolver::Source_Residual(CGeometry *geometry, CSolver **solver_contai
297300

298301
CVariable* flowNodes = solver_container[FLOW_SOL]->GetNodes();
299302

300-
301303
/*--- Pick one numerics object per thread. ---*/
302304
CNumerics* numerics = numerics_container[SOURCE_FIRST_TERM + omp_get_thread_num()*MAX_TERMS];
303305

SU2_CFD/src/solvers/CTurbSSTSolver.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ void CTurbSSTSolver::Postprocessing(CGeometry *geometry, CSolver **solver_contai
244244
SetSolution_Gradient_LS(geometry, config);
245245
}
246246

247+
AD::StartNoSharedReading();
248+
247249
SU2_OMP_FOR_STAT(omp_chunk_size)
248250
for (unsigned long iPoint = 0; iPoint < nPoint; iPoint ++) {
249251

@@ -275,6 +277,7 @@ void CTurbSSTSolver::Postprocessing(CGeometry *geometry, CSolver **solver_contai
275277
}
276278
END_SU2_OMP_FOR
277279

280+
AD::EndNoSharedReading();
278281
}
279282

280283
void CTurbSSTSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container,

0 commit comments

Comments
 (0)