Skip to content

Commit

Permalink
Merge pull request #2320 from su2code/fix_turbo_ramps
Browse files Browse the repository at this point in the history
Fixes to turbo monitor
  • Loading branch information
joshkellyjak authored Jul 11, 2024
2 parents bbdc457 + c90780b commit dc4c70f
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 49 deletions.
2 changes: 1 addition & 1 deletion Common/include/CConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5133,7 +5133,7 @@ class CConfig {
/*!
* \brief Set Monitor Outlet Pressure value for the ramp.
*/
void SetMonitotOutletPressure(su2double newMonPres) { MonitorOutletPressure = newMonPres;}
void SetMonitorOutletPressure(su2double newMonPres) { MonitorOutletPressure = newMonPres;}

/*!
* \brief Get Outlet Pressure Ramp option.
Expand Down
6 changes: 5 additions & 1 deletion SU2_CFD/include/iteration/CFluidIteration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,12 @@ class CFluidIteration : public CIteration {

/*!
* \brief Monitors turbo computation (pressure and turbo ramps).
* \param[in] geometry_container - Geometrical definition of the problem
* \param[in] config_container - Defintion of the particular problem
* \param[in] ExtIter - The current iteration of the problem
* \param[in] iZone - The current zone
*/
void TurboMonitor(CGeometry**** geometry_container, CConfig** config_container, unsigned long ExtIter);
void TurboMonitor(CGeometry**** geometry_container, CConfig** config_container, unsigned long ExtIter, unsigned short iZone);

/*!
* \brief Computes turboperformance.
Expand Down
83 changes: 37 additions & 46 deletions SU2_CFD/src/iteration/CFluidIteration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ bool CFluidIteration::Monitor(COutput* output, CIntegration**** integration, CGe
config[val_iZone]->GetInnerIter(), val_iInst);
}

TurboMonitor(geometry, config, config[val_iZone]->GetInnerIter());
TurboMonitor(geometry, config, config[val_iZone]->GetInnerIter(), val_iZone);
}
output->SetHistoryOutput(geometry[val_iZone][val_iInst][MESH_0], solver[val_iZone][val_iInst][MESH_0],
config[val_iZone], config[val_iZone]->GetTimeIter(), config[val_iZone]->GetOuterIter(),
Expand All @@ -251,45 +251,38 @@ bool CFluidIteration::Monitor(COutput* output, CIntegration**** integration, CGe
return StopCalc;
}

void CFluidIteration::TurboMonitor(CGeometry**** geometry_container, CConfig** config_container, unsigned long iter) {

auto* config = config_container[ZONE_0];
void CFluidIteration::TurboMonitor(CGeometry**** geometry_container, CConfig** config_container, unsigned long iter, unsigned short iZone) {
auto* config = config_container[iZone];

if (config_container[ZONE_0]->GetMultizone_Problem())
iter = config_container[ZONE_0]->GetOuterIter();


/*--- ROTATING FRAME Ramp: Compute the updated rotational velocity. ---*/
if (config->GetGrid_Movement() && config->GetRampRotatingFrame()) {
const unsigned long rampFreq = SU2_TYPE::Int(config->GetRampRotatingFrame_Coeff(1));
const unsigned long finalRamp_Iter = SU2_TYPE::Int(config->GetRampRotatingFrame_Coeff(2));
const su2double rot_z_ini = config->GetRampRotatingFrame_Coeff(0);
const bool print = false;
const bool print = (config->GetComm_Level() == COMM_FULL);

if(iter % rampFreq == 0 && iter <= finalRamp_Iter){

for (auto iZone = 0u; iZone < nZone; iZone++) {
const su2double rot_z_final = config_container[iZone]->GetFinalRotation_Rate_Z();
const su2double rot_z_final = config->GetFinalRotation_Rate_Z();

if (fabs(rot_z_final) > 0.0) {
const su2double rot_z = rot_z_ini + iter * ( rot_z_final - rot_z_ini) / finalRamp_Iter;
config_container[iZone]->SetRotation_Rate(2, rot_z);
if (rank == MASTER_NODE && print && iter > 0) {
cout << "\nUpdated rotating frame grid velocities for zone " << iZone << ".\n";
}
geometry_container[iZone][INST_0][MESH_0]->SetRotationalVelocity(config_container[iZone], print);
geometry_container[iZone][INST_0][MESH_0]->SetShroudVelocity(config_container[iZone]);
if (fabs(rot_z_final) > 0.0) {
const su2double rot_z = rot_z_ini + iter * ( rot_z_final - rot_z_ini) / finalRamp_Iter;
config->SetRotation_Rate(2, rot_z);
if (rank == MASTER_NODE && iter > 0) {
cout << "\nUpdated rotating frame grid velocities for zone " << iZone << ".\n";
}
geometry_container[iZone][INST_0][MESH_0]->SetRotationalVelocity(config, print);
geometry_container[iZone][INST_0][MESH_0]->SetShroudVelocity(config);
}

for (auto iZone = 0u; iZone < nZone; iZone++) {
geometry_container[iZone][INST_0][MESH_0]->SetAvgTurboValue(config_container[iZone], iZone, INFLOW, false);
geometry_container[iZone][INST_0][MESH_0]->SetAvgTurboValue(config_container[iZone],iZone, OUTFLOW, false);
geometry_container[iZone][INST_0][MESH_0]->GatherInOutAverageValues(config_container[iZone], false);
}
geometry_container[iZone][INST_0][MESH_0]->SetAvgTurboValue(config, iZone, INFLOW, false);
geometry_container[iZone][INST_0][MESH_0]->SetAvgTurboValue(config, iZone, OUTFLOW, false);
geometry_container[iZone][INST_0][MESH_0]->GatherInOutAverageValues(config, false);

for (auto iZone = 0; iZone < nZone-1; iZone++) {
geometry_container[nZone-1][INST_0][MESH_0]->SetAvgTurboGeoValues(config_container[iZone],geometry_container[iZone][INST_0][MESH_0], iZone);
if (iZone < nZone - 1) {
geometry_container[nZone-1][INST_0][MESH_0]->SetAvgTurboGeoValues(config ,geometry_container[iZone][INST_0][MESH_0], iZone);
}
}
}
Expand All @@ -303,28 +296,26 @@ void CFluidIteration::TurboMonitor(CGeometry**** geometry_container, CConfig** c

if (iter % rampFreq == 0 && iter <= finalRamp_Iter) {
const su2double outPres = outPres_ini + iter * (outPres_final - outPres_ini) / finalRamp_Iter;
if (rank == MASTER_NODE) config->SetMonitotOutletPressure(outPres);

for (auto iZone = 0u; iZone < nZone; iZone++) {
for (auto iMarker = 0; iMarker < config_container[iZone]->GetnMarker_All(); iMarker++) {
const auto KindBC = config_container[iZone]->GetMarker_All_KindBC(iMarker);
const auto Marker_Tag = config_container[iZone]->GetMarker_All_TagBound(iMarker);
unsigned short KindBCOption;
switch (KindBC) {
case RIEMANN_BOUNDARY:
KindBCOption = config_container[iZone]->GetKind_Data_Riemann(Marker_Tag);
if (KindBCOption == STATIC_PRESSURE || KindBCOption == RADIAL_EQUILIBRIUM) {
SU2_MPI::Error("Outlet pressure ramp only implemented for NRBC", CURRENT_FUNCTION);
}
break;
case GILES_BOUNDARY:
KindBCOption = config_container[iZone]->GetKind_Data_Giles(Marker_Tag);
if (KindBCOption == STATIC_PRESSURE || KindBCOption == STATIC_PRESSURE_1D ||
KindBCOption == RADIAL_EQUILIBRIUM ) {
config_container[iZone]->SetGiles_Var1(outPres, Marker_Tag);
}
break;
}
if (rank == MASTER_NODE) config->SetMonitorOutletPressure(outPres);

for (auto iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) {
const auto KindBC = config->GetMarker_All_KindBC(iMarker);
const auto Marker_Tag = config->GetMarker_All_TagBound(iMarker);
unsigned short KindBCOption;
switch (KindBC) {
case RIEMANN_BOUNDARY:
KindBCOption = config->GetKind_Data_Riemann(Marker_Tag);
if (KindBCOption == STATIC_PRESSURE || KindBCOption == RADIAL_EQUILIBRIUM) {
SU2_MPI::Error("Outlet pressure ramp only implemented for NRBC", CURRENT_FUNCTION);
}
break;
case GILES_BOUNDARY:
KindBCOption = config->GetKind_Data_Giles(Marker_Tag);
if (KindBCOption == STATIC_PRESSURE || KindBCOption == STATIC_PRESSURE_1D ||
KindBCOption == RADIAL_EQUILIBRIUM ) {
config->SetGiles_Var1(outPres, Marker_Tag);
}
break;
}
}
}
Expand Down
1 change: 0 additions & 1 deletion SU2_CFD/src/output/COutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ void COutput::SetHistoryOutput(CGeometry ****geometry, CSolver *****solver, CCon
if (rank == MASTER_NODE){
LoadTurboHistoryData(TurboStagePerf, TurboPerf, config[val_iZone]);
}
SetHistoryOutput(geometry[val_iZone][val_iInst][MESH_0], solver[val_iZone][val_iInst][MESH_0], config[val_iZone], TimeIter, OuterIter,InnerIter);

}

Expand Down

0 comments on commit dc4c70f

Please sign in to comment.