Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions SU2_CFD/include/output/COutput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,15 +720,14 @@ class COutput {

/*!
* \brief Set the history fields common for all solvers.
* \param[in] config - Definition of the particular problem.
*/
void SetCommonHistoryFields(CConfig *config);
void SetCommonHistoryFields();

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

/*!
* \brief Allocates the data sorters if necessary.
Expand Down
4 changes: 2 additions & 2 deletions SU2_CFD/src/drivers/CSinglezoneDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ void CSinglezoneDriver::Output(unsigned long TimeIter) {
BandwidthSum = config_container[ZONE_0]->GetRestart_Bandwidth_Agg();

StartTime = SU2_MPI::Wtime();

config_container[ZONE_0]->Set_StartTime(StartTime);
}

config_container[ZONE_0]->Set_StartTime(StartTime);
}
Comment on lines 216 to 219

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is the actual fix and the rest is code cleanup? LGTM


void CSinglezoneDriver::DynamicMeshUpdate(unsigned long TimeIter) {
Expand Down
16 changes: 8 additions & 8 deletions SU2_CFD/src/output/COutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1314,7 +1314,7 @@ void COutput::PreprocessHistoryOutput(CConfig *config, bool wrt){

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

SetCommonHistoryFields(config);
SetCommonHistoryFields();

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

Expand Down Expand Up @@ -1361,7 +1361,7 @@ void COutput::PreprocessMultizoneHistoryOutput(COutput **output, CConfig **confi

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

SetCommonHistoryFields(driver_config);
SetCommonHistoryFields();

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

Expand Down Expand Up @@ -2157,15 +2157,15 @@ bool COutput::WriteVolume_Output(CConfig *config, unsigned long Iter, bool force
}
}

void COutput::SetCommonHistoryFields(CConfig *config){
void COutput::SetCommonHistoryFields() {

/// BEGIN_GROUP: ITERATION, DESCRIPTION: Iteration identifier.
/// DESCRIPTION: The time iteration index.
AddHistoryOutput("TIME_ITER", "Time_Iter", ScreenOutputFormat::INTEGER, "ITER", "Time iteration index");
AddHistoryOutput("TIME_ITER", "Time_Iter", ScreenOutputFormat::INTEGER, "ITER", "Time iteration index");
/// DESCRIPTION: The outer iteration index.
AddHistoryOutput("OUTER_ITER", "Outer_Iter", ScreenOutputFormat::INTEGER, "ITER", "Outer iteration index");
AddHistoryOutput("OUTER_ITER", "Outer_Iter", ScreenOutputFormat::INTEGER, "ITER", "Outer iteration index");
/// DESCRIPTION: The inner iteration index.
AddHistoryOutput("INNER_ITER", "Inner_Iter", ScreenOutputFormat::INTEGER, "ITER", "Inner iteration index");
AddHistoryOutput("INNER_ITER", "Inner_Iter", ScreenOutputFormat::INTEGER, "ITER", "Inner iteration index");
/// END_GROUP

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

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

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

}

void COutput::LoadCommonHistoryData(CConfig *config){
void COutput::LoadCommonHistoryData(const CConfig *config) {

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

Expand Down
28 changes: 13 additions & 15 deletions SU2_CFD/src/solvers/CEulerSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1819,16 +1819,17 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain
cell-average value of the solution. This is a locally 1st order approximation,
which is typically only active during the start-up of a calculation. ---*/

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

su2double R = sqrt(fabs(Primitive_j[nDim+2]/Primitive_i[nDim+2]));
su2double R = sqrt(fabs(Primitive_j[prim_idx.Density()]/Primitive_i[prim_idx.Density()]));
su2double sq_vel = 0.0;
for (iDim = 0; iDim < nDim; iDim++) {
su2double RoeVelocity = (R*Primitive_j[iDim+1]+Primitive_i[iDim+1])/(R+1);
su2double RoeVelocity = (R * Primitive_j[iDim + prim_idx.Velocity()] +
Primitive_i[iDim + prim_idx.Velocity()]) / (R+1);
sq_vel += pow(RoeVelocity, 2);
}
su2double RoeEnthalpy = (R*Primitive_j[nDim+3]+Primitive_i[nDim+3])/(R+1);
su2double RoeEnthalpy = (R * Primitive_j[prim_idx.Enthalpy()] + Primitive_i[prim_idx.Enthalpy()]) / (R+1);

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

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

void CEulerSolver::ComputeConsistentExtrapolation(CFluidModel *fluidModel, unsigned short nDim,
su2double *primitive, su2double *secondary) {

su2double density = primitive[nDim+2];
su2double pressure = primitive[nDim+1];

su2double velocity2 = 0.0;
for (unsigned short iDim = 0; iDim < nDim; iDim++)
velocity2 += pow(primitive[iDim+1], 2);
const CEulerVariable::CIndices<unsigned short> prim_idx(nDim, 0);
const su2double density = primitive[prim_idx.Density()];
const su2double pressure = primitive[prim_idx.Pressure()];
const su2double velocity2 = GeometryToolbox::SquaredNorm(nDim, &primitive[prim_idx.Velocity()]);

fluidModel->SetTDState_Prho(pressure, density);

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

Expand Down
85 changes: 41 additions & 44 deletions SU2_CFD/src/solvers/CIncEulerSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1226,11 +1226,11 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont
checked. Pressure is the dynamic pressure (can be negative). ---*/

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

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

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

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

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

V_infty[0] = GetPressure_Inf();
V_infty[prim_idx.Pressure()] = GetPressure_Inf();

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

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

/*--- Store the density. ---*/

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

break;

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

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

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

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

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

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

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

for (iDim = 0; iDim < nDim; iDim++)
V_inlet[iDim+1] = V_domain[iDim+1];
V_inlet[iDim+prim_idx.Velocity()] = V_domain[iDim+prim_idx.Velocity()];

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

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

} else {

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

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

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

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

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

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

}

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

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

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

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

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

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

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

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

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

V_inlet[nDim+4] = nodes->GetLaminarViscosity(iPoint);
V_inlet[nDim+5] = nodes->GetEddyViscosity(iPoint);
V_inlet[nDim+6] = nodes->GetThermalConductivity(iPoint);
V_inlet[prim_idx.LaminarViscosity()] = nodes->GetLaminarViscosity(iPoint);
V_inlet[prim_idx.EddyViscosity()] = nodes->GetEddyViscosity(iPoint);
V_inlet[prim_idx.ThermalConductivity()] = nodes->GetThermalConductivity(iPoint);

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

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

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

V_outlet[0] = P_Outlet;
V_outlet[prim_idx.Pressure()] = P_Outlet;

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

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

break;
Expand Down Expand Up @@ -2469,12 +2466,12 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container,

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

V_outlet[0] = P_Outlet;
V_outlet[prim_idx.Pressure()] = P_Outlet;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

V_outlet[nDim+4] = nodes->GetLaminarViscosity(iPoint);
V_outlet[nDim+5] = nodes->GetEddyViscosity(iPoint);
V_outlet[nDim+6] = nodes->GetThermalConductivity(iPoint);
V_outlet[prim_idx.LaminarViscosity()] = nodes->GetLaminarViscosity(iPoint);
V_outlet[prim_idx.EddyViscosity()] = nodes->GetEddyViscosity(iPoint);
V_outlet[prim_idx.ThermalConductivity()] = nodes->GetThermalConductivity(iPoint);

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

Expand Down Expand Up @@ -2878,7 +2875,7 @@ void CIncEulerSolver::GetOutlet_Properties(CGeometry *geometry, CConfig *config,
AxiFactor = 1.0;
}

Density = V_outlet[nDim+2];
Density = V_outlet[prim_idx.Density()];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to see the replacement of the magical numbers nDim + i with human readable indices


Velocity2 = 0.0; Area = 0.0; MassFlow = 0.0;

Expand Down