Skip to content

Commit 06e63d3

Browse files
Cristopher-MoralespcarruscagCristopher-Morales
authored
Adding temperature limits for incompressible solver (#2569)
* enabling relaxation factor * MLPCpp update * user option * adding temperature limits * removing underrelaxation factor * only SetDensity if Temperature is false * cleaning * additional cleaning * enabling ComputeUnderRelaxationFactor * disable ComputeUnderRelaxationFactor * Update SU2_CFD/include/variables/CIncEulerVariable.hpp Co-authored-by: Pedro Gomes <[email protected]> * Update SU2_CFD/include/variables/CIncEulerVariable.hpp Co-authored-by: Pedro Gomes <[email protected]> * Update SU2_CFD/src/variables/CIncNSVariable.cpp Co-authored-by: Pedro Gomes <[email protected]> * Update Common/include/CConfig.hpp Co-authored-by: Pedro Gomes <[email protected]> * fixing renaming and converting to protected varaibles * updating config_template * removing trailing space * adding test case * updating residuals --------- Co-authored-by: Pedro Gomes <[email protected]> Co-authored-by: Cristopher-Morales <[email protected]>
1 parent c8e0f34 commit 06e63d3

File tree

8 files changed

+184
-8
lines changed

8 files changed

+184
-8
lines changed

Common/include/CConfig.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class CConfig {
9393
bool MG_AdjointFlow; /*!< \brief MG with the adjoint flow problem */
9494
su2double *PressureLimits,
9595
*DensityLimits,
96-
*TemperatureLimits; /*!< \brief Limits for the primitive variables */
96+
TemperatureLimits[2]; /*!< \brief Limits for the primitive variables */
9797
bool ActDisk_DoubleSurface; /*!< \brief actuator disk double surface */
9898
bool Engine_HalfModel; /*!< \brief only half model is in the computational grid */
9999
bool ActDisk_SU2_DEF; /*!< \brief actuator disk double surface */
@@ -2183,6 +2183,12 @@ class CConfig {
21832183
*/
21842184
su2double GetInc_Temperature_Init(void) const { return Inc_Temperature_Init; }
21852185

2186+
/*!
2187+
* \brief Get Temperature limits for incompressible flows.
2188+
* \return Temperature limits minimum and maximum values.
2189+
*/
2190+
su2double GetTemperatureLimits(int iVar) const { return TemperatureLimits[iVar]; }
2191+
21862192
/*!
21872193
* \brief Get the flag for activating species transport clipping.
21882194
* \return Flag for species clipping.

Common/src/CConfig.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,6 +1368,9 @@ void CConfig::SetConfig_Options() {
13681368
addEnumOption("INC_DENSITY_MODEL", Kind_DensityModel, DensityModel_Map, INC_DENSITYMODEL::CONSTANT);
13691369
/*!\brief ENERGY_EQUATION \n DESCRIPTION: Solve the energy equation in the incompressible flow solver. \ingroup Config*/
13701370
addBoolOption("INC_ENERGY_EQUATION", Energy_Equation, false);
1371+
/*!\brief TEMPERATURE_LIMITS \n DESCRIPTION: Temperature limits for incompressible flows (0.0, 5000 K by default) \ingroup Config*/
1372+
TemperatureLimits[0] = 0.0; TemperatureLimits[1] = 5000.0;
1373+
addDoubleArrayOption("TEMPERATURE_LIMITS", 2, TemperatureLimits);
13711374
/*!\brief INC_DENSITY_REF \n DESCRIPTION: Reference density for incompressible flows \ingroup Config*/
13721375
addDoubleOption("INC_DENSITY_REF", Inc_Density_Ref, 1.0);
13731376
/*!\brief INC_VELOCITY_REF \n DESCRIPTION: Reference velocity for incompressible flows (1.0 by default) \ingroup Config*/

SU2_CFD/include/variables/CIncEulerVariable.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class CIncEulerVariable : public CFlowVariable {
7171

7272
VectorType Streamwise_Periodic_RecoveredPressure, /*!< \brief Recovered/Physical pressure [Pa] for streamwise periodic flow. */
7373
Streamwise_Periodic_RecoveredTemperature; /*!< \brief Recovered/Physical temperature [K] for streamwise periodic flow. */
74+
su2double TemperatureLimits[2]; /*!< \brief Temperature limits [K]. */
7475
public:
7576
/*!
7677
* \brief Constructor of the class.
@@ -82,6 +83,7 @@ class CIncEulerVariable : public CFlowVariable {
8283
* \param[in] nvar - Number of variables of the problem.
8384
* \param[in] config - Definition of the particular problem.
8485
*/
86+
8587
CIncEulerVariable(su2double pressure, const su2double *velocity, su2double temperature,
8688
unsigned long npoint, unsigned long ndim, unsigned long nvar, const CConfig *config);
8789

@@ -116,9 +118,9 @@ class CIncEulerVariable : public CFlowVariable {
116118
* \brief Set the value of the temperature for incompressible flows with energy equation.
117119
* \param[in] iPoint - Point index.
118120
*/
119-
inline bool SetTemperature(unsigned long iPoint, su2double val_temperature) final {
121+
inline bool SetTemperature(unsigned long iPoint, su2double val_temperature, const su2double *val_temp_limits) {
120122
Primitive(iPoint, indices.Temperature()) = val_temperature;
121-
return val_temperature <= 0.0;
123+
return (val_temperature <= val_temp_limits[0]) || (val_temperature >= val_temp_limits[1]);
122124
}
123125

124126
/*!

SU2_CFD/src/variables/CIncEulerVariable.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ CIncEulerVariable::CIncEulerVariable(su2double pressure, const su2double *veloci
3737
const bool dual_time = (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) ||
3838
(config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND);
3939
const bool classical_rk4 = (config->GetKind_TimeIntScheme_Flow() == CLASSICAL_RK4_EXPLICIT);
40+
TemperatureLimits[0]= config->GetTemperatureLimits(0);
41+
TemperatureLimits[1]= config->GetTemperatureLimits(1);
4042

4143
/*--- Solution initialization ---*/
4244

@@ -76,7 +78,7 @@ bool CIncEulerVariable::SetPrimVar(unsigned long iPoint, CFluidModel *FluidModel
7678
/*--- Set the value of the temperature directly ---*/
7779

7880
su2double Temperature = Solution(iPoint, nDim+1);
79-
const auto check_temp = SetTemperature(iPoint, Temperature);
81+
const auto check_temp = SetTemperature(iPoint, Temperature, TemperatureLimits);
8082

8183
/*--- Use the fluid model to compute the new value of density.
8284
Note that the thermodynamic pressure is constant and decoupled
@@ -102,7 +104,7 @@ bool CIncEulerVariable::SetPrimVar(unsigned long iPoint, CFluidModel *FluidModel
102104
/*--- Recompute the primitive variables ---*/
103105

104106
Temperature = Solution(iPoint, nDim+1);
105-
SetTemperature(iPoint, Temperature);
107+
SetTemperature(iPoint, Temperature, TemperatureLimits);
106108
FluidModel->SetTDState_T(Temperature);
107109
SetDensity(iPoint, FluidModel->GetDensity());
108110

SU2_CFD/src/variables/CIncNSVariable.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ bool CIncNSVariable::SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2do
5959
/*--- Set the value of the temperature directly ---*/
6060

6161
su2double Temperature = Solution(iPoint, indices.Temperature());
62-
auto check_temp = SetTemperature(iPoint, Temperature);
62+
auto check_temp = SetTemperature(iPoint, Temperature, TemperatureLimits);
6363

6464
/*--- Use the fluid model to compute the new value of density.
6565
Note that the thermodynamic pressure is constant and decoupled
@@ -73,7 +73,7 @@ bool CIncNSVariable::SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2do
7373
Solution(iPoint,nDim+1) = FluidModel->GetTemperature();
7474
/*--- for FLAMELET: update the local temperature using LUT variables ---*/
7575
Temperature = Solution(iPoint,indices.Temperature());
76-
check_temp = SetTemperature(iPoint, Temperature);
76+
check_temp = SetTemperature(iPoint, Temperature, TemperatureLimits);
7777

7878
/*--- Set the value of the density ---*/
7979

@@ -91,7 +91,7 @@ bool CIncNSVariable::SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2do
9191
/*--- Recompute the primitive variables ---*/
9292

9393
Temperature = Solution(iPoint, indices.Temperature());
94-
SetTemperature(iPoint, Temperature);
94+
SetTemperature(iPoint, Temperature, TemperatureLimits);
9595
FluidModel->SetTDState_T(Temperature, scalar);
9696
SetDensity(iPoint, FluidModel->GetDensity());
9797

TestCases/parallel_regression.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,6 +1646,15 @@ def main():
16461646
species_passive_val.test_vals_aarch64 = [-16.538551, -16.312552, -16.882823, -4.257599, 10, -4.585464, 8, -5.19335, 0.18661, 0]
16471647
test_list.append(species_passive_val)
16481648

1649+
# rectangle active 2-species transport
1650+
species_active_transport_temp_limits = TestCase('species_active_transport_temp_limits')
1651+
species_active_transport_temp_limits.cfg_dir = "species_transport/passive_transport_validation"
1652+
species_active_transport_temp_limits.cfg_file = "active_species_transport_temp_limits.cfg"
1653+
species_active_transport_temp_limits.test_iter = 50
1654+
species_active_transport_temp_limits.test_vals = [-2.340885, -2.257725, -1.926927, -3.236329, 9.000000, -5.006265, 4.000000, -5.931361, 1.646370, 0.993308, 0.000445, 0.652617]
1655+
species_active_transport_temp_limits.test_vals_aarch64 = [-2.340885, -2.257725, -1.926927, -3.236329, 9.000000, -5.006265, 4.000000, -5.931361, 1.646370, 0.993308, 0.000445, 0.652617]
1656+
test_list.append(species_active_transport_temp_limits)
1657+
16491658
# species transport, 3 species with multizone (2 fluid regions)
16501659
species3_multizone_restart = TestCase('species3_multizone_restart')
16511660
species3_multizone_restart.cfg_dir = "species_transport/multizone"
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2+
% %
3+
% SU2 configuration file %
4+
% Case description: Active transport 2 species: Hydrogen and air. %
5+
% 1 transport equation is being solved(For H2 in this case). %
6+
% Including temperature limits for energy equation. %
7+
% Author: Cristopher Morales Ubal %
8+
% Institution: Eindhoven University of Technology %
9+
% Date: 2025/09/20 %
10+
% File Version 8.0.1 "Harrier" %
11+
% %
12+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13+
14+
% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------%
15+
%
16+
SOLVER= INC_NAVIER_STOKES
17+
KIND_TURB_MODEL= NONE
18+
%
19+
% ---------------- INCOMPRESSIBLE FLOW CONDITION DEFINITION -------------------%
20+
%
21+
INC_DENSITY_MODEL= VARIABLE
22+
INC_DENSITY_INIT= 0.0807
23+
%
24+
INC_VELOCITY_INIT= ( 1.0, 0.0, 0.0 )
25+
%
26+
INC_ENERGY_EQUATION= YES
27+
TEMPERATURE_LIMITS= 250, 400
28+
INC_TEMPERATURE_INIT= 350.0
29+
%
30+
INC_NONDIM= DIMENSIONAL
31+
%
32+
% -------------------- FLUID PROPERTIES ------------------------------------- %
33+
%
34+
FLUID_MODEL= FLUID_MIXTURE
35+
%
36+
THERMODYNAMIC_PRESSURE= 101325.0
37+
%
38+
MOLECULAR_WEIGHT= 2.01588, 28.960
39+
%
40+
SPECIFIC_HEAT_CP = 14310, 1009.39
41+
%
42+
CONDUCTIVITY_MODEL= CONSTANT_CONDUCTIVITY
43+
THERMAL_CONDUCTIVITY_CONSTANT= 0.187, 0.0258
44+
%
45+
PRANDTL_LAM= 0.72, 0.72
46+
TURBULENT_CONDUCTIVITY_MODEL= NONE
47+
PRANDTL_TURB= 0.90, 0.90
48+
%
49+
% --------------------------- VISCOSITY MODEL ---------------------------------%
50+
%
51+
VISCOSITY_MODEL= CONSTANT_VISCOSITY
52+
%
53+
MU_CONSTANT= 8.9E-06, 1.8551E-05
54+
%
55+
MU_REF= 8.411E-05, 1.716E-05
56+
%
57+
MU_T_REF= 273, 273
58+
%
59+
SUTHERLAND_CONSTANT= 97, 111
60+
%
61+
MIXING_VISCOSITY_MODEL = WILKE
62+
%
63+
% -------------------- BOUNDARY CONDITION DEFINITION --------------------------%
64+
%
65+
MARKER_SYM= ( top, bottom)
66+
%
67+
SPECIFIED_INLET_PROFILE= NO
68+
INLET_FILENAME= inlet_venturi.dat
69+
INC_INLET_TYPE= VELOCITY_INLET VELOCITY_INLET
70+
MARKER_INLET= ( gas_inlet, 350, 3.0, 1.0, 0.0, 0.0,\
71+
air_inlet, 300, 1.0, 1.0, 0.0, 0.0 )
72+
MARKER_INLET_SPECIES= (gas_inlet, 1.0, air_inlet, 0.0)
73+
%
74+
INC_OUTLET_TYPE= PRESSURE_OUTLET
75+
MARKER_OUTLET= ( outlet, 0.0 )
76+
%
77+
% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------%
78+
%
79+
NUM_METHOD_GRAD= WEIGHTED_LEAST_SQUARES
80+
%
81+
CFL_NUMBER= 20
82+
CFL_REDUCTION_SPECIES= 1.0
83+
CFL_REDUCTION_TURB= 1.0
84+
%
85+
% Run commented Iter for good results
86+
ITER= 5000
87+
%
88+
% ------------------------ LINEAR SOLVER DEFINITION ---------------------------%
89+
%
90+
LINEAR_SOLVER= FGMRES
91+
LINEAR_SOLVER_PREC= ILU
92+
LINEAR_SOLVER_ERROR= 1E-5
93+
LINEAR_SOLVER_ITER= 10
94+
%
95+
% -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------%
96+
%
97+
CONV_NUM_METHOD_FLOW= FDS
98+
MUSCL_FLOW= NO
99+
SLOPE_LIMITER_FLOW = NONE
100+
TIME_DISCRE_FLOW= EULER_IMPLICIT
101+
%
102+
% -------------------- SCALAR TRANSPORT ---------------------------------------%
103+
%
104+
KIND_SCALAR_MODEL= SPECIES_TRANSPORT
105+
%
106+
DIFFUSIVITY_MODEL = UNITY_LEWIS
107+
%
108+
CONV_NUM_METHOD_SPECIES= BOUNDED_SCALAR
109+
MUSCL_SPECIES= NO
110+
SLOPE_LIMITER_SPECIES = NONE
111+
%
112+
TIME_DISCRE_SPECIES= EULER_IMPLICIT
113+
%
114+
SPECIES_INIT= 1.0
115+
SPECIES_CLIPPING= NO
116+
SPECIES_CLIPPING_MIN= 0.0
117+
SPECIES_CLIPPING_MAX= 1.0
118+
%
119+
% -------------------- TURBULENT TRANSPORT ---------------------------------------%
120+
%
121+
CONV_NUM_METHOD_TURB= BOUNDED_SCALAR
122+
MUSCL_TURB= NO
123+
%
124+
% --------------------------- CONVERGENCE PARAMETERS --------------------------%
125+
%
126+
CONV_FIELD= RMS_PRESSURE, RMS_VELOCITY-X, RMS_VELOCITY-Y, RMS_TKE, RMS_SPECIES
127+
CONV_RESIDUAL_MINVAL= -18
128+
CONV_STARTITER= 10
129+
%
130+
% ------------------------- INPUT/OUTPUT INFORMATION --------------------------%
131+
%
132+
MESH_FILENAME= rectangle_mixing.su2
133+
SCREEN_OUTPUT= INNER_ITER WALL_TIME \
134+
RMS_PRESSURE RMS_VELOCITY-X RMS_VELOCITY-Y RMS_ENTHALPY RMS_TKE RMS_DISSIPATION RMS_SPECIES_0 RMS_SPECIES_1 \
135+
LINSOL_ITER LINSOL_RESIDUAL \
136+
LINSOL_ITER_TURB LINSOL_RESIDUAL_TURB \
137+
LINSOL_ITER_SPECIES LINSOL_RESIDUAL_SPECIES \
138+
SURFACE_SPECIES_0
139+
SCREEN_WRT_FREQ_INNER= 10
140+
%
141+
HISTORY_OUTPUT= ITER RMS_RES LINSOL SPECIES_COEFF SPECIES_COEFF_SURF
142+
CONV_FILENAME= history
143+
MARKER_ANALYZE= gas_inlet, air_inlet, outlet
144+
MARKER_ANALYZE_AVERAGE= AREA
145+
%
146+
OUTPUT_FILES= RESTART_ASCII, PARAVIEW_MULTIBLOCK
147+
VOLUME_OUTPUT= RESIDUAL, PRIMITIVE
148+
OUTPUT_WRT_FREQ= 100
149+
%
150+
RESTART_SOL= NO
151+
READ_BINARY_RESTART= NO

config_template.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ INC_DENSITY_MODEL= CONSTANT
256256
% Solve the energy equation in the incompressible flow solver
257257
INC_ENERGY_EQUATION = NO
258258
%
259+
% Temperature limits for incompressible flows (0.0, 5000.0 K by default).
260+
TEMPERATURE_LIMITS= 0.0, 5000.0
261+
%
259262
% Initial density for incompressible flows
260263
% (1.2886 kg/m^3 by default (air), 998.2 Kg/m^3 (water))
261264
INC_DENSITY_INIT= 1.2886

0 commit comments

Comments
 (0)