Skip to content

Commit 5b12ac7

Browse files
authored
Merge pull request #1544 from su2code/fix_unsteady_wall_time
Fix WALL_TIME for unsteady + some variable index cleanup
2 parents 728bfdc + e1c43b5 commit 5b12ac7

5 files changed

Lines changed: 66 additions & 72 deletions

File tree

SU2_CFD/include/output/COutput.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -720,15 +720,14 @@ class COutput {
720720

721721
/*!
722722
* \brief Set the history fields common for all solvers.
723-
* \param[in] config - Definition of the particular problem.
724723
*/
725-
void SetCommonHistoryFields(CConfig *config);
724+
void SetCommonHistoryFields();
726725

727726
/*!
728727
* \brief Load values of the history fields common for all solvers.
729728
* \param[in] config - Definition of the particular problem.
730729
*/
731-
void LoadCommonHistoryData(CConfig *config);
730+
void LoadCommonHistoryData(const CConfig *config);
732731

733732
/*!
734733
* \brief Allocates the data sorters if necessary.

SU2_CFD/src/drivers/CSinglezoneDriver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,9 @@ void CSinglezoneDriver::Output(unsigned long TimeIter) {
213213
BandwidthSum = config_container[ZONE_0]->GetRestart_Bandwidth_Agg();
214214

215215
StartTime = SU2_MPI::Wtime();
216-
217-
config_container[ZONE_0]->Set_StartTime(StartTime);
218216
}
217+
218+
config_container[ZONE_0]->Set_StartTime(StartTime);
219219
}
220220

221221
void CSinglezoneDriver::DynamicMeshUpdate(unsigned long TimeIter) {

SU2_CFD/src/output/COutput.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,7 +1314,7 @@ void COutput::PreprocessHistoryOutput(CConfig *config, bool wrt){
13141314

13151315
/*--- Set the common output fields ---*/
13161316

1317-
SetCommonHistoryFields(config);
1317+
SetCommonHistoryFields();
13181318

13191319
/*--- Set the History output fields using a virtual function call to the child implementation ---*/
13201320

@@ -1361,7 +1361,7 @@ void COutput::PreprocessMultizoneHistoryOutput(COutput **output, CConfig **confi
13611361

13621362
/*--- Set the common history fields for all solvers ---*/
13631363

1364-
SetCommonHistoryFields(driver_config);
1364+
SetCommonHistoryFields();
13651365

13661366
/*--- Set the History output fields using a virtual function call to the child implementation ---*/
13671367

@@ -2157,15 +2157,15 @@ bool COutput::WriteVolume_Output(CConfig *config, unsigned long Iter, bool force
21572157
}
21582158
}
21592159

2160-
void COutput::SetCommonHistoryFields(CConfig *config){
2160+
void COutput::SetCommonHistoryFields() {
21612161

21622162
/// BEGIN_GROUP: ITERATION, DESCRIPTION: Iteration identifier.
21632163
/// DESCRIPTION: The time iteration index.
2164-
AddHistoryOutput("TIME_ITER", "Time_Iter", ScreenOutputFormat::INTEGER, "ITER", "Time iteration index");
2164+
AddHistoryOutput("TIME_ITER", "Time_Iter", ScreenOutputFormat::INTEGER, "ITER", "Time iteration index");
21652165
/// DESCRIPTION: The outer iteration index.
2166-
AddHistoryOutput("OUTER_ITER", "Outer_Iter", ScreenOutputFormat::INTEGER, "ITER", "Outer iteration index");
2166+
AddHistoryOutput("OUTER_ITER", "Outer_Iter", ScreenOutputFormat::INTEGER, "ITER", "Outer iteration index");
21672167
/// DESCRIPTION: The inner iteration index.
2168-
AddHistoryOutput("INNER_ITER", "Inner_Iter", ScreenOutputFormat::INTEGER, "ITER", "Inner iteration index");
2168+
AddHistoryOutput("INNER_ITER", "Inner_Iter", ScreenOutputFormat::INTEGER, "ITER", "Inner iteration index");
21692169
/// END_GROUP
21702170

21712171
/// BEGIN_GROUP: TIME_DOMAIN, DESCRIPTION: Time integration information
@@ -2175,13 +2175,13 @@ void COutput::SetCommonHistoryFields(CConfig *config){
21752175
AddHistoryOutput("TIME_STEP", "Time_Step", ScreenOutputFormat::SCIENTIFIC, "TIME_DOMAIN", "Current time step (s)");
21762176

21772177
/// DESCRIPTION: Currently used wall-clock time.
2178-
AddHistoryOutput("WALL_TIME", "Time(sec)", ScreenOutputFormat::SCIENTIFIC, "WALL_TIME", "Average wall-clock time");
2178+
AddHistoryOutput("WALL_TIME", "Time(sec)", ScreenOutputFormat::SCIENTIFIC, "WALL_TIME", "Average wall-clock time since the start of inner iterations.");
21792179

21802180
AddHistoryOutput("NONPHYSICAL_POINTS", "Nonphysical_Points", ScreenOutputFormat::INTEGER, "NONPHYSICAL_POINTS", "The number of non-physical points in the solution");
21812181

21822182
}
21832183

2184-
void COutput::LoadCommonHistoryData(CConfig *config){
2184+
void COutput::LoadCommonHistoryData(const CConfig *config) {
21852185

21862186
SetHistoryOutputValue("TIME_STEP", config->GetDelta_UnstTimeND()*config->GetTime_Ref());
21872187

SU2_CFD/src/solvers/CEulerSolver.cpp

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,16 +1819,17 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain
18191819
cell-average value of the solution. This is a locally 1st order approximation,
18201820
which is typically only active during the start-up of a calculation. ---*/
18211821

1822-
bool neg_pres_or_rho_i = (Primitive_i[nDim+1] < 0.0) || (Primitive_i[nDim+2] < 0.0);
1823-
bool neg_pres_or_rho_j = (Primitive_j[nDim+1] < 0.0) || (Primitive_j[nDim+2] < 0.0);
1822+
bool neg_pres_or_rho_i = (Primitive_i[prim_idx.Pressure()] < 0.0) || (Primitive_i[prim_idx.Density()] < 0.0);
1823+
bool neg_pres_or_rho_j = (Primitive_j[prim_idx.Pressure()] < 0.0) || (Primitive_j[prim_idx.Density()] < 0.0);
18241824

1825-
su2double R = sqrt(fabs(Primitive_j[nDim+2]/Primitive_i[nDim+2]));
1825+
su2double R = sqrt(fabs(Primitive_j[prim_idx.Density()]/Primitive_i[prim_idx.Density()]));
18261826
su2double sq_vel = 0.0;
18271827
for (iDim = 0; iDim < nDim; iDim++) {
1828-
su2double RoeVelocity = (R*Primitive_j[iDim+1]+Primitive_i[iDim+1])/(R+1);
1828+
su2double RoeVelocity = (R * Primitive_j[iDim + prim_idx.Velocity()] +
1829+
Primitive_i[iDim + prim_idx.Velocity()]) / (R+1);
18291830
sq_vel += pow(RoeVelocity, 2);
18301831
}
1831-
su2double RoeEnthalpy = (R*Primitive_j[nDim+3]+Primitive_i[nDim+3])/(R+1);
1832+
su2double RoeEnthalpy = (R * Primitive_j[prim_idx.Enthalpy()] + Primitive_i[prim_idx.Enthalpy()]) / (R+1);
18321833

18331834
bool neg_sound_speed = ((Gamma-1)*(RoeEnthalpy-0.5*sq_vel) < 0.0);
18341835

@@ -1932,19 +1933,16 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain
19321933

19331934
void CEulerSolver::ComputeConsistentExtrapolation(CFluidModel *fluidModel, unsigned short nDim,
19341935
su2double *primitive, su2double *secondary) {
1935-
1936-
su2double density = primitive[nDim+2];
1937-
su2double pressure = primitive[nDim+1];
1938-
1939-
su2double velocity2 = 0.0;
1940-
for (unsigned short iDim = 0; iDim < nDim; iDim++)
1941-
velocity2 += pow(primitive[iDim+1], 2);
1936+
const CEulerVariable::CIndices<unsigned short> prim_idx(nDim, 0);
1937+
const su2double density = primitive[prim_idx.Density()];
1938+
const su2double pressure = primitive[prim_idx.Pressure()];
1939+
const su2double velocity2 = GeometryToolbox::SquaredNorm(nDim, &primitive[prim_idx.Velocity()]);
19421940

19431941
fluidModel->SetTDState_Prho(pressure, density);
19441942

1945-
primitive[0] = fluidModel->GetTemperature();
1946-
primitive[nDim+3] = fluidModel->GetStaticEnergy() + primitive[nDim+1]/primitive[nDim+2] + 0.5*velocity2;
1947-
primitive[nDim+4] = fluidModel->GetSoundSpeed();
1943+
primitive[prim_idx.Temperature()] = fluidModel->GetTemperature();
1944+
primitive[prim_idx.Enthalpy()] = fluidModel->GetStaticEnergy() + pressure / density + 0.5*velocity2;
1945+
primitive[prim_idx.SoundSpeed()] = fluidModel->GetSoundSpeed();
19481946
secondary[0] = fluidModel->GetdPdrho_e();
19491947
secondary[1] = fluidModel->GetdPde_rho();
19501948

SU2_CFD/src/solvers/CIncEulerSolver.cpp

Lines changed: 41 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,11 +1226,11 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont
12261226
checked. Pressure is the dynamic pressure (can be negative). ---*/
12271227

12281228
if (config->GetEnergy_Equation()) {
1229-
bool neg_temperature_i = (Primitive_i[nDim+1] < 0.0);
1230-
bool neg_temperature_j = (Primitive_j[nDim+1] < 0.0);
1229+
bool neg_temperature_i = (Primitive_i[prim_idx.Temperature()] < 0.0);
1230+
bool neg_temperature_j = (Primitive_j[prim_idx.Temperature()] < 0.0);
12311231

1232-
bool neg_density_i = (Primitive_i[nDim+2] < 0.0);
1233-
bool neg_density_j = (Primitive_j[nDim+2] < 0.0);
1232+
bool neg_density_i = (Primitive_i[prim_idx.Density()] < 0.0);
1233+
bool neg_density_j = (Primitive_j[prim_idx.Density()] < 0.0);
12341234

12351235
nodes->SetNon_Physical(iPoint, neg_density_i || neg_temperature_i);
12361236
nodes->SetNon_Physical(jPoint, neg_density_j || neg_temperature_j);
@@ -2035,27 +2035,27 @@ void CIncEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_contain
20352035
/*--- Recompute and store the velocity in the primitive variable vector. ---*/
20362036

20372037
for (iDim = 0; iDim < nDim; iDim++)
2038-
V_infty[iDim+1] = GetVelocity_Inf(iDim);
2038+
V_infty[iDim+prim_idx.Velocity()] = GetVelocity_Inf(iDim);
20392039

20402040
/*--- Far-field pressure set to static pressure (0.0). ---*/
20412041

2042-
V_infty[0] = GetPressure_Inf();
2042+
V_infty[prim_idx.Pressure()] = GetPressure_Inf();
20432043

20442044
/*--- Dirichlet condition for temperature at far-field (if energy is active). ---*/
20452045

2046-
V_infty[nDim+1] = GetTemperature_Inf();
2046+
V_infty[prim_idx.Temperature()] = GetTemperature_Inf();
20472047

20482048
/*--- Store the density. ---*/
20492049

2050-
V_infty[nDim+2] = GetDensity_Inf();
2050+
V_infty[prim_idx.Density()] = GetDensity_Inf();
20512051

20522052
/*--- Beta coefficient stored at the node ---*/
20532053

2054-
V_infty[nDim+3] = nodes->GetBetaInc2(iPoint);
2054+
V_infty[prim_idx.Beta()] = nodes->GetBetaInc2(iPoint);
20552055

20562056
/*--- Cp is needed for Temperature equation. ---*/
20572057

2058-
V_infty[nDim+7] = nodes->GetSpecificHeatCp(iPoint);
2058+
V_infty[prim_idx.CpTotal()] = nodes->GetSpecificHeatCp(iPoint);
20592059

20602060
/*--- Set various quantities in the numerics class ---*/
20612061

@@ -2084,9 +2084,9 @@ void CIncEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_contain
20842084

20852085
/*--- Set transport properties at infinity. ---*/
20862086

2087-
V_infty[nDim+4] = nodes->GetLaminarViscosity(iPoint);
2088-
V_infty[nDim+5] = nodes->GetEddyViscosity(iPoint);
2089-
V_infty[nDim+6] = nodes->GetThermalConductivity(iPoint);
2087+
V_infty[prim_idx.LaminarViscosity()] = nodes->GetLaminarViscosity(iPoint);
2088+
V_infty[prim_idx.EddyViscosity()] = nodes->GetEddyViscosity(iPoint);
2089+
V_infty[prim_idx.ThermalConductivity()] = nodes->GetThermalConductivity(iPoint);
20902090

20912091
/*--- Set the normal vector and the coordinates ---*/
20922092

@@ -2185,7 +2185,7 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container,
21852185

21862186
/*--- Neumann condition for dynamic pressure ---*/
21872187

2188-
V_inlet[0] = nodes->GetPressure(iPoint);
2188+
V_inlet[prim_idx.Pressure()] = nodes->GetPressure(iPoint);
21892189

21902190
/*--- The velocity is either prescribed or computed from total pressure. ---*/
21912191

@@ -2202,11 +2202,11 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container,
22022202
/*--- Store the velocity in the primitive variable vector. ---*/
22032203

22042204
for (iDim = 0; iDim < nDim; iDim++)
2205-
V_inlet[iDim+1] = Vel_Mag*UnitFlowDir[iDim];
2205+
V_inlet[iDim+prim_idx.Velocity()] = Vel_Mag*UnitFlowDir[iDim];
22062206

22072207
/*--- Dirichlet condition for temperature (if energy is active) ---*/
22082208

2209-
V_inlet[nDim+1] = Inlet_Ttotal[val_marker][iVertex]/config->GetTemperature_Ref();
2209+
V_inlet[prim_idx.Temperature()] = Inlet_Ttotal[val_marker][iVertex]/config->GetTemperature_Ref();
22102210

22112211
break;
22122212

@@ -2224,10 +2224,7 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container,
22242224

22252225
/*--- Check for back flow through the inlet. ---*/
22262226

2227-
Vn = 0.0;
2228-
for (iDim = 0; iDim < nDim; iDim++) {
2229-
Vn += V_domain[iDim+1]*(-1.0*Normal[iDim]/Area);
2230-
}
2227+
Vn = -GeometryToolbox::DotProduct(nDim, &V_domain[prim_idx.Velocity()], Normal) / Area;
22312228

22322229
/*--- If the local static pressure is larger than the specified
22332230
total pressure or the velocity is directed upstream, we have a
@@ -2239,16 +2236,16 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container,
22392236

22402237
/*--- Back flow: use the prescribed P_total as static pressure. ---*/
22412238

2242-
V_inlet[0] = Inlet_Ptotal[val_marker][iVertex]/config->GetPressure_Ref();
2239+
V_inlet[prim_idx.Pressure()] = Inlet_Ptotal[val_marker][iVertex]/config->GetPressure_Ref();
22432240

22442241
/*--- Neumann condition for velocity. ---*/
22452242

22462243
for (iDim = 0; iDim < nDim; iDim++)
2247-
V_inlet[iDim+1] = V_domain[iDim+1];
2244+
V_inlet[iDim+prim_idx.Velocity()] = V_domain[iDim+prim_idx.Velocity()];
22482245

22492246
/*--- Neumann condition for the temperature. ---*/
22502247

2251-
V_inlet[nDim+1] = nodes->GetTemperature(iPoint);
2248+
V_inlet[prim_idx.Temperature()] = nodes->GetTemperature(iPoint);
22522249

22532250
} else {
22542251

@@ -2267,17 +2264,17 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container,
22672264
/*--- Compute the delta change in velocity in each direction. ---*/
22682265

22692266
for (iDim = 0; iDim < nDim; iDim++)
2270-
dV[iDim] = Vel_Mag*UnitFlowDir[iDim] - V_domain[iDim+1];
2267+
dV[iDim] = Vel_Mag*UnitFlowDir[iDim] - V_domain[iDim+prim_idx.Velocity()];
22712268

22722269
/*--- Update the velocity in the primitive variable vector.
22732270
Note we use damping here to improve stability/convergence. ---*/
22742271

22752272
for (iDim = 0; iDim < nDim; iDim++)
2276-
V_inlet[iDim+1] = V_domain[iDim+1] + Damping*dV[iDim];
2273+
V_inlet[iDim+prim_idx.Velocity()] = V_domain[iDim+prim_idx.Velocity()] + Damping*dV[iDim];
22772274

22782275
/*--- Dirichlet condition for temperature (if energy is active) ---*/
22792276

2280-
V_inlet[nDim+1] = Inlet_Ttotal[val_marker][iVertex]/config->GetTemperature_Ref();
2277+
V_inlet[prim_idx.Temperature()] = Inlet_Ttotal[val_marker][iVertex]/config->GetTemperature_Ref();
22812278

22822279
}
22832280

@@ -2292,15 +2289,15 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container,
22922289
construction, or will be set fixed implicitly by the temperature
22932290
and equation of state. ---*/
22942291

2295-
V_inlet[nDim+2] = nodes->GetDensity(iPoint);
2292+
V_inlet[prim_idx.Density()] = nodes->GetDensity(iPoint);
22962293

22972294
/*--- Beta coefficient from the config file ---*/
22982295

2299-
V_inlet[nDim+3] = nodes->GetBetaInc2(iPoint);
2296+
V_inlet[prim_idx.Beta()] = nodes->GetBetaInc2(iPoint);
23002297

23012298
/*--- Cp is needed for Temperature equation. ---*/
23022299

2303-
V_inlet[nDim+7] = nodes->GetSpecificHeatCp(iPoint);
2300+
V_inlet[prim_idx.CpTotal()] = nodes->GetSpecificHeatCp(iPoint);
23042301

23052302
/*--- Set various quantities in the solver class ---*/
23062303

@@ -2329,9 +2326,9 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container,
23292326

23302327
/*--- Set transport properties at the inlet ---*/
23312328

2332-
V_inlet[nDim+4] = nodes->GetLaminarViscosity(iPoint);
2333-
V_inlet[nDim+5] = nodes->GetEddyViscosity(iPoint);
2334-
V_inlet[nDim+6] = nodes->GetThermalConductivity(iPoint);
2329+
V_inlet[prim_idx.LaminarViscosity()] = nodes->GetLaminarViscosity(iPoint);
2330+
V_inlet[prim_idx.EddyViscosity()] = nodes->GetEddyViscosity(iPoint);
2331+
V_inlet[prim_idx.ThermalConductivity()] = nodes->GetThermalConductivity(iPoint);
23352332

23362333
/*--- Set the normal vector and the coordinates ---*/
23372334

@@ -2430,12 +2427,12 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container,
24302427

24312428
/*--- The pressure is prescribed at the outlet. ---*/
24322429

2433-
V_outlet[0] = P_Outlet;
2430+
V_outlet[prim_idx.Pressure()] = P_Outlet;
24342431

24352432
/*--- Neumann condition for the velocity. ---*/
24362433

24372434
for (iDim = 0; iDim < nDim; iDim++) {
2438-
V_outlet[iDim+1] = nodes->GetVelocity(iPoint,iDim);
2435+
V_outlet[iDim+prim_idx.Velocity()] = nodes->GetVelocity(iPoint,iDim);
24392436
}
24402437

24412438
break;
@@ -2469,12 +2466,12 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container,
24692466

24702467
/*--- The pressure is prescribed at the outlet. ---*/
24712468

2472-
V_outlet[0] = P_Outlet;
2469+
V_outlet[prim_idx.Pressure()] = P_Outlet;
24732470

24742471
/*--- Neumann condition for the velocity ---*/
24752472

24762473
for (iDim = 0; iDim < nDim; iDim++) {
2477-
V_outlet[iDim+1] = nodes->GetVelocity(iPoint,iDim);
2474+
V_outlet[iDim+prim_idx.Velocity()] = nodes->GetVelocity(iPoint,iDim);
24782475
}
24792476

24802477
break;
@@ -2483,21 +2480,21 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container,
24832480

24842481
/*--- Neumann condition for the temperature. ---*/
24852482

2486-
V_outlet[nDim+1] = nodes->GetTemperature(iPoint);
2483+
V_outlet[prim_idx.Temperature()] = nodes->GetTemperature(iPoint);
24872484

24882485
/*--- Access density at the interior node. This is either constant by
24892486
construction, or will be set fixed implicitly by the temperature
24902487
and equation of state. ---*/
24912488

2492-
V_outlet[nDim+2] = nodes->GetDensity(iPoint);
2489+
V_outlet[prim_idx.Density()] = nodes->GetDensity(iPoint);
24932490

24942491
/*--- Beta coefficient from the config file ---*/
24952492

2496-
V_outlet[nDim+3] = nodes->GetBetaInc2(iPoint);
2493+
V_outlet[prim_idx.Beta()] = nodes->GetBetaInc2(iPoint);
24972494

24982495
/*--- Cp is needed for Temperature equation. ---*/
24992496

2500-
V_outlet[nDim+7] = nodes->GetSpecificHeatCp(iPoint);
2497+
V_outlet[prim_idx.CpTotal()] = nodes->GetSpecificHeatCp(iPoint);
25012498

25022499
/*--- Set various quantities in the solver class ---*/
25032500

@@ -2527,9 +2524,9 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container,
25272524

25282525
/*--- Set transport properties at the outlet. ---*/
25292526

2530-
V_outlet[nDim+4] = nodes->GetLaminarViscosity(iPoint);
2531-
V_outlet[nDim+5] = nodes->GetEddyViscosity(iPoint);
2532-
V_outlet[nDim+6] = nodes->GetThermalConductivity(iPoint);
2527+
V_outlet[prim_idx.LaminarViscosity()] = nodes->GetLaminarViscosity(iPoint);
2528+
V_outlet[prim_idx.EddyViscosity()] = nodes->GetEddyViscosity(iPoint);
2529+
V_outlet[prim_idx.ThermalConductivity()] = nodes->GetThermalConductivity(iPoint);
25332530

25342531
/*--- Set the normal vector and the coordinates ---*/
25352532

@@ -2878,7 +2875,7 @@ void CIncEulerSolver::GetOutlet_Properties(CGeometry *geometry, CConfig *config,
28782875
AxiFactor = 1.0;
28792876
}
28802877

2881-
Density = V_outlet[nDim+2];
2878+
Density = V_outlet[prim_idx.Density()];
28822879

28832880
Velocity2 = 0.0; Area = 0.0; MassFlow = 0.0;
28842881

0 commit comments

Comments
 (0)