Skip to content

Commit df5838c

Browse files
committed
added compatibility for multizone driver selection
1 parent 2bb4550 commit df5838c

6 files changed

Lines changed: 120 additions & 109 deletions

File tree

SU2_CFD/include/drivers/CDriverBase.hpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class CDriverBase {
5454
UsedTime; /*!< \brief Elapsed time between Start and Stop point of the timer. */
5555

5656
unsigned long TimeIter;
57-
57+
unsigned long selected_iZone = ZONE_0; /*!< \brief Selected zone for the driver. Defaults to ZONE_0 */
5858
unsigned short iMesh, /*!< \brief Iterator on mesh levels. */
5959
iZone, /*!< \brief Iterator on zones. */
6060
nZone, /*!< \brief Total number of zones in the problem. */
@@ -227,7 +227,7 @@ class CDriverBase {
227227
SU2_MPI::Error("Initial coordinates are only available with DEFORM_MESH= YES", CURRENT_FUNCTION);
228228
}
229229
auto* coords =
230-
const_cast<su2activematrix*>(solver_container[ZONE_0][INST_0][MESH_0][MESH_SOL]->GetNodes()->GetMesh_Coord());
230+
const_cast<su2activematrix*>(solver_container[selected_iZone][INST_0][MESH_0][MESH_SOL]->GetNodes()->GetMesh_Coord());
231231
return CPyWrapperMatrixView(*coords, "InitialCoordinates", true);
232232
}
233233

@@ -241,7 +241,7 @@ class CDriverBase {
241241
if (iMarker >= GetNumberMarkers()) SU2_MPI::Error("Marker index exceeds size.", CURRENT_FUNCTION);
242242

243243
auto* coords =
244-
const_cast<su2activematrix*>(solver_container[ZONE_0][INST_0][MESH_0][MESH_SOL]->GetNodes()->GetMesh_Coord());
244+
const_cast<su2activematrix*>(solver_container[selected_iZone][INST_0][MESH_0][MESH_SOL]->GetNodes()->GetMesh_Coord());
245245
return CPyWrapperMarkerMatrixView(*coords, main_geometry->vertex[iMarker], main_geometry->GetnVertex(iMarker),
246246
"MarkerInitialCoordinates", true);
247247
}
@@ -530,6 +530,17 @@ class CDriverBase {
530530
main_geometry->SetCustomBoundaryHeatFlux(iMarker, iVertex, WallHeatFlux);
531531
}
532532

533+
534+
/*!
535+
* \brief Selects zone to be used for Driver operation
536+
* \param[in] iZone - Zone identifier.
537+
*/
538+
inline void SelectZone(unsigned long iZone) {
539+
selected_iZone = iZone;
540+
main_geometry = geometry_container[selected_iZone][INST_0][MESH_0];
541+
main_config = config_container[selected_iZone];
542+
}
543+
533544
/*!
534545
* \brief Get the wall normal heat flux at a vertex on a specified marker of the flow or heat solver.
535546
* \note This can be the output of a heat or flow solver in a CHT setting.
@@ -677,7 +688,7 @@ class CDriverBase {
677688
if (iMarker < std::numeric_limits<unsigned short>::max() && iMarker > GetNumberMarkers()) {
678689
SU2_MPI::Error("Marker index exceeds size.", CURRENT_FUNCTION);
679690
}
680-
auto* solver = solver_container[ZONE_0][INST_0][MESH_0][iSolver];
691+
auto* solver = solver_container[selected_iZone][INST_0][MESH_0][iSolver];
681692
if (solver == nullptr) SU2_MPI::Error("The selected solver does not exist.", CURRENT_FUNCTION);
682693
return solver;
683694
}

SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ void CDiscAdjMultizoneDriver::Run() {
440440
/*--- Check for convergence. ---*/
441441

442442
StopCalc = driver_output->GetConvergence() || (iOuterIter == nOuterIter-1) ||
443-
((nZone==1) && output_container[ZONE_0]->GetConvergence());
443+
((nZone==1) && output_container[selected_iZone]->GetConvergence());
444444

445445
/*--- Clear the stored adjoint information to be ready for a new evaluation. ---*/
446446

@@ -765,13 +765,13 @@ void CDiscAdjMultizoneDriver::SetObjFunction(RECORDING kind_recording) {
765765
void CDiscAdjMultizoneDriver::SetAdjObjFunction() {
766766
su2double seeding = 1.0;
767767

768-
if (config_container[ZONE_0]->GetTime_Domain()) {
769-
const auto IterAvg_Obj = config_container[ZONE_0]->GetIter_Avg_Objective();
768+
if (config_container[selected_iZone]->GetTime_Domain()) {
769+
const auto IterAvg_Obj = config_container[selected_iZone]->GetIter_Avg_Objective();
770770
if (TimeIter < IterAvg_Obj) {
771771
/*--- Default behavior when no window is chosen is to use Square-Windowing, i.e. the numerator equals 1.0 ---*/
772772
auto windowEvaluator = CWindowingTools();
773773
const su2double weight =
774-
windowEvaluator.GetWndWeight(config_container[ZONE_0]->GetKindWindow(), TimeIter, IterAvg_Obj - 1);
774+
windowEvaluator.GetWndWeight(config_container[selected_iZone]->GetKindWindow(), TimeIter, IterAvg_Obj - 1);
775775
seeding = weight / IterAvg_Obj;
776776
}
777777
else {

0 commit comments

Comments
 (0)