From df5838c335be8aa7d2ad6b5b09ddeec8d4e09b94 Mon Sep 17 00:00:00 2001 From: Afshawn Lotfi Date: Thu, 27 Apr 2023 15:56:37 +0000 Subject: [PATCH 1/3] added compatibility for multizone driver selection --- SU2_CFD/include/drivers/CDriverBase.hpp | 19 ++- .../src/drivers/CDiscAdjMultizoneDriver.cpp | 8 +- SU2_CFD/src/drivers/CDriver.cpp | 142 +++++++++--------- SU2_CFD/src/drivers/CDriverBase.cpp | 10 +- SU2_CFD/src/drivers/CMultizoneDriver.cpp | 16 +- SU2_CFD/src/python_wrapper_structure.cpp | 34 ++--- 6 files changed, 120 insertions(+), 109 deletions(-) diff --git a/SU2_CFD/include/drivers/CDriverBase.hpp b/SU2_CFD/include/drivers/CDriverBase.hpp index d720246efb74..00ccb3d29b59 100644 --- a/SU2_CFD/include/drivers/CDriverBase.hpp +++ b/SU2_CFD/include/drivers/CDriverBase.hpp @@ -54,7 +54,7 @@ class CDriverBase { UsedTime; /*!< \brief Elapsed time between Start and Stop point of the timer. */ unsigned long TimeIter; - + unsigned long selected_iZone = ZONE_0; /*!< \brief Selected zone for the driver. Defaults to ZONE_0 */ unsigned short iMesh, /*!< \brief Iterator on mesh levels. */ iZone, /*!< \brief Iterator on zones. */ nZone, /*!< \brief Total number of zones in the problem. */ @@ -227,7 +227,7 @@ class CDriverBase { SU2_MPI::Error("Initial coordinates are only available with DEFORM_MESH= YES", CURRENT_FUNCTION); } auto* coords = - const_cast(solver_container[ZONE_0][INST_0][MESH_0][MESH_SOL]->GetNodes()->GetMesh_Coord()); + const_cast(solver_container[selected_iZone][INST_0][MESH_0][MESH_SOL]->GetNodes()->GetMesh_Coord()); return CPyWrapperMatrixView(*coords, "InitialCoordinates", true); } @@ -241,7 +241,7 @@ class CDriverBase { if (iMarker >= GetNumberMarkers()) SU2_MPI::Error("Marker index exceeds size.", CURRENT_FUNCTION); auto* coords = - const_cast(solver_container[ZONE_0][INST_0][MESH_0][MESH_SOL]->GetNodes()->GetMesh_Coord()); + const_cast(solver_container[selected_iZone][INST_0][MESH_0][MESH_SOL]->GetNodes()->GetMesh_Coord()); return CPyWrapperMarkerMatrixView(*coords, main_geometry->vertex[iMarker], main_geometry->GetnVertex(iMarker), "MarkerInitialCoordinates", true); } @@ -530,6 +530,17 @@ class CDriverBase { main_geometry->SetCustomBoundaryHeatFlux(iMarker, iVertex, WallHeatFlux); } + + /*! + * \brief Selects zone to be used for Driver operation + * \param[in] iZone - Zone identifier. + */ + inline void SelectZone(unsigned long iZone) { + selected_iZone = iZone; + main_geometry = geometry_container[selected_iZone][INST_0][MESH_0]; + main_config = config_container[selected_iZone]; + } + /*! * \brief Get the wall normal heat flux at a vertex on a specified marker of the flow or heat solver. * \note This can be the output of a heat or flow solver in a CHT setting. @@ -677,7 +688,7 @@ class CDriverBase { if (iMarker < std::numeric_limits::max() && iMarker > GetNumberMarkers()) { SU2_MPI::Error("Marker index exceeds size.", CURRENT_FUNCTION); } - auto* solver = solver_container[ZONE_0][INST_0][MESH_0][iSolver]; + auto* solver = solver_container[selected_iZone][INST_0][MESH_0][iSolver]; if (solver == nullptr) SU2_MPI::Error("The selected solver does not exist.", CURRENT_FUNCTION); return solver; } diff --git a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp index 6277f409b8d8..13319167fc63 100644 --- a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp @@ -440,7 +440,7 @@ void CDiscAdjMultizoneDriver::Run() { /*--- Check for convergence. ---*/ StopCalc = driver_output->GetConvergence() || (iOuterIter == nOuterIter-1) || - ((nZone==1) && output_container[ZONE_0]->GetConvergence()); + ((nZone==1) && output_container[selected_iZone]->GetConvergence()); /*--- Clear the stored adjoint information to be ready for a new evaluation. ---*/ @@ -765,13 +765,13 @@ void CDiscAdjMultizoneDriver::SetObjFunction(RECORDING kind_recording) { void CDiscAdjMultizoneDriver::SetAdjObjFunction() { su2double seeding = 1.0; - if (config_container[ZONE_0]->GetTime_Domain()) { - const auto IterAvg_Obj = config_container[ZONE_0]->GetIter_Avg_Objective(); + if (config_container[selected_iZone]->GetTime_Domain()) { + const auto IterAvg_Obj = config_container[selected_iZone]->GetIter_Avg_Objective(); if (TimeIter < IterAvg_Obj) { /*--- Default behavior when no window is chosen is to use Square-Windowing, i.e. the numerator equals 1.0 ---*/ auto windowEvaluator = CWindowingTools(); const su2double weight = - windowEvaluator.GetWndWeight(config_container[ZONE_0]->GetKindWindow(), TimeIter, IterAvg_Obj - 1); + windowEvaluator.GetWndWeight(config_container[selected_iZone]->GetKindWindow(), TimeIter, IterAvg_Obj - 1); seeding = weight / IterAvg_Obj; } else { diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 07fc5ca36979..c60a7ba9b0cd 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -120,8 +120,8 @@ CDriverBase(confFile, val_nZone, MPICommunicator), StopCalc(false), fsi(false), /*--- Retrieve dimension from mesh file ---*/ - nDim = CConfig::GetnDim(config_container[ZONE_0]->GetMesh_FileName(), - config_container[ZONE_0]->GetMesh_FileFormat()); + nDim = CConfig::GetnDim(config_container[selected_iZone]->GetMesh_FileName(), + config_container[selected_iZone]->GetMesh_FileFormat()); /*--- Output preprocessing ---*/ @@ -243,7 +243,7 @@ CDriverBase(confFile, val_nZone, MPICommunicator), StopCalc(false), fsi(false), } } - if (config_container[ZONE_0]->GetBoolTurbomachinery()){ + if (config_container[selected_iZone]->GetBoolTurbomachinery()){ if (rank == MASTER_NODE) cout << endl <<"---------------------- Turbomachinery Preprocessing ---------------------" << endl; @@ -342,7 +342,7 @@ void CDriver::InitializeContainers(){ void CDriver::Finalize() { - const bool wrt_perf = config_container[ZONE_0]->GetWrt_Performance(); + const bool wrt_perf = config_container[selected_iZone]->GetWrt_Performance(); /*--- Output some information to the console. ---*/ @@ -350,10 +350,10 @@ void CDriver::Finalize() { /*--- Print out the number of non-physical points and reconstructions ---*/ - if (config_container[ZONE_0]->GetNonphysical_Points() > 0) - cout << "Warning: there are " << config_container[ZONE_0]->GetNonphysical_Points() << " non-physical points in the solution." << endl; - if (config_container[ZONE_0]->GetNonphysical_Reconstr() > 0) - cout << "Warning: " << config_container[ZONE_0]->GetNonphysical_Reconstr() << " reconstructed states for upwinding are non-physical." << endl; + if (config_container[selected_iZone]->GetNonphysical_Points() > 0) + cout << "Warning: there are " << config_container[selected_iZone]->GetNonphysical_Points() << " non-physical points in the solution." << endl; + if (config_container[selected_iZone]->GetNonphysical_Reconstr() > 0) + cout << "Warning: " << config_container[selected_iZone]->GetNonphysical_Reconstr() << " reconstructed states for upwinding are non-physical." << endl; } if (rank == MASTER_NODE) @@ -456,8 +456,8 @@ void CDriver::Finalize() { // Note that for now this is called only by a single thread, but all // necessary variables have been made thread private for safety (tick/tock)!! - config_container[ZONE_0]->SetProfilingCSV(); - config_container[ZONE_0]->GEMMProfilingCSV(); + config_container[selected_iZone]->SetProfilingCSV(); + config_container[selected_iZone]->GEMMProfilingCSV(); /*--- Deallocate config container ---*/ if (config_container!= nullptr) { @@ -585,14 +585,14 @@ void CDriver::PreprocessInput(CConfig **&config, CConfig *&driver_config) { /*--- Keep a reference to the main (ZONE 0) config. ---*/ - main_config = config_container[ZONE_0]; + main_config = config_container[selected_iZone]; /*--- Determine whether or not the FEM solver is used, which decides the type of * geometry classes that are instantiated. Only adapted for single-zone problems ---*/ - fem_solver = config_container[ZONE_0]->GetFEMSolver(); + fem_solver = config_container[selected_iZone]->GetFEMSolver(); - fsi = config_container[ZONE_0]->GetFSI_Simulation(); + fsi = config_container[selected_iZone]->GetFSI_Simulation(); } void CDriver::InitializeGeometry(CConfig* config, CGeometry **&geometry, bool dummy){ @@ -693,7 +693,7 @@ void CDriver::InitializeGeometry(CConfig* config, CGeometry **&geometry, bool du /*--- Keep a reference to the main (ZONE_0, INST_0, MESH_0) geometry. ---*/ - main_geometry = geometry_container[ZONE_0][INST_0][MESH_0]; + main_geometry = geometry_container[selected_iZone][INST_0][MESH_0]; } void CDriver::InitializeGeometryFVM(CConfig *config, CGeometry **&geometry) { @@ -2470,7 +2470,7 @@ void CDriver::InitializeInterface(CConfig **config, CSolver***** solver, CGeomet interface_type = FLOW_TRACTION; auto nConst = 2; bool conservative = config[target]->GetConservativeInterpolation(); - if(!config[ZONE_0]->GetDiscrete_Adjoint()) { + if(!config[selected_iZone]->GetDiscrete_Adjoint()) { interface[donor][target] = new CFlowTractionInterface(nDim, nConst, config[donor], conservative); } else { interface[donor][target] = new CDiscAdjFlowTractionInterface(nDim, nConst, config[donor], conservative); @@ -2570,7 +2570,7 @@ void CDriver::PreprocessStaticMesh(const CConfig *config, CGeometry** geometry){ /*--- Set the grid velocities on all multigrid levels for a steadily rotating reference frame. ---*/ - for (iMGlevel = 0; iMGlevel <= config_container[ZONE_0]->GetnMGLevels(); iMGlevel++){ + for (iMGlevel = 0; iMGlevel <= config_container[selected_iZone]->GetnMGLevels(); iMGlevel++){ geometry[iMGlevel]->SetRotationalVelocity(config, true); geometry[iMGlevel]->SetShroudVelocity(config); } @@ -2588,7 +2588,7 @@ void CDriver::PreprocessStaticMesh(const CConfig *config, CGeometry** geometry){ /*--- Set the translational velocity on all grid levels. ---*/ - for (iMGlevel = 0; iMGlevel <= config_container[ZONE_0]->GetnMGLevels(); iMGlevel++) + for (iMGlevel = 0; iMGlevel <= config_container[selected_iZone]->GetnMGLevels(); iMGlevel++) geometry_container[iZone][INST_0][iMGlevel]->SetTranslationalVelocity(config, true); break; @@ -2667,8 +2667,8 @@ void CDriver::PreprocessOutput(CConfig **config, CConfig *driver_config, COutput } /*--- Check for an unsteady restart. Update ExtIter if necessary. ---*/ - if (config_container[ZONE_0]->GetTime_Domain() && config_container[ZONE_0]->GetRestart()) - TimeIter = config_container[ZONE_0]->GetRestart_Iter(); + if (config_container[selected_iZone]->GetTime_Domain() && config_container[selected_iZone]->GetRestart()) + TimeIter = config_container[selected_iZone]->GetRestart_Iter(); } @@ -2678,9 +2678,9 @@ void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, unsigned short donorZone,targetZone, nMarkerInt, iMarkerInt; unsigned short nSpanMax = 0; - bool restart = (config[ZONE_0]->GetRestart() || config[ZONE_0]->GetRestart_Flow()); - mixingplane = config[ZONE_0]->GetBoolMixingPlaneInterface(); - bool discrete_adjoint = config[ZONE_0]->GetDiscrete_Adjoint(); + bool restart = (config[selected_iZone]->GetRestart() || config[selected_iZone]->GetRestart_Flow()); + mixingplane = config[selected_iZone]->GetBoolMixingPlaneInterface(); + bool discrete_adjoint = config[selected_iZone]->GetDiscrete_Adjoint(); su2double areaIn, areaOut, nBlades, flowAngleIn, flowAngleOut; /*--- Create turbovertex structure ---*/ @@ -2694,7 +2694,7 @@ void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, nSpanMax = config[iZone]->GetnSpanWiseSections(); } - config[ZONE_0]->SetnSpan_iZones(config[iZone]->GetnSpanWiseSections(), iZone); + config[selected_iZone]->SetnSpan_iZones(config[iZone]->GetnSpanWiseSections(), iZone); geometry[iZone][INST_0][MESH_0]->SetTurboVertex(config[iZone], iZone, INFLOW, true); geometry[iZone][INST_0][MESH_0]->SetTurboVertex(config[iZone], iZone, OUTFLOW, true); @@ -2737,13 +2737,13 @@ void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, if (rank == MASTER_NODE) cout << "Transfer average geometric quantities to zone 0." << endl; for (iZone = 1; iZone < nZone; iZone++) { - interface[iZone][ZONE_0]->GatherAverageTurboGeoValues(geometry[iZone][INST_0][MESH_0],geometry[ZONE_0][INST_0][MESH_0], iZone); + interface[iZone][selected_iZone]->GatherAverageTurboGeoValues(geometry[iZone][INST_0][MESH_0],geometry[selected_iZone][INST_0][MESH_0], iZone); } /*--- Transfer number of blade to ZONE_0 to correctly compute turbo performance---*/ for (iZone = 1; iZone < nZone; iZone++) { nBlades = config[iZone]->GetnBlades(iZone); - config[ZONE_0]->SetnBlades(iZone, nBlades); + config[selected_iZone]->SetnBlades(iZone, nBlades); } if (rank == MASTER_NODE){ @@ -2809,7 +2809,7 @@ void CDriver::PrintDirectResidual(RECORDING kind_recording) { if (rank != MASTER_NODE || kind_recording != RECORDING::SOLUTION_VARIABLES) return; - const bool multizone = config_container[ZONE_0]->GetMultizone_Problem(); + const bool multizone = config_container[selected_iZone]->GetMultizone_Problem(); /*--- Helper lambda func to return lenghty [iVar][iZone] string. ---*/ auto iVar_iZone2string = [&](unsigned short ivar, unsigned short izone) { @@ -2822,7 +2822,7 @@ void CDriver::PrintDirectResidual(RECORDING kind_recording) { const unsigned short fieldWidth = 15; PrintingToolbox::CTablePrinter RMSTable(&std::cout); - RMSTable.SetPrecision(config_container[ZONE_0]->GetOutput_Precision()); + RMSTable.SetPrecision(config_container[selected_iZone]->GetOutput_Precision()); /*--- The CTablePrinter requires two sweeps: *--- 0. Add the colum names (addVals=0=false) plus CTablePrinter.PrintHeader() @@ -2920,7 +2920,7 @@ void CDriver::PrintDirectResidual(RECORDING kind_recording) { } void CDriver::RampTurbomachineryValues(unsigned long iter) { - auto* config = config_container[ZONE_0]; + auto* config = config_container[selected_iZone]; /*--- ROTATING FRAME Ramp: Compute the updated rotational velocity. ---*/ if (config->GetGrid_Movement() && config->GetRampRotatingFrame()) { @@ -2952,8 +2952,8 @@ void CDriver::RampTurbomachineryValues(unsigned long iter) { } for (auto iZone = 1u; iZone < nZone; iZone++) { - interface_container[iZone][ZONE_0]->GatherAverageTurboGeoValues( - geometry_container[iZone][INST_0][MESH_0], geometry_container[ZONE_0][INST_0][MESH_0], iZone); + interface_container[iZone][selected_iZone]->GatherAverageTurboGeoValues( + geometry_container[iZone][INST_0][MESH_0], geometry_container[selected_iZone][INST_0][MESH_0], iZone); } } } @@ -2996,7 +2996,7 @@ void CDriver::RampTurbomachineryValues(unsigned long iter) { } CFluidDriver::CFluidDriver(char* confFile, unsigned short val_nZone, SU2_Comm MPICommunicator) : CDriver(confFile, val_nZone, MPICommunicator, false) { - Max_Iter = config_container[ZONE_0]->GetnInner_Iter(); + Max_Iter = config_container[selected_iZone]->GetnInner_Iter(); } CFluidDriver::~CFluidDriver() = default; @@ -3024,7 +3024,7 @@ void CFluidDriver::StartSolver(){ /*--- For the Disc.Adj. of a case with (rigidly) moving grid, the appropriate mesh cordinates are read from the restart files. ---*/ if (!fem_solver && - !(config_container[ZONE_0]->GetGrid_Movement() && config_container[ZONE_0]->GetDiscrete_Adjoint())) { + !(config_container[selected_iZone]->GetGrid_Movement() && config_container[selected_iZone]->GetDiscrete_Adjoint())) { DynamicMeshUpdate(Iter); } @@ -3037,7 +3037,7 @@ void CFluidDriver::StartSolver(){ Update(); /*--- Terminate the simulation if only the Jacobian must be computed. ---*/ - if (config_container[ZONE_0]->GetJacobian_Spatial_Discretization_Only()) break; + if (config_container[selected_iZone]->GetJacobian_Spatial_Discretization_Only()) break; /*--- Monitor the computations after each iteration. ---*/ @@ -3231,7 +3231,7 @@ CHBDriver::CHBDriver(char* confFile, MPICommunicator) { unsigned short kInst; - nInstHB = nInst[ZONE_0]; + nInstHB = nInst[selected_iZone]; /*--- allocate dynamic memory for the Harmonic Balance operator ---*/ D = new su2double*[nInstHB]; @@ -3254,17 +3254,17 @@ void CHBDriver::Run() { all zones before beginning the iteration. ---*/ for (iInst = 0; iInst < nInstHB; iInst++) - iteration_container[ZONE_0][iInst]->Preprocess(output_container[ZONE_0], integration_container, geometry_container, + iteration_container[selected_iZone][iInst]->Preprocess(output_container[selected_iZone], integration_container, geometry_container, solver_container, numerics_container, config_container, surface_movement, grid_movement, FFDBox, ZONE_0, iInst); for (iInst = 0; iInst < nInstHB; iInst++) - iteration_container[ZONE_0][iInst]->Iterate(output_container[ZONE_0], integration_container, geometry_container, + iteration_container[selected_iZone][iInst]->Iterate(output_container[selected_iZone], integration_container, geometry_container, solver_container, numerics_container, config_container, surface_movement, grid_movement, FFDBox, ZONE_0, iInst); for (iInst = 0; iInst < nInstHB; iInst++) - iteration_container[ZONE_0][iInst]->Monitor(output_container[ZONE_0], integration_container, geometry_container, + iteration_container[selected_iZone][iInst]->Monitor(output_container[selected_iZone], integration_container, geometry_container, solver_container, numerics_container, config_container, surface_movement, grid_movement, FFDBox, ZONE_0, iInst); @@ -3279,7 +3279,7 @@ void CHBDriver::Update() { } /*--- Precondition the harmonic balance source terms ---*/ - if (config_container[ZONE_0]->GetHB_Precondition() == YES) { + if (config_container[selected_iZone]->GetHB_Precondition() == YES) { StabilizeHarmonicBalance(); } @@ -3287,7 +3287,7 @@ void CHBDriver::Update() { for (iInst = 0; iInst < nInstHB; iInst++) { /*--- Update the harmonic balance terms across all zones ---*/ - iteration_container[ZONE_0][iInst]->Update(output_container[ZONE_0], integration_container, geometry_container, + iteration_container[selected_iZone][iInst]->Update(output_container[selected_iZone], integration_container, geometry_container, solver_container, numerics_container, config_container, surface_movement, grid_movement, FFDBox, ZONE_0, iInst); @@ -3298,15 +3298,15 @@ void CHBDriver::Update() { void CHBDriver::SetHarmonicBalance(unsigned short iInst) { unsigned short iVar, jInst, iMGlevel; - unsigned short nVar = solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->GetnVar(); + unsigned short nVar = solver_container[selected_iZone][INST_0][MESH_0][FLOW_SOL]->GetnVar(); unsigned long iPoint; - bool implicit = (config_container[ZONE_0]->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - bool adjoint = (config_container[ZONE_0]->GetContinuous_Adjoint()); + bool implicit = (config_container[selected_iZone]->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + bool adjoint = (config_container[selected_iZone]->GetContinuous_Adjoint()); if (adjoint) { - implicit = (config_container[ZONE_0]->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); + implicit = (config_container[selected_iZone]->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); } - unsigned long InnerIter = config_container[ZONE_0]->GetInnerIter(); + unsigned long InnerIter = config_container[selected_iZone]->GetInnerIter(); /*--- Retrieve values from the config file ---*/ auto *U = new su2double[nVar]; @@ -3317,20 +3317,20 @@ void CHBDriver::SetHarmonicBalance(unsigned short iInst) { su2double deltaU, deltaPsi; /*--- Compute period of oscillation ---*/ - su2double period = config_container[ZONE_0]->GetHarmonicBalance_Period(); + su2double period = config_container[selected_iZone]->GetHarmonicBalance_Period(); /*--- Non-dimensionalize the input period, if necessary. */ - period /= config_container[ZONE_0]->GetTime_Ref(); + period /= config_container[selected_iZone]->GetTime_Ref(); if (InnerIter == 0) ComputeHBOperator(); /*--- Compute various source terms for explicit direct, implicit direct, and adjoint problems ---*/ /*--- Loop over all grid levels ---*/ - for (iMGlevel = 0; iMGlevel <= config_container[ZONE_0]->GetnMGLevels(); iMGlevel++) { + for (iMGlevel = 0; iMGlevel <= config_container[selected_iZone]->GetnMGLevels(); iMGlevel++) { /*--- Loop over each node in the volume mesh ---*/ - for (iPoint = 0; iPoint < geometry_container[ZONE_0][iInst][iMGlevel]->GetnPoint(); iPoint++) { + for (iPoint = 0; iPoint < geometry_container[selected_iZone][iInst][iMGlevel]->GetnPoint(); iPoint++) { for (iVar = 0; iVar < nVar; iVar++) { Source[iVar] = 0.0; @@ -3343,11 +3343,11 @@ void CHBDriver::SetHarmonicBalance(unsigned short iInst) { for (iVar = 0; iVar < nVar; iVar++) { if (!adjoint) { - U[iVar] = solver_container[ZONE_0][jInst][iMGlevel][FLOW_SOL]->GetNodes()->GetSolution(iPoint, iVar); + U[iVar] = solver_container[selected_iZone][jInst][iMGlevel][FLOW_SOL]->GetNodes()->GetSolution(iPoint, iVar); Source[iVar] += U[iVar]*D[iInst][jInst]; if (implicit) { - U_old[iVar] = solver_container[ZONE_0][jInst][iMGlevel][FLOW_SOL]->GetNodes()->GetSolution_Old(iPoint, iVar); + U_old[iVar] = solver_container[selected_iZone][jInst][iMGlevel][FLOW_SOL]->GetNodes()->GetSolution_Old(iPoint, iVar); deltaU = U[iVar] - U_old[iVar]; Source[iVar] += deltaU*D[iInst][jInst]; } @@ -3355,11 +3355,11 @@ void CHBDriver::SetHarmonicBalance(unsigned short iInst) { } else { - Psi[iVar] = solver_container[ZONE_0][jInst][iMGlevel][ADJFLOW_SOL]->GetNodes()->GetSolution(iPoint, iVar); + Psi[iVar] = solver_container[selected_iZone][jInst][iMGlevel][ADJFLOW_SOL]->GetNodes()->GetSolution(iPoint, iVar); Source[iVar] += Psi[iVar]*D[jInst][iInst]; if (implicit) { - Psi_old[iVar] = solver_container[ZONE_0][jInst][iMGlevel][ADJFLOW_SOL]->GetNodes()->GetSolution_Old(iPoint, iVar); + Psi_old[iVar] = solver_container[selected_iZone][jInst][iMGlevel][ADJFLOW_SOL]->GetNodes()->GetSolution_Old(iPoint, iVar); deltaPsi = Psi[iVar] - Psi_old[iVar]; Source[iVar] += deltaPsi*D[jInst][iInst]; } @@ -3369,10 +3369,10 @@ void CHBDriver::SetHarmonicBalance(unsigned short iInst) { /*--- Store sources for current row ---*/ for (iVar = 0; iVar < nVar; iVar++) { if (!adjoint) { - solver_container[ZONE_0][iInst][iMGlevel][FLOW_SOL]->GetNodes()->SetHarmonicBalance_Source(iPoint, iVar, Source[iVar]); + solver_container[selected_iZone][iInst][iMGlevel][FLOW_SOL]->GetNodes()->SetHarmonicBalance_Source(iPoint, iVar, Source[iVar]); } else { - solver_container[ZONE_0][iInst][iMGlevel][ADJFLOW_SOL]->GetNodes()->SetHarmonicBalance_Source(iPoint, iVar, Source[iVar]); + solver_container[selected_iZone][iInst][iMGlevel][ADJFLOW_SOL]->GetNodes()->SetHarmonicBalance_Source(iPoint, iVar, Source[iVar]); } } @@ -3381,29 +3381,29 @@ void CHBDriver::SetHarmonicBalance(unsigned short iInst) { } /*--- Source term for a turbulence model ---*/ - if (config_container[ZONE_0]->GetKind_Solver() == MAIN_SOLVER::RANS) { + if (config_container[selected_iZone]->GetKind_Solver() == MAIN_SOLVER::RANS) { /*--- Extra variables needed if we have a turbulence model. ---*/ - unsigned short nVar_Turb = solver_container[ZONE_0][INST_0][MESH_0][TURB_SOL]->GetnVar(); + unsigned short nVar_Turb = solver_container[selected_iZone][INST_0][MESH_0][TURB_SOL]->GetnVar(); auto *U_Turb = new su2double[nVar_Turb]; auto *Source_Turb = new su2double[nVar_Turb]; /*--- Loop over only the finest mesh level (turbulence is always solved on the original grid only). ---*/ - for (iPoint = 0; iPoint < geometry_container[ZONE_0][INST_0][MESH_0]->GetnPoint(); iPoint++) { + for (iPoint = 0; iPoint < geometry_container[selected_iZone][INST_0][MESH_0]->GetnPoint(); iPoint++) { for (iVar = 0; iVar < nVar_Turb; iVar++) Source_Turb[iVar] = 0.0; for (jInst = 0; jInst < nInstHB; jInst++) { /*--- Retrieve solution at this node in current zone ---*/ for (iVar = 0; iVar < nVar_Turb; iVar++) { - U_Turb[iVar] = solver_container[ZONE_0][jInst][MESH_0][TURB_SOL]->GetNodes()->GetSolution(iPoint, iVar); + U_Turb[iVar] = solver_container[selected_iZone][jInst][MESH_0][TURB_SOL]->GetNodes()->GetSolution(iPoint, iVar); Source_Turb[iVar] += U_Turb[iVar]*D[iInst][jInst]; } } /*--- Store sources for current iZone ---*/ for (iVar = 0; iVar < nVar_Turb; iVar++) - solver_container[ZONE_0][iInst][MESH_0][TURB_SOL]->GetNodes()->SetHarmonicBalance_Source(iPoint, iVar, Source_Turb[iVar]); + solver_container[selected_iZone][iInst][MESH_0][TURB_SOL]->GetNodes()->SetHarmonicBalance_Source(iPoint, iVar, Source_Turb[iVar]); } delete [] U_Turb; @@ -3421,9 +3421,9 @@ void CHBDriver::SetHarmonicBalance(unsigned short iInst) { void CHBDriver::StabilizeHarmonicBalance() { unsigned short i, j, k, iVar, iInst, jInst, iMGlevel; - unsigned short nVar = solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->GetnVar(); + unsigned short nVar = solver_container[selected_iZone][INST_0][MESH_0][FLOW_SOL]->GetnVar(); unsigned long iPoint; - bool adjoint = (config_container[ZONE_0]->GetContinuous_Adjoint()); + bool adjoint = (config_container[selected_iZone]->GetContinuous_Adjoint()); /*--- Retrieve values from the config file ---*/ auto *Source = new su2double[nInstHB]; @@ -3438,13 +3438,13 @@ void CHBDriver::StabilizeHarmonicBalance() { } /*--- Loop over all grid levels ---*/ - for (iMGlevel = 0; iMGlevel <= config_container[ZONE_0]->GetnMGLevels(); iMGlevel++) { + for (iMGlevel = 0; iMGlevel <= config_container[selected_iZone]->GetnMGLevels(); iMGlevel++) { /*--- Loop over each node in the volume mesh ---*/ - for (iPoint = 0; iPoint < geometry_container[ZONE_0][INST_0][iMGlevel]->GetnPoint(); iPoint++) { + for (iPoint = 0; iPoint < geometry_container[selected_iZone][INST_0][iMGlevel]->GetnPoint(); iPoint++) { /*--- Get time step for current node ---*/ - Delta = solver_container[ZONE_0][INST_0][iMGlevel][FLOW_SOL]->GetNodes()->GetDelta_Time(iPoint); + Delta = solver_container[selected_iZone][INST_0][iMGlevel][FLOW_SOL]->GetNodes()->GetDelta_Time(iPoint); /*--- Setup stabilization matrix for this node ---*/ for (iInst = 0; iInst < nInstHB; iInst++) { @@ -3543,7 +3543,7 @@ void CHBDriver::StabilizeHarmonicBalance() { /*--- Get current source terms (not yet preconditioned) and zero source array to prepare preconditioning ---*/ for (iInst = 0; iInst < nInstHB; iInst++) { - Source_old[iInst] = solver_container[ZONE_0][iInst][iMGlevel][FLOW_SOL]->GetNodes()->GetHarmonicBalance_Source(iPoint, iVar); + Source_old[iInst] = solver_container[selected_iZone][iInst][iMGlevel][FLOW_SOL]->GetNodes()->GetHarmonicBalance_Source(iPoint, iVar); Source[iInst] = 0; } @@ -3555,10 +3555,10 @@ void CHBDriver::StabilizeHarmonicBalance() { /*--- Store updated source terms for current node ---*/ if (!adjoint) { - solver_container[ZONE_0][iInst][iMGlevel][FLOW_SOL]->GetNodes()->SetHarmonicBalance_Source(iPoint, iVar, Source[iInst]); + solver_container[selected_iZone][iInst][iMGlevel][FLOW_SOL]->GetNodes()->SetHarmonicBalance_Source(iPoint, iVar, Source[iInst]); } else { - solver_container[ZONE_0][iInst][iMGlevel][ADJFLOW_SOL]->GetNodes()->SetHarmonicBalance_Source(iPoint, iVar, Source[iInst]); + solver_container[selected_iZone][iInst][iMGlevel][ADJFLOW_SOL]->GetNodes()->SetHarmonicBalance_Source(iPoint, iVar, Source[iInst]); } } @@ -3594,15 +3594,15 @@ void CHBDriver::ComputeHBOperator() { } /*--- Get simualation period from config file ---*/ - su2double Period = config_container[ZONE_0]->GetHarmonicBalance_Period(); + su2double Period = config_container[selected_iZone]->GetHarmonicBalance_Period(); /*--- Non-dimensionalize the input period, if necessary. */ - Period /= config_container[ZONE_0]->GetTime_Ref(); + Period /= config_container[selected_iZone]->GetTime_Ref(); /*--- Build the array containing the selected frequencies to solve ---*/ for (iInst = 0; iInst < nInstHB; iInst++) { - Omega_HB[iInst] = config_container[ZONE_0]->GetOmega_HB()[iInst]; - Omega_HB[iInst] /= config_container[ZONE_0]->GetOmega_Ref(); //TODO: check + Omega_HB[iInst] = config_container[selected_iZone]->GetOmega_HB()[iInst]; + Omega_HB[iInst] /= config_container[selected_iZone]->GetOmega_Ref(); //TODO: check } /*--- Build the diagonal matrix of the frequencies DD ---*/ diff --git a/SU2_CFD/src/drivers/CDriverBase.cpp b/SU2_CFD/src/drivers/CDriverBase.cpp index ff07e7d1e482..603e2f734f84 100644 --- a/SU2_CFD/src/drivers/CDriverBase.cpp +++ b/SU2_CFD/src/drivers/CDriverBase.cpp @@ -391,14 +391,14 @@ vector CDriverBase::GetMarkerVertexNormals(unsigned short iMarker } void CDriverBase::CommunicateMeshDisplacements() { - solver_container[ZONE_0][INST_0][MESH_0][MESH_SOL]->InitiateComms(main_geometry, main_config, MESH_DISPLACEMENTS); - solver_container[ZONE_0][INST_0][MESH_0][MESH_SOL]->CompleteComms(main_geometry, main_config, MESH_DISPLACEMENTS); + solver_container[selected_iZone][INST_0][MESH_0][MESH_SOL]->InitiateComms(main_geometry, main_config, MESH_DISPLACEMENTS); + solver_container[selected_iZone][INST_0][MESH_0][MESH_SOL]->CompleteComms(main_geometry, main_config, MESH_DISPLACEMENTS); } map CDriverBase::GetSolverIndices() const { map indexMap; for (auto iSol = 0u; iSol < MAX_SOLS; iSol++) { - const auto* solver = solver_container[ZONE_0][INST_0][MESH_0][iSol]; + const auto* solver = solver_container[selected_iZone][INST_0][MESH_0][iSol]; if (solver != nullptr) { if (solver->GetSolverName().empty()) SU2_MPI::Error("Solver name was not defined.", CURRENT_FUNCTION); indexMap[solver->GetSolverName()] = iSol; @@ -408,7 +408,7 @@ map CDriverBase::GetSolverIndices() const { } std::map CDriverBase::GetFEASolutionIndices() const { - if (solver_container[ZONE_0][INST_0][MESH_0][FEA_SOL] == nullptr) { + if (solver_container[selected_iZone][INST_0][MESH_0][FEA_SOL] == nullptr) { SU2_MPI::Error("The FEA solver does not exist.", CURRENT_FUNCTION); } const auto nDim = main_geometry->GetnDim(); @@ -429,7 +429,7 @@ std::map CDriverBase::GetFEASolutionIndices() const { } map CDriverBase::GetPrimitiveIndices() const { - if (solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL] == nullptr) { + if (solver_container[selected_iZone][INST_0][MESH_0][FLOW_SOL] == nullptr) { SU2_MPI::Error("The flow solver does not exist.", CURRENT_FUNCTION); } return PrimitiveNameToIndexMap(CPrimitiveIndices( diff --git a/SU2_CFD/src/drivers/CMultizoneDriver.cpp b/SU2_CFD/src/drivers/CMultizoneDriver.cpp index 61f59223fcfe..9c8039db7824 100644 --- a/SU2_CFD/src/drivers/CMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CMultizoneDriver.cpp @@ -248,7 +248,7 @@ void CMultizoneDriver::Preprocess(unsigned long TimeIter) { } /*--- Ramp turbo values for unsteady problems here, otherwise do it over outer iterations. ---*/ - if (config_container[ZONE_0]->GetTime_Domain()) { + if (config_container[selected_iZone]->GetTime_Domain()) { RampTurbomachineryValues(TimeIter); } @@ -294,7 +294,7 @@ void CMultizoneDriver::RunGaussSeidel() { for (auto iOuter_Iter = 0ul; iOuter_Iter < driver_config->GetnOuter_Iter(); iOuter_Iter++) { /*--- Ramp turbo values for steady problems here, otherwise do it over time steps. ---*/ - if (!config_container[ZONE_0]->GetTime_Domain()) { + if (!config_container[selected_iZone]->GetTime_Domain()) { RampTurbomachineryValues(iOuter_Iter); } @@ -352,7 +352,7 @@ void CMultizoneDriver::RunJacobi() { for (auto iOuter_Iter = 0ul; iOuter_Iter < driver_config->GetnOuter_Iter(); iOuter_Iter++){ /*--- Ramp turbo values for steady problems here, otherwise do it over time steps. ---*/ - if (!config_container[ZONE_0]->GetTime_Domain()) { + if (!config_container[selected_iZone]->GetTime_Domain()) { RampTurbomachineryValues(iOuter_Iter); } @@ -407,7 +407,7 @@ void CMultizoneDriver::RunJacobi() { void CMultizoneDriver::Corrector(unsigned short val_iZone) { if (config_container[val_iZone]->GetRelaxation()) - iteration_container[val_iZone][INST_0]->Relaxation(output_container[ZONE_0], integration_container, + iteration_container[val_iZone][INST_0]->Relaxation(output_container[selected_iZone], integration_container, geometry_container, solver_container, numerics_container, config_container, surface_movement, grid_movement, FFDBox, val_iZone, INST_0); } @@ -493,7 +493,7 @@ void CMultizoneDriver::Output(unsigned long TimeIter) { UsedTimeOutput += StopTime-StartTime; OutputCount++; - BandwidthSum = config_container[ZONE_0]->GetRestart_Bandwidth_Agg(); + BandwidthSum = config_container[selected_iZone]->GetRestart_Bandwidth_Agg(); StartTime = SU2_MPI::Wtime(); @@ -632,8 +632,8 @@ void CMultizoneDriver::SetMixingPlane(unsigned short donorZone) { void CMultizoneDriver::SetTurboPerformance() { for (auto donorZone = 1u; donorZone < nZone; donorZone++) { - interface_container[donorZone][ZONE_0]->GatherAverageValues(solver_container[donorZone][INST_0][MESH_0][FLOW_SOL], - solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL], + interface_container[donorZone][selected_iZone]->GatherAverageValues(solver_container[donorZone][INST_0][MESH_0][FLOW_SOL], + solver_container[selected_iZone][INST_0][MESH_0][FLOW_SOL], donorZone); } } @@ -688,5 +688,5 @@ bool CMultizoneDriver::Monitor(unsigned long TimeIter){ } bool CMultizoneDriver::GetTimeConvergence() const{ - return output_container[ZONE_0]->GetCauchyCorrectedTimeConvergence(config_container[ZONE_0]); + return output_container[selected_iZone]->GetCauchyCorrectedTimeConvergence(config_container[selected_iZone]); } diff --git a/SU2_CFD/src/python_wrapper_structure.cpp b/SU2_CFD/src/python_wrapper_structure.cpp index 3626baaae5a3..b5b8c80d5813 100644 --- a/SU2_CFD/src/python_wrapper_structure.cpp +++ b/SU2_CFD/src/python_wrapper_structure.cpp @@ -62,15 +62,15 @@ void CDriver::PreprocessPythonInterface(CConfig** config, CGeometry**** geometry /* Functions to obtain global parameters from SU2 (time steps, delta t, etc.) */ ////////////////////////////////////////////////////////////////////////////////// -unsigned long CDriver::GetNumberTimeIter() const { return config_container[ZONE_0]->GetnTime_Iter(); } +unsigned long CDriver::GetNumberTimeIter() const { return config_container[selected_iZone]->GetnTime_Iter(); } unsigned long CDriver::GetTimeIter() const { return TimeIter; } passivedouble CDriver::GetUnsteadyTimeStep() const { - return SU2_TYPE::GetValue(config_container[ZONE_0]->GetTime_Step()); + return SU2_TYPE::GetValue(config_container[selected_iZone]->GetTime_Step()); } -string CDriver::GetSurfaceFileName() const { return config_container[ZONE_0]->GetSurfCoeff_FileName(); } +string CDriver::GetSurfaceFileName() const { return config_container[selected_iZone]->GetSurfCoeff_FileName(); } //////////////////////////////////////////////////////////////////////////////// /* Functions related to the management of markers */ @@ -78,12 +78,12 @@ string CDriver::GetSurfaceFileName() const { return config_container[ZONE_0]->Ge void CDriver::SetHeatSourcePosition(passivedouble alpha, passivedouble pos_x, passivedouble pos_y, passivedouble pos_z) { - CSolver* solver = solver_container[ZONE_0][INST_0][MESH_0][RAD_SOL]; + CSolver* solver = solver_container[selected_iZone][INST_0][MESH_0][RAD_SOL]; - config_container[ZONE_0]->SetHeatSource_Rot_Z(alpha); - config_container[ZONE_0]->SetHeatSource_Center(pos_x, pos_y, pos_z); + config_container[selected_iZone]->SetHeatSource_Rot_Z(alpha); + config_container[selected_iZone]->SetHeatSource_Center(pos_x, pos_y, pos_z); - solver->SetVolumetricHeatSource(geometry_container[ZONE_0][INST_0][MESH_0], config_container[ZONE_0]); + solver->SetVolumetricHeatSource(geometry_container[selected_iZone][INST_0][MESH_0], config_container[selected_iZone]); } void CDriver::SetInletAngle(unsigned short iMarker, passivedouble alpha) { @@ -91,9 +91,9 @@ void CDriver::SetInletAngle(unsigned short iMarker, passivedouble alpha) { unsigned long iVertex; - for (iVertex = 0; iVertex < geometry_container[ZONE_0][INST_0][MESH_0]->nVertex[iMarker]; iVertex++) { - solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->SetInlet_FlowDir(iMarker, iVertex, 0, cos(alpha_rad)); - solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->SetInlet_FlowDir(iMarker, iVertex, 1, sin(alpha_rad)); + for (iVertex = 0; iVertex < geometry_container[selected_iZone][INST_0][MESH_0]->nVertex[iMarker]; iVertex++) { + solver_container[selected_iZone][INST_0][MESH_0][FLOW_SOL]->SetInlet_FlowDir(iMarker, iVertex, 0, cos(alpha_rad)); + solver_container[selected_iZone][INST_0][MESH_0][FLOW_SOL]->SetInlet_FlowDir(iMarker, iVertex, 1, sin(alpha_rad)); } } @@ -106,22 +106,22 @@ void CSinglezoneDriver::SetInitialMesh() { SU2_OMP_PARALLEL { for (iMesh = 0u; iMesh <= main_config->GetnMGLevels(); iMesh++) { - SU2_OMP_FOR_STAT(roundUpDiv(geometry_container[ZONE_0][INST_0][iMesh]->GetnPoint(), omp_get_max_threads())) - for (auto iPoint = 0ul; iPoint < geometry_container[ZONE_0][INST_0][iMesh]->GetnPoint(); iPoint++) { + SU2_OMP_FOR_STAT(roundUpDiv(geometry_container[selected_iZone][INST_0][iMesh]->GetnPoint(), omp_get_max_threads())) + for (auto iPoint = 0ul; iPoint < geometry_container[selected_iZone][INST_0][iMesh]->GetnPoint(); iPoint++) { /*--- Overwrite fictitious velocities. ---*/ su2double Grid_Vel[3] = {0.0, 0.0, 0.0}; /*--- Set the grid velocity for this coarse node. ---*/ - geometry_container[ZONE_0][INST_0][iMesh]->nodes->SetGridVel(iPoint, Grid_Vel); + geometry_container[selected_iZone][INST_0][iMesh]->nodes->SetGridVel(iPoint, Grid_Vel); } END_SU2_OMP_FOR /*--- Push back the volume. ---*/ - geometry_container[ZONE_0][INST_0][iMesh]->nodes->SetVolume_n(); - geometry_container[ZONE_0][INST_0][iMesh]->nodes->SetVolume_nM1(); + geometry_container[selected_iZone][INST_0][iMesh]->nodes->SetVolume_n(); + geometry_container[selected_iZone][INST_0][iMesh]->nodes->SetVolume_nM1(); } /*--- Push back the solution so that there is no fictitious velocity at the next step. ---*/ - solver_container[ZONE_0][INST_0][MESH_0][MESH_SOL]->GetNodes()->Set_Solution_time_n(); - solver_container[ZONE_0][INST_0][MESH_0][MESH_SOL]->GetNodes()->Set_Solution_time_n1(); + solver_container[selected_iZone][INST_0][MESH_0][MESH_SOL]->GetNodes()->Set_Solution_time_n(); + solver_container[selected_iZone][INST_0][MESH_0][MESH_SOL]->GetNodes()->Set_Solution_time_n1(); } END_SU2_OMP_PARALLEL } From fdc15e04abe456d4d2e0dcb7bf8a0aa49745ae0d Mon Sep 17 00:00:00 2001 From: Afshawn Lotfi Date: Sun, 30 Apr 2023 01:25:40 +0000 Subject: [PATCH 2/3] Removed changes for non pysu2 functions --- .../src/drivers/CDiscAdjMultizoneDriver.cpp | 8 +- SU2_CFD/src/drivers/CDriver.cpp | 142 +++++++++--------- SU2_CFD/src/drivers/CMultizoneDriver.cpp | 16 +- 3 files changed, 83 insertions(+), 83 deletions(-) diff --git a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp index 13319167fc63..6277f409b8d8 100644 --- a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp @@ -440,7 +440,7 @@ void CDiscAdjMultizoneDriver::Run() { /*--- Check for convergence. ---*/ StopCalc = driver_output->GetConvergence() || (iOuterIter == nOuterIter-1) || - ((nZone==1) && output_container[selected_iZone]->GetConvergence()); + ((nZone==1) && output_container[ZONE_0]->GetConvergence()); /*--- Clear the stored adjoint information to be ready for a new evaluation. ---*/ @@ -765,13 +765,13 @@ void CDiscAdjMultizoneDriver::SetObjFunction(RECORDING kind_recording) { void CDiscAdjMultizoneDriver::SetAdjObjFunction() { su2double seeding = 1.0; - if (config_container[selected_iZone]->GetTime_Domain()) { - const auto IterAvg_Obj = config_container[selected_iZone]->GetIter_Avg_Objective(); + if (config_container[ZONE_0]->GetTime_Domain()) { + const auto IterAvg_Obj = config_container[ZONE_0]->GetIter_Avg_Objective(); if (TimeIter < IterAvg_Obj) { /*--- Default behavior when no window is chosen is to use Square-Windowing, i.e. the numerator equals 1.0 ---*/ auto windowEvaluator = CWindowingTools(); const su2double weight = - windowEvaluator.GetWndWeight(config_container[selected_iZone]->GetKindWindow(), TimeIter, IterAvg_Obj - 1); + windowEvaluator.GetWndWeight(config_container[ZONE_0]->GetKindWindow(), TimeIter, IterAvg_Obj - 1); seeding = weight / IterAvg_Obj; } else { diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index c60a7ba9b0cd..07fc5ca36979 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -120,8 +120,8 @@ CDriverBase(confFile, val_nZone, MPICommunicator), StopCalc(false), fsi(false), /*--- Retrieve dimension from mesh file ---*/ - nDim = CConfig::GetnDim(config_container[selected_iZone]->GetMesh_FileName(), - config_container[selected_iZone]->GetMesh_FileFormat()); + nDim = CConfig::GetnDim(config_container[ZONE_0]->GetMesh_FileName(), + config_container[ZONE_0]->GetMesh_FileFormat()); /*--- Output preprocessing ---*/ @@ -243,7 +243,7 @@ CDriverBase(confFile, val_nZone, MPICommunicator), StopCalc(false), fsi(false), } } - if (config_container[selected_iZone]->GetBoolTurbomachinery()){ + if (config_container[ZONE_0]->GetBoolTurbomachinery()){ if (rank == MASTER_NODE) cout << endl <<"---------------------- Turbomachinery Preprocessing ---------------------" << endl; @@ -342,7 +342,7 @@ void CDriver::InitializeContainers(){ void CDriver::Finalize() { - const bool wrt_perf = config_container[selected_iZone]->GetWrt_Performance(); + const bool wrt_perf = config_container[ZONE_0]->GetWrt_Performance(); /*--- Output some information to the console. ---*/ @@ -350,10 +350,10 @@ void CDriver::Finalize() { /*--- Print out the number of non-physical points and reconstructions ---*/ - if (config_container[selected_iZone]->GetNonphysical_Points() > 0) - cout << "Warning: there are " << config_container[selected_iZone]->GetNonphysical_Points() << " non-physical points in the solution." << endl; - if (config_container[selected_iZone]->GetNonphysical_Reconstr() > 0) - cout << "Warning: " << config_container[selected_iZone]->GetNonphysical_Reconstr() << " reconstructed states for upwinding are non-physical." << endl; + if (config_container[ZONE_0]->GetNonphysical_Points() > 0) + cout << "Warning: there are " << config_container[ZONE_0]->GetNonphysical_Points() << " non-physical points in the solution." << endl; + if (config_container[ZONE_0]->GetNonphysical_Reconstr() > 0) + cout << "Warning: " << config_container[ZONE_0]->GetNonphysical_Reconstr() << " reconstructed states for upwinding are non-physical." << endl; } if (rank == MASTER_NODE) @@ -456,8 +456,8 @@ void CDriver::Finalize() { // Note that for now this is called only by a single thread, but all // necessary variables have been made thread private for safety (tick/tock)!! - config_container[selected_iZone]->SetProfilingCSV(); - config_container[selected_iZone]->GEMMProfilingCSV(); + config_container[ZONE_0]->SetProfilingCSV(); + config_container[ZONE_0]->GEMMProfilingCSV(); /*--- Deallocate config container ---*/ if (config_container!= nullptr) { @@ -585,14 +585,14 @@ void CDriver::PreprocessInput(CConfig **&config, CConfig *&driver_config) { /*--- Keep a reference to the main (ZONE 0) config. ---*/ - main_config = config_container[selected_iZone]; + main_config = config_container[ZONE_0]; /*--- Determine whether or not the FEM solver is used, which decides the type of * geometry classes that are instantiated. Only adapted for single-zone problems ---*/ - fem_solver = config_container[selected_iZone]->GetFEMSolver(); + fem_solver = config_container[ZONE_0]->GetFEMSolver(); - fsi = config_container[selected_iZone]->GetFSI_Simulation(); + fsi = config_container[ZONE_0]->GetFSI_Simulation(); } void CDriver::InitializeGeometry(CConfig* config, CGeometry **&geometry, bool dummy){ @@ -693,7 +693,7 @@ void CDriver::InitializeGeometry(CConfig* config, CGeometry **&geometry, bool du /*--- Keep a reference to the main (ZONE_0, INST_0, MESH_0) geometry. ---*/ - main_geometry = geometry_container[selected_iZone][INST_0][MESH_0]; + main_geometry = geometry_container[ZONE_0][INST_0][MESH_0]; } void CDriver::InitializeGeometryFVM(CConfig *config, CGeometry **&geometry) { @@ -2470,7 +2470,7 @@ void CDriver::InitializeInterface(CConfig **config, CSolver***** solver, CGeomet interface_type = FLOW_TRACTION; auto nConst = 2; bool conservative = config[target]->GetConservativeInterpolation(); - if(!config[selected_iZone]->GetDiscrete_Adjoint()) { + if(!config[ZONE_0]->GetDiscrete_Adjoint()) { interface[donor][target] = new CFlowTractionInterface(nDim, nConst, config[donor], conservative); } else { interface[donor][target] = new CDiscAdjFlowTractionInterface(nDim, nConst, config[donor], conservative); @@ -2570,7 +2570,7 @@ void CDriver::PreprocessStaticMesh(const CConfig *config, CGeometry** geometry){ /*--- Set the grid velocities on all multigrid levels for a steadily rotating reference frame. ---*/ - for (iMGlevel = 0; iMGlevel <= config_container[selected_iZone]->GetnMGLevels(); iMGlevel++){ + for (iMGlevel = 0; iMGlevel <= config_container[ZONE_0]->GetnMGLevels(); iMGlevel++){ geometry[iMGlevel]->SetRotationalVelocity(config, true); geometry[iMGlevel]->SetShroudVelocity(config); } @@ -2588,7 +2588,7 @@ void CDriver::PreprocessStaticMesh(const CConfig *config, CGeometry** geometry){ /*--- Set the translational velocity on all grid levels. ---*/ - for (iMGlevel = 0; iMGlevel <= config_container[selected_iZone]->GetnMGLevels(); iMGlevel++) + for (iMGlevel = 0; iMGlevel <= config_container[ZONE_0]->GetnMGLevels(); iMGlevel++) geometry_container[iZone][INST_0][iMGlevel]->SetTranslationalVelocity(config, true); break; @@ -2667,8 +2667,8 @@ void CDriver::PreprocessOutput(CConfig **config, CConfig *driver_config, COutput } /*--- Check for an unsteady restart. Update ExtIter if necessary. ---*/ - if (config_container[selected_iZone]->GetTime_Domain() && config_container[selected_iZone]->GetRestart()) - TimeIter = config_container[selected_iZone]->GetRestart_Iter(); + if (config_container[ZONE_0]->GetTime_Domain() && config_container[ZONE_0]->GetRestart()) + TimeIter = config_container[ZONE_0]->GetRestart_Iter(); } @@ -2678,9 +2678,9 @@ void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, unsigned short donorZone,targetZone, nMarkerInt, iMarkerInt; unsigned short nSpanMax = 0; - bool restart = (config[selected_iZone]->GetRestart() || config[selected_iZone]->GetRestart_Flow()); - mixingplane = config[selected_iZone]->GetBoolMixingPlaneInterface(); - bool discrete_adjoint = config[selected_iZone]->GetDiscrete_Adjoint(); + bool restart = (config[ZONE_0]->GetRestart() || config[ZONE_0]->GetRestart_Flow()); + mixingplane = config[ZONE_0]->GetBoolMixingPlaneInterface(); + bool discrete_adjoint = config[ZONE_0]->GetDiscrete_Adjoint(); su2double areaIn, areaOut, nBlades, flowAngleIn, flowAngleOut; /*--- Create turbovertex structure ---*/ @@ -2694,7 +2694,7 @@ void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, nSpanMax = config[iZone]->GetnSpanWiseSections(); } - config[selected_iZone]->SetnSpan_iZones(config[iZone]->GetnSpanWiseSections(), iZone); + config[ZONE_0]->SetnSpan_iZones(config[iZone]->GetnSpanWiseSections(), iZone); geometry[iZone][INST_0][MESH_0]->SetTurboVertex(config[iZone], iZone, INFLOW, true); geometry[iZone][INST_0][MESH_0]->SetTurboVertex(config[iZone], iZone, OUTFLOW, true); @@ -2737,13 +2737,13 @@ void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, if (rank == MASTER_NODE) cout << "Transfer average geometric quantities to zone 0." << endl; for (iZone = 1; iZone < nZone; iZone++) { - interface[iZone][selected_iZone]->GatherAverageTurboGeoValues(geometry[iZone][INST_0][MESH_0],geometry[selected_iZone][INST_0][MESH_0], iZone); + interface[iZone][ZONE_0]->GatherAverageTurboGeoValues(geometry[iZone][INST_0][MESH_0],geometry[ZONE_0][INST_0][MESH_0], iZone); } /*--- Transfer number of blade to ZONE_0 to correctly compute turbo performance---*/ for (iZone = 1; iZone < nZone; iZone++) { nBlades = config[iZone]->GetnBlades(iZone); - config[selected_iZone]->SetnBlades(iZone, nBlades); + config[ZONE_0]->SetnBlades(iZone, nBlades); } if (rank == MASTER_NODE){ @@ -2809,7 +2809,7 @@ void CDriver::PrintDirectResidual(RECORDING kind_recording) { if (rank != MASTER_NODE || kind_recording != RECORDING::SOLUTION_VARIABLES) return; - const bool multizone = config_container[selected_iZone]->GetMultizone_Problem(); + const bool multizone = config_container[ZONE_0]->GetMultizone_Problem(); /*--- Helper lambda func to return lenghty [iVar][iZone] string. ---*/ auto iVar_iZone2string = [&](unsigned short ivar, unsigned short izone) { @@ -2822,7 +2822,7 @@ void CDriver::PrintDirectResidual(RECORDING kind_recording) { const unsigned short fieldWidth = 15; PrintingToolbox::CTablePrinter RMSTable(&std::cout); - RMSTable.SetPrecision(config_container[selected_iZone]->GetOutput_Precision()); + RMSTable.SetPrecision(config_container[ZONE_0]->GetOutput_Precision()); /*--- The CTablePrinter requires two sweeps: *--- 0. Add the colum names (addVals=0=false) plus CTablePrinter.PrintHeader() @@ -2920,7 +2920,7 @@ void CDriver::PrintDirectResidual(RECORDING kind_recording) { } void CDriver::RampTurbomachineryValues(unsigned long iter) { - auto* config = config_container[selected_iZone]; + auto* config = config_container[ZONE_0]; /*--- ROTATING FRAME Ramp: Compute the updated rotational velocity. ---*/ if (config->GetGrid_Movement() && config->GetRampRotatingFrame()) { @@ -2952,8 +2952,8 @@ void CDriver::RampTurbomachineryValues(unsigned long iter) { } for (auto iZone = 1u; iZone < nZone; iZone++) { - interface_container[iZone][selected_iZone]->GatherAverageTurboGeoValues( - geometry_container[iZone][INST_0][MESH_0], geometry_container[selected_iZone][INST_0][MESH_0], iZone); + interface_container[iZone][ZONE_0]->GatherAverageTurboGeoValues( + geometry_container[iZone][INST_0][MESH_0], geometry_container[ZONE_0][INST_0][MESH_0], iZone); } } } @@ -2996,7 +2996,7 @@ void CDriver::RampTurbomachineryValues(unsigned long iter) { } CFluidDriver::CFluidDriver(char* confFile, unsigned short val_nZone, SU2_Comm MPICommunicator) : CDriver(confFile, val_nZone, MPICommunicator, false) { - Max_Iter = config_container[selected_iZone]->GetnInner_Iter(); + Max_Iter = config_container[ZONE_0]->GetnInner_Iter(); } CFluidDriver::~CFluidDriver() = default; @@ -3024,7 +3024,7 @@ void CFluidDriver::StartSolver(){ /*--- For the Disc.Adj. of a case with (rigidly) moving grid, the appropriate mesh cordinates are read from the restart files. ---*/ if (!fem_solver && - !(config_container[selected_iZone]->GetGrid_Movement() && config_container[selected_iZone]->GetDiscrete_Adjoint())) { + !(config_container[ZONE_0]->GetGrid_Movement() && config_container[ZONE_0]->GetDiscrete_Adjoint())) { DynamicMeshUpdate(Iter); } @@ -3037,7 +3037,7 @@ void CFluidDriver::StartSolver(){ Update(); /*--- Terminate the simulation if only the Jacobian must be computed. ---*/ - if (config_container[selected_iZone]->GetJacobian_Spatial_Discretization_Only()) break; + if (config_container[ZONE_0]->GetJacobian_Spatial_Discretization_Only()) break; /*--- Monitor the computations after each iteration. ---*/ @@ -3231,7 +3231,7 @@ CHBDriver::CHBDriver(char* confFile, MPICommunicator) { unsigned short kInst; - nInstHB = nInst[selected_iZone]; + nInstHB = nInst[ZONE_0]; /*--- allocate dynamic memory for the Harmonic Balance operator ---*/ D = new su2double*[nInstHB]; @@ -3254,17 +3254,17 @@ void CHBDriver::Run() { all zones before beginning the iteration. ---*/ for (iInst = 0; iInst < nInstHB; iInst++) - iteration_container[selected_iZone][iInst]->Preprocess(output_container[selected_iZone], integration_container, geometry_container, + iteration_container[ZONE_0][iInst]->Preprocess(output_container[ZONE_0], integration_container, geometry_container, solver_container, numerics_container, config_container, surface_movement, grid_movement, FFDBox, ZONE_0, iInst); for (iInst = 0; iInst < nInstHB; iInst++) - iteration_container[selected_iZone][iInst]->Iterate(output_container[selected_iZone], integration_container, geometry_container, + iteration_container[ZONE_0][iInst]->Iterate(output_container[ZONE_0], integration_container, geometry_container, solver_container, numerics_container, config_container, surface_movement, grid_movement, FFDBox, ZONE_0, iInst); for (iInst = 0; iInst < nInstHB; iInst++) - iteration_container[selected_iZone][iInst]->Monitor(output_container[selected_iZone], integration_container, geometry_container, + iteration_container[ZONE_0][iInst]->Monitor(output_container[ZONE_0], integration_container, geometry_container, solver_container, numerics_container, config_container, surface_movement, grid_movement, FFDBox, ZONE_0, iInst); @@ -3279,7 +3279,7 @@ void CHBDriver::Update() { } /*--- Precondition the harmonic balance source terms ---*/ - if (config_container[selected_iZone]->GetHB_Precondition() == YES) { + if (config_container[ZONE_0]->GetHB_Precondition() == YES) { StabilizeHarmonicBalance(); } @@ -3287,7 +3287,7 @@ void CHBDriver::Update() { for (iInst = 0; iInst < nInstHB; iInst++) { /*--- Update the harmonic balance terms across all zones ---*/ - iteration_container[selected_iZone][iInst]->Update(output_container[selected_iZone], integration_container, geometry_container, + iteration_container[ZONE_0][iInst]->Update(output_container[ZONE_0], integration_container, geometry_container, solver_container, numerics_container, config_container, surface_movement, grid_movement, FFDBox, ZONE_0, iInst); @@ -3298,15 +3298,15 @@ void CHBDriver::Update() { void CHBDriver::SetHarmonicBalance(unsigned short iInst) { unsigned short iVar, jInst, iMGlevel; - unsigned short nVar = solver_container[selected_iZone][INST_0][MESH_0][FLOW_SOL]->GetnVar(); + unsigned short nVar = solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->GetnVar(); unsigned long iPoint; - bool implicit = (config_container[selected_iZone]->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - bool adjoint = (config_container[selected_iZone]->GetContinuous_Adjoint()); + bool implicit = (config_container[ZONE_0]->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + bool adjoint = (config_container[ZONE_0]->GetContinuous_Adjoint()); if (adjoint) { - implicit = (config_container[selected_iZone]->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); + implicit = (config_container[ZONE_0]->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); } - unsigned long InnerIter = config_container[selected_iZone]->GetInnerIter(); + unsigned long InnerIter = config_container[ZONE_0]->GetInnerIter(); /*--- Retrieve values from the config file ---*/ auto *U = new su2double[nVar]; @@ -3317,20 +3317,20 @@ void CHBDriver::SetHarmonicBalance(unsigned short iInst) { su2double deltaU, deltaPsi; /*--- Compute period of oscillation ---*/ - su2double period = config_container[selected_iZone]->GetHarmonicBalance_Period(); + su2double period = config_container[ZONE_0]->GetHarmonicBalance_Period(); /*--- Non-dimensionalize the input period, if necessary. */ - period /= config_container[selected_iZone]->GetTime_Ref(); + period /= config_container[ZONE_0]->GetTime_Ref(); if (InnerIter == 0) ComputeHBOperator(); /*--- Compute various source terms for explicit direct, implicit direct, and adjoint problems ---*/ /*--- Loop over all grid levels ---*/ - for (iMGlevel = 0; iMGlevel <= config_container[selected_iZone]->GetnMGLevels(); iMGlevel++) { + for (iMGlevel = 0; iMGlevel <= config_container[ZONE_0]->GetnMGLevels(); iMGlevel++) { /*--- Loop over each node in the volume mesh ---*/ - for (iPoint = 0; iPoint < geometry_container[selected_iZone][iInst][iMGlevel]->GetnPoint(); iPoint++) { + for (iPoint = 0; iPoint < geometry_container[ZONE_0][iInst][iMGlevel]->GetnPoint(); iPoint++) { for (iVar = 0; iVar < nVar; iVar++) { Source[iVar] = 0.0; @@ -3343,11 +3343,11 @@ void CHBDriver::SetHarmonicBalance(unsigned short iInst) { for (iVar = 0; iVar < nVar; iVar++) { if (!adjoint) { - U[iVar] = solver_container[selected_iZone][jInst][iMGlevel][FLOW_SOL]->GetNodes()->GetSolution(iPoint, iVar); + U[iVar] = solver_container[ZONE_0][jInst][iMGlevel][FLOW_SOL]->GetNodes()->GetSolution(iPoint, iVar); Source[iVar] += U[iVar]*D[iInst][jInst]; if (implicit) { - U_old[iVar] = solver_container[selected_iZone][jInst][iMGlevel][FLOW_SOL]->GetNodes()->GetSolution_Old(iPoint, iVar); + U_old[iVar] = solver_container[ZONE_0][jInst][iMGlevel][FLOW_SOL]->GetNodes()->GetSolution_Old(iPoint, iVar); deltaU = U[iVar] - U_old[iVar]; Source[iVar] += deltaU*D[iInst][jInst]; } @@ -3355,11 +3355,11 @@ void CHBDriver::SetHarmonicBalance(unsigned short iInst) { } else { - Psi[iVar] = solver_container[selected_iZone][jInst][iMGlevel][ADJFLOW_SOL]->GetNodes()->GetSolution(iPoint, iVar); + Psi[iVar] = solver_container[ZONE_0][jInst][iMGlevel][ADJFLOW_SOL]->GetNodes()->GetSolution(iPoint, iVar); Source[iVar] += Psi[iVar]*D[jInst][iInst]; if (implicit) { - Psi_old[iVar] = solver_container[selected_iZone][jInst][iMGlevel][ADJFLOW_SOL]->GetNodes()->GetSolution_Old(iPoint, iVar); + Psi_old[iVar] = solver_container[ZONE_0][jInst][iMGlevel][ADJFLOW_SOL]->GetNodes()->GetSolution_Old(iPoint, iVar); deltaPsi = Psi[iVar] - Psi_old[iVar]; Source[iVar] += deltaPsi*D[jInst][iInst]; } @@ -3369,10 +3369,10 @@ void CHBDriver::SetHarmonicBalance(unsigned short iInst) { /*--- Store sources for current row ---*/ for (iVar = 0; iVar < nVar; iVar++) { if (!adjoint) { - solver_container[selected_iZone][iInst][iMGlevel][FLOW_SOL]->GetNodes()->SetHarmonicBalance_Source(iPoint, iVar, Source[iVar]); + solver_container[ZONE_0][iInst][iMGlevel][FLOW_SOL]->GetNodes()->SetHarmonicBalance_Source(iPoint, iVar, Source[iVar]); } else { - solver_container[selected_iZone][iInst][iMGlevel][ADJFLOW_SOL]->GetNodes()->SetHarmonicBalance_Source(iPoint, iVar, Source[iVar]); + solver_container[ZONE_0][iInst][iMGlevel][ADJFLOW_SOL]->GetNodes()->SetHarmonicBalance_Source(iPoint, iVar, Source[iVar]); } } @@ -3381,29 +3381,29 @@ void CHBDriver::SetHarmonicBalance(unsigned short iInst) { } /*--- Source term for a turbulence model ---*/ - if (config_container[selected_iZone]->GetKind_Solver() == MAIN_SOLVER::RANS) { + if (config_container[ZONE_0]->GetKind_Solver() == MAIN_SOLVER::RANS) { /*--- Extra variables needed if we have a turbulence model. ---*/ - unsigned short nVar_Turb = solver_container[selected_iZone][INST_0][MESH_0][TURB_SOL]->GetnVar(); + unsigned short nVar_Turb = solver_container[ZONE_0][INST_0][MESH_0][TURB_SOL]->GetnVar(); auto *U_Turb = new su2double[nVar_Turb]; auto *Source_Turb = new su2double[nVar_Turb]; /*--- Loop over only the finest mesh level (turbulence is always solved on the original grid only). ---*/ - for (iPoint = 0; iPoint < geometry_container[selected_iZone][INST_0][MESH_0]->GetnPoint(); iPoint++) { + for (iPoint = 0; iPoint < geometry_container[ZONE_0][INST_0][MESH_0]->GetnPoint(); iPoint++) { for (iVar = 0; iVar < nVar_Turb; iVar++) Source_Turb[iVar] = 0.0; for (jInst = 0; jInst < nInstHB; jInst++) { /*--- Retrieve solution at this node in current zone ---*/ for (iVar = 0; iVar < nVar_Turb; iVar++) { - U_Turb[iVar] = solver_container[selected_iZone][jInst][MESH_0][TURB_SOL]->GetNodes()->GetSolution(iPoint, iVar); + U_Turb[iVar] = solver_container[ZONE_0][jInst][MESH_0][TURB_SOL]->GetNodes()->GetSolution(iPoint, iVar); Source_Turb[iVar] += U_Turb[iVar]*D[iInst][jInst]; } } /*--- Store sources for current iZone ---*/ for (iVar = 0; iVar < nVar_Turb; iVar++) - solver_container[selected_iZone][iInst][MESH_0][TURB_SOL]->GetNodes()->SetHarmonicBalance_Source(iPoint, iVar, Source_Turb[iVar]); + solver_container[ZONE_0][iInst][MESH_0][TURB_SOL]->GetNodes()->SetHarmonicBalance_Source(iPoint, iVar, Source_Turb[iVar]); } delete [] U_Turb; @@ -3421,9 +3421,9 @@ void CHBDriver::SetHarmonicBalance(unsigned short iInst) { void CHBDriver::StabilizeHarmonicBalance() { unsigned short i, j, k, iVar, iInst, jInst, iMGlevel; - unsigned short nVar = solver_container[selected_iZone][INST_0][MESH_0][FLOW_SOL]->GetnVar(); + unsigned short nVar = solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->GetnVar(); unsigned long iPoint; - bool adjoint = (config_container[selected_iZone]->GetContinuous_Adjoint()); + bool adjoint = (config_container[ZONE_0]->GetContinuous_Adjoint()); /*--- Retrieve values from the config file ---*/ auto *Source = new su2double[nInstHB]; @@ -3438,13 +3438,13 @@ void CHBDriver::StabilizeHarmonicBalance() { } /*--- Loop over all grid levels ---*/ - for (iMGlevel = 0; iMGlevel <= config_container[selected_iZone]->GetnMGLevels(); iMGlevel++) { + for (iMGlevel = 0; iMGlevel <= config_container[ZONE_0]->GetnMGLevels(); iMGlevel++) { /*--- Loop over each node in the volume mesh ---*/ - for (iPoint = 0; iPoint < geometry_container[selected_iZone][INST_0][iMGlevel]->GetnPoint(); iPoint++) { + for (iPoint = 0; iPoint < geometry_container[ZONE_0][INST_0][iMGlevel]->GetnPoint(); iPoint++) { /*--- Get time step for current node ---*/ - Delta = solver_container[selected_iZone][INST_0][iMGlevel][FLOW_SOL]->GetNodes()->GetDelta_Time(iPoint); + Delta = solver_container[ZONE_0][INST_0][iMGlevel][FLOW_SOL]->GetNodes()->GetDelta_Time(iPoint); /*--- Setup stabilization matrix for this node ---*/ for (iInst = 0; iInst < nInstHB; iInst++) { @@ -3543,7 +3543,7 @@ void CHBDriver::StabilizeHarmonicBalance() { /*--- Get current source terms (not yet preconditioned) and zero source array to prepare preconditioning ---*/ for (iInst = 0; iInst < nInstHB; iInst++) { - Source_old[iInst] = solver_container[selected_iZone][iInst][iMGlevel][FLOW_SOL]->GetNodes()->GetHarmonicBalance_Source(iPoint, iVar); + Source_old[iInst] = solver_container[ZONE_0][iInst][iMGlevel][FLOW_SOL]->GetNodes()->GetHarmonicBalance_Source(iPoint, iVar); Source[iInst] = 0; } @@ -3555,10 +3555,10 @@ void CHBDriver::StabilizeHarmonicBalance() { /*--- Store updated source terms for current node ---*/ if (!adjoint) { - solver_container[selected_iZone][iInst][iMGlevel][FLOW_SOL]->GetNodes()->SetHarmonicBalance_Source(iPoint, iVar, Source[iInst]); + solver_container[ZONE_0][iInst][iMGlevel][FLOW_SOL]->GetNodes()->SetHarmonicBalance_Source(iPoint, iVar, Source[iInst]); } else { - solver_container[selected_iZone][iInst][iMGlevel][ADJFLOW_SOL]->GetNodes()->SetHarmonicBalance_Source(iPoint, iVar, Source[iInst]); + solver_container[ZONE_0][iInst][iMGlevel][ADJFLOW_SOL]->GetNodes()->SetHarmonicBalance_Source(iPoint, iVar, Source[iInst]); } } @@ -3594,15 +3594,15 @@ void CHBDriver::ComputeHBOperator() { } /*--- Get simualation period from config file ---*/ - su2double Period = config_container[selected_iZone]->GetHarmonicBalance_Period(); + su2double Period = config_container[ZONE_0]->GetHarmonicBalance_Period(); /*--- Non-dimensionalize the input period, if necessary. */ - Period /= config_container[selected_iZone]->GetTime_Ref(); + Period /= config_container[ZONE_0]->GetTime_Ref(); /*--- Build the array containing the selected frequencies to solve ---*/ for (iInst = 0; iInst < nInstHB; iInst++) { - Omega_HB[iInst] = config_container[selected_iZone]->GetOmega_HB()[iInst]; - Omega_HB[iInst] /= config_container[selected_iZone]->GetOmega_Ref(); //TODO: check + Omega_HB[iInst] = config_container[ZONE_0]->GetOmega_HB()[iInst]; + Omega_HB[iInst] /= config_container[ZONE_0]->GetOmega_Ref(); //TODO: check } /*--- Build the diagonal matrix of the frequencies DD ---*/ diff --git a/SU2_CFD/src/drivers/CMultizoneDriver.cpp b/SU2_CFD/src/drivers/CMultizoneDriver.cpp index 9c8039db7824..61f59223fcfe 100644 --- a/SU2_CFD/src/drivers/CMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CMultizoneDriver.cpp @@ -248,7 +248,7 @@ void CMultizoneDriver::Preprocess(unsigned long TimeIter) { } /*--- Ramp turbo values for unsteady problems here, otherwise do it over outer iterations. ---*/ - if (config_container[selected_iZone]->GetTime_Domain()) { + if (config_container[ZONE_0]->GetTime_Domain()) { RampTurbomachineryValues(TimeIter); } @@ -294,7 +294,7 @@ void CMultizoneDriver::RunGaussSeidel() { for (auto iOuter_Iter = 0ul; iOuter_Iter < driver_config->GetnOuter_Iter(); iOuter_Iter++) { /*--- Ramp turbo values for steady problems here, otherwise do it over time steps. ---*/ - if (!config_container[selected_iZone]->GetTime_Domain()) { + if (!config_container[ZONE_0]->GetTime_Domain()) { RampTurbomachineryValues(iOuter_Iter); } @@ -352,7 +352,7 @@ void CMultizoneDriver::RunJacobi() { for (auto iOuter_Iter = 0ul; iOuter_Iter < driver_config->GetnOuter_Iter(); iOuter_Iter++){ /*--- Ramp turbo values for steady problems here, otherwise do it over time steps. ---*/ - if (!config_container[selected_iZone]->GetTime_Domain()) { + if (!config_container[ZONE_0]->GetTime_Domain()) { RampTurbomachineryValues(iOuter_Iter); } @@ -407,7 +407,7 @@ void CMultizoneDriver::RunJacobi() { void CMultizoneDriver::Corrector(unsigned short val_iZone) { if (config_container[val_iZone]->GetRelaxation()) - iteration_container[val_iZone][INST_0]->Relaxation(output_container[selected_iZone], integration_container, + iteration_container[val_iZone][INST_0]->Relaxation(output_container[ZONE_0], integration_container, geometry_container, solver_container, numerics_container, config_container, surface_movement, grid_movement, FFDBox, val_iZone, INST_0); } @@ -493,7 +493,7 @@ void CMultizoneDriver::Output(unsigned long TimeIter) { UsedTimeOutput += StopTime-StartTime; OutputCount++; - BandwidthSum = config_container[selected_iZone]->GetRestart_Bandwidth_Agg(); + BandwidthSum = config_container[ZONE_0]->GetRestart_Bandwidth_Agg(); StartTime = SU2_MPI::Wtime(); @@ -632,8 +632,8 @@ void CMultizoneDriver::SetMixingPlane(unsigned short donorZone) { void CMultizoneDriver::SetTurboPerformance() { for (auto donorZone = 1u; donorZone < nZone; donorZone++) { - interface_container[donorZone][selected_iZone]->GatherAverageValues(solver_container[donorZone][INST_0][MESH_0][FLOW_SOL], - solver_container[selected_iZone][INST_0][MESH_0][FLOW_SOL], + interface_container[donorZone][ZONE_0]->GatherAverageValues(solver_container[donorZone][INST_0][MESH_0][FLOW_SOL], + solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL], donorZone); } } @@ -688,5 +688,5 @@ bool CMultizoneDriver::Monitor(unsigned long TimeIter){ } bool CMultizoneDriver::GetTimeConvergence() const{ - return output_container[selected_iZone]->GetCauchyCorrectedTimeConvergence(config_container[selected_iZone]); + return output_container[ZONE_0]->GetCauchyCorrectedTimeConvergence(config_container[ZONE_0]); } From b83b4bb487a8ee8a7dcdf9e4c23177b3281e8537 Mon Sep 17 00:00:00 2001 From: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> Date: Sun, 14 May 2023 18:26:42 -0700 Subject: [PATCH 3/3] Apply suggestions from code review --- SU2_CFD/include/drivers/CDriverBase.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SU2_CFD/include/drivers/CDriverBase.hpp b/SU2_CFD/include/drivers/CDriverBase.hpp index 00ccb3d29b59..9625c83d74d8 100644 --- a/SU2_CFD/include/drivers/CDriverBase.hpp +++ b/SU2_CFD/include/drivers/CDriverBase.hpp @@ -54,7 +54,7 @@ class CDriverBase { UsedTime; /*!< \brief Elapsed time between Start and Stop point of the timer. */ unsigned long TimeIter; - unsigned long selected_iZone = ZONE_0; /*!< \brief Selected zone for the driver. Defaults to ZONE_0 */ + unsigned short selected_iZone = ZONE_0; /*!< \brief Selected zone for the driver. Defaults to ZONE_0 */ unsigned short iMesh, /*!< \brief Iterator on mesh levels. */ iZone, /*!< \brief Iterator on zones. */ nZone, /*!< \brief Total number of zones in the problem. */ @@ -530,12 +530,12 @@ class CDriverBase { main_geometry->SetCustomBoundaryHeatFlux(iMarker, iVertex, WallHeatFlux); } - /*! * \brief Selects zone to be used for Driver operation * \param[in] iZone - Zone identifier. */ - inline void SelectZone(unsigned long iZone) { + inline void SelectZone(unsigned short iZone) { + if (iZone >= nZone) SU2_MPI::Error("Zone index out of range", CURRENT_FUNCTION); selected_iZone = iZone; main_geometry = geometry_container[selected_iZone][INST_0][MESH_0]; main_config = config_container[selected_iZone];