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
36 changes: 20 additions & 16 deletions SU2_CFD/include/solvers/CFVMFlowSolverBase.inl
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,8 @@ void CFVMFlowSolverBase<V, R>::Viscous_Residual_impl(unsigned long iEdge, CGeome

const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT);
const bool tkeNeeded = (config->GetKind_Turb_Model() == TURB_MODEL::SST);
const bool ideal_gas = (config->GetKind_FluidModel() == STANDARD_AIR) ||
(config->GetKind_FluidModel() == IDEAL_GAS);

CVariable* turbNodes = nullptr;
if (tkeNeeded) turbNodes = solver_container[TURB_SOL]->GetNodes();
Expand All @@ -469,10 +471,10 @@ void CFVMFlowSolverBase<V, R>::Viscous_Residual_impl(unsigned long iEdge, CGeome

numerics->SetPrimitive(nodes->GetPrimitive(iPoint),
nodes->GetPrimitive(jPoint));

numerics->SetSecondary(nodes->GetSecondary(iPoint),
nodes->GetSecondary(jPoint));

if (!ideal_gas) {
numerics->SetSecondary(nodes->GetSecondary(iPoint),
nodes->GetSecondary(jPoint));
}
/*--- Gradients. ---*/

numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint),
Expand Down Expand Up @@ -1149,6 +1151,8 @@ void CFVMFlowSolverBase<V, FlowRegime>::BC_Sym_Plane(CGeometry* geometry, CSolve
SU2_ZONE_SCOPED

const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT);
const bool ideal_gas = (config->GetKind_FluidModel() == STANDARD_AIR) ||
(config->GetKind_FluidModel() == IDEAL_GAS);
const auto iVel = prim_idx.Velocity();

/*--- Blazek chapter 8.:
Expand Down Expand Up @@ -1205,7 +1209,9 @@ void CFVMFlowSolverBase<V, FlowRegime>::BC_Sym_Plane(CGeometry* geometry, CSolve

/*--- Set Primitive and Secondary for numerics class. ---*/
conv_numerics->SetPrimitive(V_domain, V_reflected);
conv_numerics->SetSecondary(nodes->GetSecondary(iPoint), nodes->GetSecondary(iPoint));
if (!ideal_gas) {
conv_numerics->SetSecondary(nodes->GetSecondary(iPoint), nodes->GetSecondary(iPoint));
}

/*--- Compute the residual using an upwind scheme. ---*/
auto residual = conv_numerics->ComputeResidual(config);
Expand Down Expand Up @@ -1329,6 +1335,8 @@ void CFVMFlowSolverBase<V, FlowRegime>::BC_Fluid_Interface(CGeometry* geometry,
CConfig* config) {
SU2_ZONE_SCOPED

const bool ideal_gas = config->GetKind_FluidModel() == STANDARD_AIR || config->GetKind_FluidModel() == IDEAL_GAS;

unsigned long iVertex, jVertex, iPoint, Point_Normal = 0;
unsigned short iDim, iVar, jVar, iMarker, nDonorVertex;

Expand Down Expand Up @@ -1380,19 +1388,15 @@ void CFVMFlowSolverBase<V, FlowRegime>::BC_Fluid_Interface(CGeometry* geometry,

conv_numerics->SetPrimitive(PrimVar_i, PrimVar_j);

if (FlowRegime == ENUM_REGIME::COMPRESSIBLE) {
if (!(config->GetKind_FluidModel() == STANDARD_AIR || config->GetKind_FluidModel() == IDEAL_GAS)) {
auto Secondary_i = nodes->GetSecondary(iPoint);

P_static = PrimVar_j[nDim + 1];
rho_static = PrimVar_j[nDim + 2];
GetFluidModel()->SetTDState_Prho(P_static, rho_static);
if (FlowRegime == ENUM_REGIME::COMPRESSIBLE && !ideal_gas) {
P_static = PrimVar_j[nDim + 1];
rho_static = PrimVar_j[nDim + 2];
GetFluidModel()->SetTDState_Prho(P_static, rho_static);

Secondary_j[0] = GetFluidModel()->GetdPdrho_e();
Secondary_j[1] = GetFluidModel()->GetdPde_rho();
Secondary_j[0] = GetFluidModel()->GetdPdrho_e();
Secondary_j[1] = GetFluidModel()->GetdPde_rho();

conv_numerics->SetSecondary(Secondary_i, Secondary_j);
}
conv_numerics->SetSecondary(nodes->GetSecondary(iPoint), Secondary_j);
}

/*--- Set the normal vector ---*/
Expand Down
6 changes: 0 additions & 6 deletions SU2_CFD/include/solvers/CSolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ class CSolver {
nPrimVar, /*!< \brief Number of primitive variables of the problem. */
nPrimVarGrad, /*!< \brief Number of primitive variables of the problem in the gradient computation. */
nSecondaryVar, /*!< \brief Number of primitive variables of the problem. */
nSecondaryVarGrad, /*!< \brief Number of primitive variables of the problem in the gradient computation. */
nVarGrad, /*!< \brief Number of variables for deallocating the LS Cvector. */
nDim; /*!< \brief Number of dimensions of the problem. */
unsigned long nPoint; /*!< \brief Number of points of the computational grid. */
Expand Down Expand Up @@ -415,11 +414,6 @@ class CSolver {
*/
inline unsigned short GetnSecondaryVar(void) const { return nSecondaryVar; }

/*!
* \brief Get the number of variables of the problem.
*/
inline unsigned short GetnSecondaryVarGrad(void) const { return nSecondaryVarGrad; }

/*!
* \brief Get the number of variables of the problem.
*/
Expand Down
2 changes: 0 additions & 2 deletions SU2_CFD/include/variables/CVariable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,12 @@ class CVariable {

VectorType SolutionExtra_BGS_k; /*!< \brief Intermediate storage, enables cross term extraction as that is also pushed to Solution. */

protected:
unsigned long nPoint = 0; /*!< \brief Number of points in the domain. */
unsigned long nDim = 0; /*!< \brief Number of dimension of the problem. */
unsigned long nVar = 0; /*!< \brief Number of variables of the problem. */
unsigned long nPrimVar = 0; /*!< \brief Number of primitive variables. */
unsigned long nPrimVarGrad = 0; /*!< \brief Number of primitives for which a gradient is computed. */
unsigned long nSecondaryVar = 0; /*!< \brief Number of secondary variables. */
unsigned long nSecondaryVarGrad = 0; /*!< \brief Number of secondaries for which a gradient is computed. */
unsigned long nAuxVar = 0; /*!< \brief Number of auxiliary variables. */

/*--- Only allow default construction by derived classes. ---*/
Expand Down
25 changes: 16 additions & 9 deletions SU2_CFD/src/solvers/CEulerSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config,
/*--- Centered schemes only need gradients for viscous fluxes (T and v). ---*/
nPrimVarGrad = EulerNPrimVarGrad(config, nDim);
nSecondaryVar = nSecVar;
nSecondaryVarGrad = 2;

/*--- Initialize nVarGrad for deallocation ---*/

Expand Down Expand Up @@ -1883,8 +1882,11 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain

/*--- Get primitive and secondary variables ---*/

auto V_i = nodes->GetPrimitive(iPoint); auto V_j = nodes->GetPrimitive(jPoint);
auto S_i = nodes->GetSecondary(iPoint); auto S_j = nodes->GetSecondary(jPoint);
auto V_i = nodes->GetPrimitive(iPoint);
auto V_j = nodes->GetPrimitive(jPoint);

const su2double* S_i = ideal_gas? nullptr : nodes->GetSecondary(iPoint);
const su2double* S_j = ideal_gas? nullptr : nodes->GetSecondary(jPoint);

/*--- Set them with or without high order reconstruction using MUSCL strategy. ---*/

Expand Down Expand Up @@ -5081,9 +5083,11 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container,

const string Marker_Tag = config->GetMarker_All_TagBound(val_marker);
const bool viscous = config->GetViscous(),
implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT),
implicit = config->GetKind_TimeIntScheme() == EULER_IMPLICIT,
gravity = config->GetGravityForce(),
tkeNeeded = (config->GetKind_Turb_Model() == TURB_MODEL::SST);
tkeNeeded = config->GetKind_Turb_Model() == TURB_MODEL::SST,
ideal_gas = config->GetKind_FluidModel() == STANDARD_AIR ||
config->GetKind_FluidModel() == IDEAL_GAS;

su2double **P_Tensor = new su2double*[nVar],
**invP_Tensor = new su2double*[nVar];
Expand Down Expand Up @@ -5451,7 +5455,7 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container,

/*--- Secondary variables ---*/

auto S_domain = nodes->GetSecondary(iPoint);
const su2double* S_domain = ideal_gas? nullptr : nodes->GetSecondary(iPoint);

/*--- Compute secondary thermodynamic properties (partial derivatives...) ---*/
su2double S_boundary[8];
Expand Down Expand Up @@ -5527,6 +5531,8 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain
bool viscous = config->GetViscous();
bool gravity = (config->GetGravityForce());
bool tkeNeeded = (config->GetKind_Turb_Model() == TURB_MODEL::SST);
const bool ideal_gas = config->GetKind_FluidModel() == STANDARD_AIR ||
config->GetKind_FluidModel() == IDEAL_GAS;

su2double *Normal, *turboNormal, *UnitNormal, *FlowDirMix, FlowDirMixMag, *turboVelocity;
Normal = new su2double[nDim];
Expand Down Expand Up @@ -5947,7 +5953,7 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain

/*--- Secondary variables ---*/

S_domain = nodes->GetSecondary(iPoint);
S_domain = ideal_gas ? nullptr : nodes->GetSecondary(iPoint);

/*--- Compute secondary thermodynamic properties (partial derivatives...) ---*/

Expand Down Expand Up @@ -6203,6 +6209,8 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, CNu
bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT);
string Marker_Tag = config->GetMarker_All_TagBound(val_marker);
bool viscous = config->GetViscous();
const bool ideal_gas = config->GetKind_FluidModel() == STANDARD_AIR ||
config->GetKind_FluidModel() == IDEAL_GAS;
unsigned short nSpanWiseSections = geometry->GetnSpanWiseSections(config->GetMarker_All_TurbomachineryFlag(val_marker));
su2double relfacAvgCfg = config->GetGiles_RelaxFactorAverage(Marker_Tag);
su2double relfacFouCfg = config->GetGiles_RelaxFactorFourier(Marker_Tag);
Expand Down Expand Up @@ -6538,8 +6546,7 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, CNu
V_domain = nodes->GetPrimitive(iPoint);

/*--- Retrieve domain Secondary variables ---*/
S_domain = nodes->GetSecondary(iPoint);

S_domain = ideal_gas? nullptr : nodes->GetSecondary(iPoint);

/*--- Compute the internal state u_i ---*/
Velocity2_i = 0;
Expand Down
5 changes: 3 additions & 2 deletions SU2_CFD/src/solvers/CNSSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,9 @@ unsigned long CNSSolver::SetPrimitive_Variables(CSolver **solver_container, cons

/*--- Compressible flow, primitive variables nDim+5, (T, vx, vy, vz, P, rho, h, c, lamMu, eddyMu, ThCond, Cp) ---*/

bool physical = static_cast<CNSVariable*>(nodes)->SetPrimVar(iPoint, eddy_visc, turb_ke, GetFluidModel());
nodes->SetSecondaryVar(iPoint, GetFluidModel());
auto* ns_nodes = static_cast<CNSVariable*>(nodes);
bool physical = ns_nodes->SetPrimVar(iPoint, eddy_visc, turb_ke, GetFluidModel());
ns_nodes->SetSecondaryVar(iPoint, GetFluidModel());

/*--- Check for non-realizable states for reporting. ---*/

Expand Down
17 changes: 12 additions & 5 deletions SU2_CFD/src/variables/CEulerVariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ unsigned long EulerNPrimVarGrad(const CConfig *config, unsigned long ndim) {
return ndim + 4;
}

unsigned long EulerNSecVar(const CConfig *config) {
const bool ideal_gas = config->GetKind_FluidModel() == STANDARD_AIR ||
config->GetKind_FluidModel() == IDEAL_GAS;
if (ideal_gas) return 0;
return config->GetViscous() ? 8 : 2;
}

CEulerVariable::CEulerVariable(su2double density, const su2double *velocity, su2double energy, unsigned long npoint,
unsigned long ndim, unsigned long nvar, const CConfig *config)
: CFlowVariable(npoint, ndim, nvar, ndim + 9, EulerNPrimVarGrad(config, ndim), config),
Expand All @@ -52,8 +59,7 @@ CEulerVariable::CEulerVariable(su2double density, const su2double *velocity, su2
(config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND);
const bool classical_rk4 = (config->GetKind_TimeIntScheme_Flow() == CLASSICAL_RK4_EXPLICIT);

nSecondaryVar = config->GetViscous() ? 8 : 2,
nSecondaryVarGrad = 2;
nSecondaryVar = EulerNSecVar(config);

/*--- Solution initialization ---*/

Expand Down Expand Up @@ -156,10 +162,11 @@ bool CEulerVariable::SetPrimVar(unsigned long iPoint, CFluidModel *FluidModel) {
}

void CEulerVariable::SetSecondaryVar(unsigned long iPoint, CFluidModel *FluidModel) {
if (nSecondaryVar == 0) return;

/*--- Compute secondary thermo-physical properties (partial derivatives...) ---*/
/*--- Compute secondary thermo-physical properties (partial derivatives...) ---*/

SetdPdrho_e(iPoint, FluidModel->GetdPdrho_e());
SetdPde_rho(iPoint, FluidModel->GetdPde_rho());
SetdPdrho_e(iPoint, FluidModel->GetdPdrho_e());
SetdPde_rho(iPoint, FluidModel->GetdPde_rho());

}
21 changes: 11 additions & 10 deletions SU2_CFD/src/variables/CNSVariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,21 +210,22 @@ bool CNSVariable::SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2doubl
}

void CNSVariable::SetSecondaryVar(unsigned long iPoint, CFluidModel *FluidModel) {
if (nSecondaryVar == 0) return;

/*--- Compute secondary thermodynamic properties (partial derivatives...) ---*/
/*--- Compute secondary thermodynamic properties (partial derivatives...) ---*/

SetdPdrho_e( iPoint, FluidModel->GetdPdrho_e() );
SetdPde_rho( iPoint, FluidModel->GetdPde_rho() );
SetdPdrho_e( iPoint, FluidModel->GetdPdrho_e() );
SetdPde_rho( iPoint, FluidModel->GetdPde_rho() );

SetdTdrho_e( iPoint, FluidModel->GetdTdrho_e() );
SetdTde_rho( iPoint, FluidModel->GetdTde_rho() );
SetdTdrho_e( iPoint, FluidModel->GetdTdrho_e() );
SetdTde_rho( iPoint, FluidModel->GetdTde_rho() );

/*--- Compute secondary thermo-physical properties (partial derivatives...) ---*/
/*--- Compute secondary thermo-physical properties (partial derivatives...) ---*/

Setdmudrho_T( iPoint, FluidModel->Getdmudrho_T() );
SetdmudT_rho( iPoint, FluidModel->GetdmudT_rho() );
Setdmudrho_T( iPoint, FluidModel->Getdmudrho_T() );
SetdmudT_rho( iPoint, FluidModel->GetdmudT_rho() );

Setdktdrho_T( iPoint, FluidModel->Getdktdrho_T() );
SetdktdT_rho( iPoint, FluidModel->GetdktdT_rho() );
Setdktdrho_T( iPoint, FluidModel->Getdktdrho_T() );
SetdktdT_rho( iPoint, FluidModel->GetdktdT_rho() );

}
Loading