Skip to content

Commit cdc2392

Browse files
committed
Added MUSCL Ramps options
1 parent a720b66 commit cdc2392

File tree

9 files changed

+110
-11
lines changed

9 files changed

+110
-11
lines changed

Common/include/CConfig.hpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,6 +1097,7 @@ class CConfig {
10971097
bool SpatialFourier; /*!< \brief option for computing the fourier transforms for subsonic non-reflecting BC. */
10981098
bool RampMotionFrame; /*!< \brief option for ramping up or down the motion Frame values */
10991099
bool RampOutlet; /*!< \brief option for ramping up or down the outlet values */
1100+
bool RampMUSCL;
11001101
bool RampRotatingFrame; /*!< \brief option for ramping up or down the motion Frame values */
11011102
bool RampTranslationFrame; /*!< \brief option for ramping up or down the outlet values */
11021103
bool RampOutletMassFlow; /*!< \brief option for ramping up or down the motion Frame values */
@@ -1113,6 +1114,11 @@ class CConfig {
11131114
array<su2double, N_POLY_COEFFS> kt_polycoeffs{{0.0}}; /*!< \brief Array for thermal conductivity polynomial coefficients. */
11141115
bool Body_Force; /*!< \brief Flag to know if a body force is included in the formulation. */
11151116

1117+
su2double rampMUSCLValue; /*!< \brief Current value of the MUSCL ramp */
1118+
su2double RampMUSCLPower; /*!< \brief Exponent by which to raise the MUSCL ramp to the power of */
1119+
MUSCL_RAMP_TYPE Kind_MUSCLRamp;
1120+
unsigned long *rampMUSCLCoeff; /*!< \brief ramp MUSCL value coefficients for the COption class. */
1121+
11161122
ENUM_STREAMWISE_PERIODIC Kind_Streamwise_Periodic; /*!< \brief Kind of Streamwise periodic flow (pressure drop or massflow) */
11171123
bool Streamwise_Periodic_Temperature; /*!< \brief Use real periodicity for Energy equation or otherwise outlet source term. */
11181124
su2double Streamwise_Periodic_PressureDrop; /*!< \brief Value of prescribed pressure drop [Pa] which results in an artificial body force vector. */
@@ -5179,6 +5185,12 @@ class CConfig {
51795185
*/
51805186
bool GetRampOutflow(void) const { return RampOutlet; }
51815187

5188+
/*!
5189+
* \brief Get MUSCL ramp option.
5190+
* \return Ramp MUSCL option
5191+
*/
5192+
bool GetMUSCLRamp(void) const { return RampMUSCL; }
5193+
51825194
/*!
51835195
* \brief General interface for accessing ramp coefficient information
51845196
* \return coeff for ramps
@@ -5189,6 +5201,37 @@ class CConfig {
51895201
else return 0;
51905202
};
51915203

5204+
/*!
5205+
* \brief Interface for accessing MUSCL ramp coefficient information
5206+
* \return coeff for ramps
5207+
*/
5208+
unsigned long GetMUSCLRampCoeff(RAMP_COEFF val_coeff) const {
5209+
return rampMUSCLCoeff[val_coeff];
5210+
}
5211+
5212+
/*!
5213+
* \brief Set MUSCL ramp value.
5214+
*/
5215+
void SetMUSCLRampValue(su2double ramp_value) { rampMUSCLValue = ramp_value; }
5216+
5217+
/*!
5218+
* \brief Get MUSCL ramp value.
5219+
* \return Ramp MUSCL value
5220+
*/
5221+
su2double GetMUSCLRampValue(void) const { return rampMUSCLValue; }
5222+
5223+
/*!
5224+
* \brief Get MUSCL ramp power.
5225+
* \return Ramp MUSCL power
5226+
*/
5227+
su2double GetMUSCLRampPower(void) const { return RampMUSCLPower; }
5228+
5229+
/*!
5230+
* \brief Get MUSCL ramp kind.
5231+
* \return Ramp MUSCL kind
5232+
*/
5233+
MUSCL_RAMP_TYPE GetKind_MUSCLRamp(void) const { return Kind_MUSCLRamp; }
5234+
51925235
/*!
51935236
* \brief Generic interface for setting monitor outlet values for the ramp.
51945237
*/

Common/include/option_structure.hpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1931,7 +1931,18 @@ enum TURBO_MARKER_TYPE{
19311931

19321932
enum class RAMP_TYPE{
19331933
GRID, /*!< \brief flag for rotational/translational ramps */
1934-
BOUNDARY /*!< \brief flag for pressure/mass flow ramps*/
1934+
BOUNDARY, /*!< \brief flag for pressure/mass flow ramps*/
1935+
MUSCL /*!< \brief flag for MUSCL ramps */
1936+
};
1937+
1938+
enum class MUSCL_RAMP_TYPE{
1939+
ITERATION, /*!< \brief flag for linear iteration-based ramp */
1940+
SMOOTH_FUNCTION /*!< \brief flag for smooth cosine ramp */
1941+
};
1942+
1943+
static const MapType<std::string, MUSCL_RAMP_TYPE> MUSCLRamp_Map = {
1944+
MakePair("ITERATION", MUSCL_RAMP_TYPE::ITERATION)
1945+
MakePair("SMOOTH_FUNCTION", MUSCL_RAMP_TYPE::SMOOTH_FUNCTION)
19351946
};
19361947

19371948
/*!

Common/src/CConfig.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,6 +1986,18 @@ void CConfig::SetConfig_Options() {
19861986
addBoolOption("MUSCL_FLOW", MUSCL_Flow, true);
19871987
/*!\brief MUSCL_KAPPA_FLOW \n DESCRIPTION: Blending coefficient for the U-MUSCL scheme \ingroup Config*/
19881988
addDoubleOption("MUSCL_KAPPA_FLOW", MUSCL_Kappa_Flow, 0.0);
1989+
/*!\brief RAMP_MUSCL \n DESCRIPTION: Enable ramping of the MUSCL scheme from 1st to 2nd order using specified method*/
1990+
addBoolOption("RAMP_MUSCL", RampMUSCL, false);
1991+
/*! brief RAMP_OUTLET_COEFF \n DESCRIPTION: the 1st coeff is the ramp start iteration,
1992+
* the 2nd coeff is the iteration update frequenct, 3rd coeff is the total number of iterations */
1993+
unsigned short nMUSCLCoeffs = 3;
1994+
rampMUSCLCoeff = new unsigned long [nMUSCLCoeffs];
1995+
rampMUSCLCoeff[0] = 0.0; rampMUSCLCoeff[1] = 1.0; rampMUSCLCoeff[2] = 500.0;
1996+
addULongListOption("RAMP_MUSCL_COEFF", nMUSCLCoeffs, rampMUSCLCoeff);
1997+
/*!\brief RAMP_MUSCL_POWER \n DESRCIPTION: Exponent of the MUSCL ramp formulation */
1998+
addDoubleOption("RAMP_MUSCL_POWER", RampMUSCLPower, 1.0);
1999+
/*!\brief KIND_MUSCL_RAMP \n DESCRIPTION: The kind of MUSCL Ramp to be applied */
2000+
addEnumOption("KIND_MUSCL_RAMP", Kind_MUSCLRamp, MUSCLRamp_Map, MUSCL_RAMP_TYPE::ITERATION);
19892001
/*!\brief SLOPE_LIMITER_FLOW
19902002
* DESCRIPTION: Slope limiter for the direct solution. \n OPTIONS: See \link Limiter_Map \endlink \n DEFAULT VENKATAKRISHNAN \ingroup Config*/
19912003
addEnumOption("SLOPE_LIMITER_FLOW", Kind_SlopeLimit_Flow, Limiter_Map, LIMITER::VENKATAKRISHNAN);
@@ -4479,6 +4491,12 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
44794491
}
44804492
}
44814493

4494+
if(RampMUSCL && !DiscreteAdjoint){
4495+
rampMUSCLValue = 0.0;
4496+
} else {
4497+
rampMUSCLValue = 1.0;
4498+
}
4499+
44824500
/*--- Check on extra Relaxation factor for Giles---*/
44834501
if(extrarelfac[1] > 0.5){
44844502
extrarelfac[1] = 0.5;

SU2_CFD/include/solvers/CScalarSolver.inl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ void CScalarSolver<VariableType>::Upwind_Residual(CGeometry* geometry, CSolver**
222222
for (auto iVar = 0u; iVar < solver_container[FLOW_SOL]->GetnPrimVarGrad(); iVar++) {
223223
const su2double V_ij = V_j[iVar] - V_i[iVar];
224224

225-
su2double Project_Grad_i = MUSCL_Reconstruction(Gradient_i[iVar], Vector_ij, V_ij, kappaFlow);
226-
su2double Project_Grad_j = MUSCL_Reconstruction(Gradient_j[iVar], Vector_ij, V_ij, kappaFlow);
225+
su2double Project_Grad_i = config->GetMUSCLRampValue() * MUSCL_Reconstruction(Gradient_i[iVar], Vector_ij, V_ij, kappaFlow);
226+
su2double Project_Grad_j = config->GetMUSCLRampValue() * MUSCL_Reconstruction(Gradient_j[iVar], Vector_ij, V_ij, kappaFlow);
227227

228228
if (limiterFlow) {
229229
Project_Grad_i *= Limiter_i[iVar];
@@ -251,8 +251,8 @@ void CScalarSolver<VariableType>::Upwind_Residual(CGeometry* geometry, CSolver**
251251
for (auto iVar = 0u; iVar < nVar; iVar++) {
252252
const su2double U_ij = Scalar_j[iVar] - Scalar_i[iVar];
253253

254-
su2double Project_Grad_i = MUSCL_Reconstruction(Gradient_i[iVar], Vector_ij, U_ij, kappa);
255-
su2double Project_Grad_j = MUSCL_Reconstruction(Gradient_j[iVar], Vector_ij, U_ij, kappa);
254+
su2double Project_Grad_i = config->GetMUSCLRampValue() * MUSCL_Reconstruction(Gradient_i[iVar], Vector_ij, U_ij, kappa);
255+
su2double Project_Grad_j = config->GetMUSCLRampValue() * MUSCL_Reconstruction(Gradient_j[iVar], Vector_ij, U_ij, kappa);
256256

257257
if (limiter) {
258258
Project_Grad_i *= Limiter_i[iVar];

SU2_CFD/include/solvers/CSolver.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ class CSolver {
587587
* \param[in] vector_ij - Distance vector.
588588
* \param[in] delta_ij - Centered difference.
589589
* \param[in] kappa - Blending coefficient for U-MUSCL reconstruction.
590+
* \param[in] ramp_val - Value of the ramp
590591
* \return - Projected variable.
591592
*/
592593
inline su2double MUSCL_Reconstruction(const su2double* grad, const su2double* vector_ij, su2double delta_ij, su2double kappa) {

SU2_CFD/src/iteration/CFluidIteration.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,9 @@ bool CFluidIteration::Monitor(COutput* output, CIntegration**** integration, CGe
241241
if (config[val_iZone]->GetRampOutflow())
242242
UpdateRamp(geometry, config, config[val_iZone]->GetInnerIter(), val_iZone, RAMP_TYPE::BOUNDARY);
243243

244+
if (config[val_iZone]->GetMUSCLRamp())
245+
UpdateRamp(geometry, config, config[val_iZone]->GetInnerIter(), val_iZone, RAMP_TYPE::MUSCL);
246+
244247
output->SetHistoryOutput(geometry[val_iZone][val_iInst][MESH_0], solver[val_iZone][val_iInst][MESH_0],
245248
config[val_iZone], config[val_iZone]->GetTimeIter(), config[val_iZone]->GetOuterIter(),
246249
config[val_iZone]->GetInnerIter());
@@ -330,6 +333,29 @@ void CFluidIteration::UpdateRamp(CGeometry**** geometry_container, CConfig** con
330333
}
331334
}
332335
}
336+
337+
if (ramp_flag == RAMP_TYPE::MUSCL) {
338+
const long unsigned startIter = config->GetMUSCLRampCoeff(RAMP_COEFF::INITIAL_VALUE);
339+
const long unsigned updateFreq = config->GetMUSCLRampCoeff(RAMP_COEFF::UPDATE_FREQ);
340+
const long unsigned finalIter = config->GetMUSCLRampCoeff(RAMP_COEFF::FINAL_ITER);
341+
const auto power = config->GetMUSCLRampPower();
342+
auto iterFrac = (static_cast<double>(iter - startIter)/static_cast<double>(finalIter - startIter));
343+
if (iter < startIter) return;
344+
if ((iter == startIter) && (rank == MASTER_NODE)) cout << "Beginning to ramp MUSCL scheme..." << endl;
345+
if ((iter % updateFreq == 0 && iter < finalIter) || (iter == finalIter)) {
346+
switch (config->GetKind_MUSCLRamp()) {
347+
case MUSCL_RAMP_TYPE::ITERATION:
348+
config->SetMUSCLRampValue(std::pow(std::min<double>(1.0, iterFrac), power));
349+
break;
350+
case MUSCL_RAMP_TYPE::SMOOTH_FUNCTION:
351+
config->SetMUSCLRampValue(std::pow((0.5 * (1 - cos(M_PI * std::min(1.0, iterFrac)))), power));
352+
break;
353+
default:
354+
break;
355+
}
356+
if (rank == MASTER_NODE) cout << "MUSCL Ramp value updated. New Value: " << config->GetMUSCLRampValue() << endl;
357+
}
358+
}
333359
}
334360

335361
void CFluidIteration::ComputeTurboPerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container, unsigned long ExtIter) {

SU2_CFD/src/solvers/CEulerSolver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1881,8 +1881,8 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain
18811881
for (auto iVar = 0u; iVar < nPrimVarGrad; iVar++) {
18821882
const su2double V_ij = V_j[iVar] - V_i[iVar];
18831883

1884-
const su2double Project_Grad_i = nkRelax * MUSCL_Reconstruction(Gradient_i[iVar], Vector_ij, V_ij, kappa);
1885-
const su2double Project_Grad_j = nkRelax * MUSCL_Reconstruction(Gradient_j[iVar], Vector_ij, V_ij, kappa);
1884+
const su2double Project_Grad_i = config->GetMUSCLRampValue() * nkRelax * MUSCL_Reconstruction(Gradient_i[iVar], Vector_ij, V_ij, kappa);
1885+
const su2double Project_Grad_j = config->GetMUSCLRampValue() * nkRelax * MUSCL_Reconstruction(Gradient_j[iVar], Vector_ij, V_ij, kappa);
18861886

18871887
su2double lim_i = 1.0;
18881888
su2double lim_j = 1.0;

SU2_CFD/src/solvers/CIncEulerSolver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,8 +1279,8 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont
12791279
for (auto iVar = 0u; iVar < nPrimVarGrad; iVar++) {
12801280
const su2double V_ij = V_j[iVar] - V_i[iVar];
12811281

1282-
const su2double Project_Grad_i = nkRelax * MUSCL_Reconstruction(Gradient_i[iVar], Vector_ij, V_ij, kappa);
1283-
const su2double Project_Grad_j = nkRelax * MUSCL_Reconstruction(Gradient_j[iVar], Vector_ij, V_ij, kappa);
1282+
const su2double Project_Grad_i = config->GetMUSCLRampValue() * nkRelax * MUSCL_Reconstruction(Gradient_i[iVar], Vector_ij, V_ij, kappa);
1283+
const su2double Project_Grad_j = config->GetMUSCLRampValue() * nkRelax * MUSCL_Reconstruction(Gradient_j[iVar], Vector_ij, V_ij, kappa);
12841284

12851285
su2double lim_i = 1.0;
12861286
su2double lim_j = 1.0;

SU2_CFD/src/solvers/CNEMOEulerSolver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,8 @@ void CNEMOEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_con
542542
for (auto iVar = 0ul; iVar < nPrimVarGrad; iVar++) {
543543
const su2double V_ij = V_j[iVar] - V_i[iVar];
544544

545-
Project_Grad_i[iVar] = nkRelax * MUSCL_Reconstruction(Gradient_i[iVar], Vector_ij, V_ij, kappa);
546-
Project_Grad_j[iVar] = nkRelax * MUSCL_Reconstruction(Gradient_j[iVar], Vector_ij, V_ij, kappa);
545+
Project_Grad_i[iVar] = config->GetMUSCLRampValue() * nkRelax * MUSCL_Reconstruction(Gradient_i[iVar], Vector_ij, V_ij, kappa);
546+
Project_Grad_j[iVar] = config->GetMUSCLRampValue() * nkRelax * MUSCL_Reconstruction(Gradient_j[iVar], Vector_ij, V_ij, kappa);
547547

548548
if (limiter) {
549549
if (van_albada) {

0 commit comments

Comments
 (0)