diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 36e802e99f6..bf5bbd0684c 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -508,6 +508,7 @@ class CConfig { CONDUCTIVITYMODEL_TURB Kind_ConductivityModel_Turb; /*!< \brief Kind of the Turbulent Thermal Conductivity Model */ DIFFUSIVITYMODEL Kind_Diffusivity_Model; /*!< \brief Kind of the mass diffusivity Model */ FREESTREAM_OPTION Kind_FreeStreamOption; /*!< \brief Kind of free stream option to choose if initializing with density or temperature */ + INIT_OPTION_INC Kind_InitOption_Inc; /*!< \brief Kind of initialization of the incompressible solver. */ MAIN_SOLVER Kind_Solver; /*!< \brief Kind of solver: Euler, NS, Continuous adjoint, etc. */ LIMITER Kind_SlopeLimit, /*!< \brief Slope limiter (for the runtime eq. system). */ Kind_SlopeLimit_Flow, /*!< \brief Slope limiter for flow equations.*/ @@ -4114,6 +4115,13 @@ class CConfig { * \return free stream option */ unsigned short GetKind_InitOption(void) const { return Kind_InitOption; } + + /*! + * \brief Get the initialization option of the incompressible solver. + * \return Initialization option of the incompressible solver. + */ + INIT_OPTION_INC GetKind_InitOption_Inc() const { return Kind_InitOption_Inc; } + /*! * \brief Get the value of the critical pressure. * \return Critical pressure. diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 03b00b23e3d..5669a6ec32a 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -751,6 +751,18 @@ static const MapType InitOption_Map = { MakePair("TD_CONDITIONS", TD_CONDITIONS) }; +/*! + * \brief Types of initialization of the incompressible solver. + */ +enum class INIT_OPTION_INC { + DENSITY_INIT, /*!< \brief Initialization with the initial density. */ + OPERATING_PRESSURE, /*!< \brief Initialization with the operating (thermodynamic) pressure. */ +}; +static const MapType InitOptionInc_Map = { + MakePair("DENSITY_INIT", INIT_OPTION_INC::DENSITY_INIT) + MakePair("OPERATING_PRESSURE", INIT_OPTION_INC::OPERATING_PRESSURE) +}; + /*! * \brief Types of freestream specification */ diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index d5c403d9ab1..0d257b77148 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1425,6 +1425,10 @@ void CConfig::SetConfig_Options() { addDoubleOption("MACH_NUMBER", Mach, 0.0); /*!\brief INIT_OPTION \n DESCRIPTION: Init option to choose between Reynolds or thermodynamics quantities for initializing the solution \n OPTIONS: see \link InitOption_Map \endlink \n DEFAULT REYNOLDS \ingroup Config*/ addEnumOption("INIT_OPTION", Kind_InitOption, InitOption_Map, REYNOLDS); + /*!\brief INIT_OPTION_INC \n DESCRIPTION: Init option for the incompressible solver to choose between the initial + * density and the operating pressure for initializing the solution \n OPTIONS: see \link InitOptionInc_Map \endlink + * \n DEFAULT: fluid model dependent \ingroup Config*/ + addEnumOption("INIT_OPTION_INC", Kind_InitOption_Inc, InitOptionInc_Map, INIT_OPTION_INC::DENSITY_INIT); /* DESCRIPTION: Free-stream option to choose between density and temperature for initializing the solution */ addEnumOption("FREESTREAM_OPTION", Kind_FreeStreamOption, FreeStreamOption_Map, FREESTREAM_OPTION::TEMPERATURE_FS); /*!\brief FREESTREAM_PRESSURE\n DESCRIPTION: Free-stream pressure (101325.0 N/m^2 by default) \ingroup Config*/ @@ -5398,6 +5402,18 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i } } + /*--- Without an explicit INIT_OPTION_INC each fluid model keeps the density it used before the option existed. ---*/ + + if (!OptionIsSet("INIT_OPTION_INC")) { + if (Kind_FluidModel == FLUID_MIXTURE || Kind_FluidModel == FLUID_FLAMELET) { + Kind_InitOption_Inc = INIT_OPTION_INC::OPERATING_PRESSURE; + } else { + Kind_InitOption_Inc = INIT_OPTION_INC::DENSITY_INIT; + } + } else if (Kind_FluidModel == CONSTANT_DENSITY && Kind_InitOption_Inc == INIT_OPTION_INC::OPERATING_PRESSURE) { + SU2_MPI::Error("CONSTANT_DENSITY fluid model can only be used with INIT_OPTION_INC= DENSITY_INIT.", CURRENT_FUNCTION); + } + if (Kind_Solver != MAIN_SOLVER::INC_EULER && Kind_Solver != MAIN_SOLVER::INC_NAVIER_STOKES && Kind_Solver != MAIN_SOLVER::INC_RANS) { if ((Kind_FluidModel == CONSTANT_DENSITY) || (Kind_FluidModel == INC_IDEAL_GAS) || (Kind_FluidModel == INC_IDEAL_GAS_POLY)) { SU2_MPI::Error("Fluid model not compatible with compressible flows.\n CONSTANT_DENSITY/INC_IDEAL_GAS/INC_IDEAL_GAS_POLY are for incompressible only.", CURRENT_FUNCTION); diff --git a/SU2_CFD/include/fluid/CFluidModel.hpp b/SU2_CFD/include/fluid/CFluidModel.hpp index 4072a82c907..0e0c2e624bd 100644 --- a/SU2_CFD/include/fluid/CFluidModel.hpp +++ b/SU2_CFD/include/fluid/CFluidModel.hpp @@ -381,6 +381,11 @@ class CFluidModel { */ void SetEddyViscosity(su2double val_Mu_Turb) { Mu_Turb = val_Mu_Turb; } + /*! + * \brief Set the thermodynamic pressure of the incompressible fluid models. + */ + void SetPressure(su2double val_pressure) { Pressure = val_pressure; } + /*! * \brief Get fluid model extrapolation instance * \return Query point lies outside fluid model data range. diff --git a/SU2_CFD/include/fluid/CFluidScalar.hpp b/SU2_CFD/include/fluid/CFluidScalar.hpp index 797fdd20a47..a9b0e0e798d 100644 --- a/SU2_CFD/include/fluid/CFluidScalar.hpp +++ b/SU2_CFD/include/fluid/CFluidScalar.hpp @@ -41,7 +41,6 @@ class CFluidScalar final : public CFluidModel { private: const int n_species_mixture; /*!< \brief Number of species in mixture. */ su2double Gas_Constant; /*!< \brief Specific gas constant. */ - const su2double Pressure_Thermodynamic; /*!< \brief Constant pressure thermodynamic. */ const su2double GasConstant_Ref; /*!< \brief Gas constant reference needed for Nondimensional problems. */ const su2double Std_Ref_Temp_ND; /*!< \brief Nondimensional standard reference temperature for enthalpy. */ const su2double Prandtl_Turb_Number; /*!< \brief Prandlt turbulent number.*/ diff --git a/SU2_CFD/src/fluid/CFluidScalar.cpp b/SU2_CFD/src/fluid/CFluidScalar.cpp index ea38cd0d205..da84f4cb04d 100644 --- a/SU2_CFD/src/fluid/CFluidScalar.cpp +++ b/SU2_CFD/src/fluid/CFluidScalar.cpp @@ -44,13 +44,14 @@ CFluidScalar::CFluidScalar(su2double value_pressure_operating, const CConfig* config) : CFluidModel(), n_species_mixture(config->GetnSpecies() + 1), - Pressure_Thermodynamic(value_pressure_operating), GasConstant_Ref(config->GetGas_Constant_Ref()), Std_Ref_Temp_ND(STD_REF_TEMP / config->GetTemperature_Ref()), Prandtl_Turb_Number(config->GetPrandtl_Turb()), Schmidt_Turb_Number(config->GetSchmidt_Number_Turbulent()), wilke(config->GetKind_MixingViscosityModel() == MIXINGVISCOSITYMODEL::WILKE), davidson(config->GetKind_MixingViscosityModel() == MIXINGVISCOSITYMODEL::DAVIDSON) { + Pressure = value_pressure_operating; + if (n_species_mixture > ARRAYSIZE) { SU2_MPI::Error("Too many species, increase ARRAYSIZE", CURRENT_FUNCTION); } @@ -247,7 +248,7 @@ void CFluidScalar::SetTDState_T(const su2double val_temperature, const su2double MassToMoleFractions(val_scalars); ComputeGasConstant(); Temperature = val_temperature; - Density = Pressure_Thermodynamic / (Temperature * Gas_Constant); + Density = Pressure / (Temperature * Gas_Constant); Cp = ComputeMeanSpecificHeatCp(val_scalars); Cv = Cp - Gas_Constant; Enthalpy = ComputeEnthalpyFromT(Temperature, val_scalars); @@ -272,7 +273,7 @@ void CFluidScalar::SetTDState_h(const su2double val_enthalpy, const su2double* v * expression h_s = Cp(T - T_ref). */ Temperature = val_enthalpy / Cp + Std_Ref_Temp_ND; - Density = Pressure_Thermodynamic / (Temperature * Gas_Constant); + Density = Pressure / (Temperature * Gas_Constant); Cv = Cp - Gas_Constant; if (wilke) { diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 36ec2da234b..512a99a97dc 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -286,6 +286,7 @@ void CIncEulerSolver::SetNondimensionalization(CConfig *config, unsigned short i bool tkeNeeded = ((turbulent) && ((config->GetKind_Turb_Model() == TURB_MODEL::SST))); bool energy = config->GetEnergy_Equation(); bool boussinesq = (config->GetKind_DensityModel() == INC_DENSITYMODEL::BOUSSINESQ); + bool density_init = (config->GetKind_InitOption_Inc() == INIT_OPTION_INC::DENSITY_INIT); /*--- Compute dimensional free-stream values. ---*/ @@ -309,6 +310,17 @@ void CIncEulerSolver::SetNondimensionalization(CConfig *config, unsigned short i } ModVel_FreeStream = sqrt(ModVel_FreeStream); config->SetModVel_FreeStream(ModVel_FreeStream); + const su2double* scalar_init = nullptr; + if (config->GetKind_Species_Model() != SPECIES_MODEL::NONE) scalar_init = config->GetSpecies_Init(); + + /*--- Build the fluid model at the operating pressure, it is rescaled below for density initialization. ---*/ + + const bool constant_density = (config->GetKind_FluidModel() == CONSTANT_DENSITY); + if (!constant_density) { + config->SetGas_Constant(UNIVERSAL_GAS_CONSTANT/(config->GetMolecular_Weight()/1000.0)); + Pressure_Thermodynamic = config->GetPressure_Thermodynamic(); + } + CFluidModel* auxFluidModel = nullptr; switch (config->GetKind_FluidModel()) { @@ -316,23 +328,15 @@ void CIncEulerSolver::SetNondimensionalization(CConfig *config, unsigned short i case CONSTANT_DENSITY: auxFluidModel = new CConstantDensity(Density_FreeStream, config->GetSpecific_Heat_Cp(), Temperature_FreeStream); - auxFluidModel->SetTDState_T(Temperature_FreeStream); break; case INC_IDEAL_GAS: - config->SetGas_Constant(UNIVERSAL_GAS_CONSTANT/(config->GetMolecular_Weight()/1000.0)); - Pressure_Thermodynamic = Density_FreeStream*Temperature_FreeStream*config->GetGas_Constant(); auxFluidModel = new CIncIdealGas(config->GetSpecific_Heat_Cp(), config->GetGas_Constant(), Pressure_Thermodynamic, STD_REF_TEMP); - auxFluidModel->SetTDState_T(Temperature_FreeStream); - Pressure_Thermodynamic = auxFluidModel->GetPressure(); - config->SetPressure_Thermodynamic(Pressure_Thermodynamic); break; case INC_IDEAL_GAS_POLY: - config->SetGas_Constant(UNIVERSAL_GAS_CONSTANT/(config->GetMolecular_Weight()/1000.0)); - Pressure_Thermodynamic = Density_FreeStream*Temperature_FreeStream*config->GetGas_Constant(); auxFluidModel = new CIncIdealGasPolynomial(config->GetGas_Constant(), Pressure_Thermodynamic, STD_REF_TEMP); if (viscous) { /*--- Variable Cp model via polynomial. ---*/ @@ -340,26 +344,16 @@ void CIncEulerSolver::SetNondimensionalization(CConfig *config, unsigned short i config->SetCp_PolyCoeffND(config->GetCp_PolyCoeff(iVar), iVar); auxFluidModel->SetCpModel(config, Temperature_FreeStream); } - auxFluidModel->SetTDState_T(Temperature_FreeStream); - Pressure_Thermodynamic = auxFluidModel->GetPressure(); - config->SetPressure_Thermodynamic(Pressure_Thermodynamic); break; case FLUID_MIXTURE: - config->SetGas_Constant(UNIVERSAL_GAS_CONSTANT / (config->GetMolecular_Weight() / 1000.0)); - Pressure_Thermodynamic = config->GetPressure_Thermodynamic(); auxFluidModel = new CFluidScalar(Pressure_Thermodynamic, config); - auxFluidModel->SetTDState_T(Temperature_FreeStream, config->GetSpecies_Init()); break; case FLUID_FLAMELET: - config->SetGas_Constant(UNIVERSAL_GAS_CONSTANT / (config->GetMolecular_Weight() / 1000.0)); - Pressure_Thermodynamic = config->GetPressure_Thermodynamic(); auxFluidModel = new CFluidFlamelet(config, Pressure_Thermodynamic); - config->SetPressure_Thermodynamic(Pressure_Thermodynamic); - auxFluidModel->SetTDState_T(Temperature_FreeStream, config->GetSpecies_Init()); break; default: @@ -368,6 +362,25 @@ void CIncEulerSolver::SetNondimensionalization(CConfig *config, unsigned short i break; } + auxFluidModel->SetTDState_T(Temperature_FreeStream, scalar_init); + + /*--- Density is proportional to the thermodynamic pressure, match one of the two to the initial value. + The flamelet manifold tabulates the density, there the pressure cannot change it. ---*/ + + const bool tabulated_density = (config->GetKind_DensityModel() == INC_DENSITYMODEL::FLAMELET); + + if (!constant_density) { + if (density_init && !tabulated_density) { + Pressure_Thermodynamic *= Density_FreeStream/auxFluidModel->GetDensity(); + auxFluidModel->SetPressure(Pressure_Thermodynamic); + auxFluidModel->SetTDState_T(Temperature_FreeStream, scalar_init); + } else { + Density_FreeStream = auxFluidModel->GetDensity(); + config->SetDensity_FreeStream(Density_FreeStream); + } + config->SetPressure_Thermodynamic(Pressure_Thermodynamic); + } + if (viscous) { for (iVar = 0; iVar < config->GetnPolyCoeffs(); iVar++) @@ -634,6 +647,8 @@ void CIncEulerSolver::SetNondimensionalization(CConfig *config, unsigned short i case INC_DENSITYMODEL::FLAMELET: cout << "Energy equation is disabled and density is obtained through flamelet manifold." << endl; + if (config->OptionIsSet("INIT_OPTION_INC")) + cout << "INIT_OPTION_INC is not used, the density is looked up in the flamelet manifold." << endl; break; } diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index b18917e77ba..87edd6666a1 100755 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -86,7 +86,7 @@ def main(): flame_init_methods.new_output = True test_list.append(flame_init_methods) - # 2D laminar premixed ch4-air flame, transient flame propagation + # 2D laminar premixed ch4-air flame, transient flame propagation cfd_flamelet_ch4_unsteady = TestCase('cfd_flamelet_ch4_unsteady') cfd_flamelet_ch4_unsteady.cfg_dir = "flamelet/09_laminar_premixed_ch4_flame_unsteady" cfd_flamelet_ch4_unsteady.cfg_file = "lam_prem_ch4_unsteady.cfg" @@ -1769,7 +1769,7 @@ def main(): species2_primitiveVenturi_mixingmodel_viscosity.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_viscosity.cfg_file = "species2_primitiveVenturi_mixingmodel_viscosity.cfg" species2_primitiveVenturi_mixingmodel_viscosity.test_iter = 50 - species2_primitiveVenturi_mixingmodel_viscosity.test_vals = [-5.239996, -3.625478, -3.874990, -7.535233, -5.130497, 5.000000, -1.677719, 5.000000, -3.494206, 5.000000, -2.085734, 2.494985, 0.985388, 0.599841, 0.909757] + species2_primitiveVenturi_mixingmodel_viscosity.test_vals = [-5.243310, -3.635941, -3.892111, -7.558656, -5.131491, 5.000000, -1.668102, 5.000000, -3.474705, 5.000000, -2.085931, 2.494619, 0.985334, 0.599879, 0.909406] test_list.append(species2_primitiveVenturi_mixingmodel_viscosity) # 2 species (1 eq) primitive venturi mixing using mixing model including heat capacity and mass diffusivity @@ -1777,7 +1777,7 @@ def main(): species2_primitiveVenturi_mixingmodel_heatcapacity_H2.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_heatcapacity_H2.cfg_file = "species2_primitiveVenturi_mixingmodel_heatcapacity_H2.cfg" species2_primitiveVenturi_mixingmodel_heatcapacity_H2.test_iter = 50 - species2_primitiveVenturi_mixingmodel_heatcapacity_H2.test_vals = [-5.815955, -4.624944, -4.555357, -6.656244, 2.075950, -5.479969, 30.000000, -7.342937, 12.000000, -8.030131, 8.000000, -8.931183, 2.092270, 1.000000, 0.600000, 0.492270] + species2_primitiveVenturi_mixingmodel_heatcapacity_H2.test_vals = [-5.837690, -4.641815, -4.576060, -6.662811, 2.074231, -5.482861, 30.000000, -7.308120, 12.000000, -8.022273, 8.000000, -8.828506, 2.092336, 1.000000, 0.600000, 0.492336] test_list.append(species2_primitiveVenturi_mixingmodel_heatcapacity_H2) # 2 species (1 eq) primitive venturi mixing using mixing model including heat capacity and mass diffusivity NonDimensional case @@ -1785,7 +1785,7 @@ def main(): species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.cfg_file = "species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.cfg" species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.test_iter = 50 - species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.test_vals = [-5.404273, -4.918833, -4.841423, -7.647725, 1.772604, -5.085765, 10.000000, -2.745490, 3.000000, -5.207707, 5.000000, -5.863162, 2.092298, 1.000000, 0.600000, 0.492298] + species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.test_vals = [-5.706757, -5.216206, -5.142503, -7.926926, 1.492326, -5.366923, 10.000000, -2.738884, 3.000000, -5.208126, 5.000000, -5.742459, 2.092365, 1.000000, 0.600000, 0.492365] test_list.append(species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND) # 2 species (1 eq) primitive venturi mixing using mixing model solving enthalpy equation using preconditioning + JST convective scheme @@ -1825,7 +1825,7 @@ def main(): species2_primitiveVenturi_mixingmodel_TURBULENT_MARKERS.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_TURBULENT_MARKERS.cfg_file = "species2_primitiveVenturi_mixingmodel_TURBULENT_MARKERS.cfg" species2_primitiveVenturi_mixingmodel_TURBULENT_MARKERS.test_iter = 50 - species2_primitiveVenturi_mixingmodel_TURBULENT_MARKERS.test_vals = [-4.847447, -1.922191, -1.947568, -0.716575, 1.211626, -3.930420, 21.000000, -5.152536, 9.000000, -5.329555, 4.000000, -5.865224, 2.000000, 1.000000, 0.000000, 1.000000] + species2_primitiveVenturi_mixingmodel_TURBULENT_MARKERS.test_vals = [-4.847325, -1.922154, -1.947527, -0.716546, 1.211740, -3.930346, 21.000000, -5.152522, 9.000000, -5.325373, 4.000000, -5.865914, 2.000000, 1.000000, 0.000000, 1.000000] test_list.append(species2_primitiveVenturi_mixingmodel_TURBULENT_MARKERS) # 3 species (2 eq) primitive venturi mixing with inlet files. @@ -1868,7 +1868,7 @@ def main(): species3_multizone_restart.cfg_dir = "species_transport/multizone" species3_multizone_restart.cfg_file = "configMaster.cfg" species3_multizone_restart.test_iter = 5 - species3_multizone_restart.test_vals = [-4.634924, -4.516692] + species3_multizone_restart.test_vals = [-4.621056, -4.492840] species3_multizone_restart.multizone = True test_list.append(species3_multizone_restart) diff --git a/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_operatingpressure.cfg b/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_operatingpressure.cfg new file mode 100644 index 00000000000..6e5e0d27405 --- /dev/null +++ b/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_operatingpressure.cfg @@ -0,0 +1,144 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: Species mixing with 2 species, i.e. 1 transport equations % +% The density follows from the operating pressure instead of % +% from INC_DENSITY_INIT, see INIT_OPTION_INC. % +% Author: Cristopher Morales Ubal % +% Institution: Eindhoven University of Technology % +% Date: 2022/06/15 % +% File Version 8.5.0 "Harrier" % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +SOLVER= INC_RANS +KIND_TURB_MODEL= SST +% +% ---------------- INCOMPRESSIBLE FLOW CONDITION DEFINITION -------------------% +% +INC_DENSITY_MODEL= VARIABLE +INC_DENSITY_INIT= 1.0 +% +INC_VELOCITY_INIT= ( 1.00, 0.0, 0.0 ) +% +INC_ENERGY_EQUATION= YES +INC_TEMPERATURE_INIT= 300.0 +% +INC_NONDIM= DIMENSIONAL +% +INIT_OPTION_INC= OPERATING_PRESSURE +% +% -------------------- FLUID PROPERTIES ------------------------------------- % +% +FLUID_MODEL= INC_IDEAL_GAS +% +THERMODYNAMIC_PRESSURE= 101325.0 +% +MOLECULAR_WEIGHT= 28.96 +% +SPECIFIC_HEAT_CP = 1009.39 +% +CONDUCTIVITY_MODEL= CONSTANT_CONDUCTIVITY +THERMAL_CONDUCTIVITY_CONSTANT= 0.0357 +% +PRANDTL_LAM= 0.72 +TURBULENT_CONDUCTIVITY_MODEL= NONE +PRANDTL_TURB= 0.90 +% --------------------------- VISCOSITY MODEL ---------------------------------% +% +VISCOSITY_MODEL= CONSTANT_VISCOSITY +% +MU_CONSTANT= 1.716E-5 +% +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +MARKER_HEATFLUX= ( wall, 0.0 ) +MARKER_SYM= ( axis ) +% +SPECIFIED_INLET_PROFILE= NO +INLET_FILENAME= inlet_venturi.dat +INC_INLET_TYPE= VELOCITY_INLET VELOCITY_INLET +MARKER_INLET= ( gas_inlet, 300, 1.0, 1.0, 0.0, 0.0,\ + air_axial_inlet, 300, 1.0, 0.0, -1.0, 0.0 ) +MARKER_INLET_SPECIES= (gas_inlet, 1.0,\ + air_axial_inlet, 0.6) +% +INC_OUTLET_TYPE= PRESSURE_OUTLET +MARKER_OUTLET= ( outlet, 0.0) +% +% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% +% +NUM_METHOD_GRAD= WEIGHTED_LEAST_SQUARES +% +CFL_NUMBER= 60 +CFL_REDUCTION_SPECIES= 1.0 +CFL_REDUCTION_TURB= 1.0 +% +ITER= 1000 +% +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +LINEAR_SOLVER= FGMRES +LINEAR_SOLVER_PREC= ILU +LINEAR_SOLVER_ERROR= 1E-8 +LINEAR_SOLVER_ITER= 5 +% +% -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------% +% +CONV_NUM_METHOD_FLOW= FDS +MUSCL_FLOW= YES +SLOPE_LIMITER_FLOW = NONE +TIME_DISCRE_FLOW= EULER_IMPLICIT +% +% -------------------- SCALAR TRANSPORT ---------------------------------------% +% +KIND_SCALAR_MODEL= SPECIES_TRANSPORT +DIFFUSIVITY_MODEL= CONSTANT_DIFFUSIVITY +DIFFUSIVITY_CONSTANT= 0.001 +% +CONV_NUM_METHOD_SPECIES= SCALAR_UPWIND +MUSCL_SPECIES= NO +SLOPE_LIMITER_SPECIES = NONE +% +TIME_DISCRE_SPECIES= EULER_IMPLICIT +% +SPECIES_INIT= 1.0 +SPECIES_CLIPPING= YES +SPECIES_CLIPPING_MIN= 0.0 +SPECIES_CLIPPING_MAX= 1.0 +% +% -------------------- TURBULENT TRANSPORT ---------------------------------------% +% +CONV_NUM_METHOD_TURB= SCALAR_UPWIND +MUSCL_TURB= NO +% +% --------------------------- CONVERGENCE PARAMETERS --------------------------% +% +CONV_FIELD= RMS_PRESSURE, RMS_VELOCITY-X, RMS_VELOCITY-Y, RMS_TKE, RMS_SPECIES +CONV_RESIDUAL_MINVAL= -18 +CONV_STARTITER= 10 +% +% ------------------------- INPUT/OUTPUT INFORMATION --------------------------% +% +MESH_FILENAME= primitiveVenturi.su2 +SCREEN_OUTPUT= INNER_ITER WALL_TIME \ + RMS_PRESSURE RMS_VELOCITY-X RMS_VELOCITY-Y RMS_TKE RMS_DISSIPATION RMS_SPECIES_0 \ + LINSOL_ITER LINSOL_RESIDUAL \ + LINSOL_ITER_TURB LINSOL_RESIDUAL_TURB \ + LINSOL_ITER_SPECIES LINSOL_RESIDUAL_SPECIES SURFACE_SPECIES_VARIANCE +SCREEN_WRT_FREQ_INNER= 10 +% +HISTORY_OUTPUT= RMS_RES FLOW_COEFF LINSOL SPECIES_COEFF SPECIES_COEFF_SURF +MARKER_ANALYZE= outlet gas_inlet air_axial_inlet +% +OUTPUT_FILES= RESTART_ASCII, PARAVIEW_MULTIBLOCK +VOLUME_OUTPUT= RESIDUAL, PRIMITIVE +OUTPUT_WRT_FREQ= 1000 +% +RESTART_SOL= NO +SOLUTION_FILENAME= solution +RESTART_FILENAME= restart +% +WRT_PERFORMANCE= YES diff --git a/TestCases/tutorials.py b/TestCases/tutorials.py index d0a36dc34ce..664acf01cad 100644 --- a/TestCases/tutorials.py +++ b/TestCases/tutorials.py @@ -165,7 +165,7 @@ def main(): kenics_mixer_tutorial.cfg_dir = "../Tutorials/incompressible_flow/Inc_Species_Transport_Composition_Dependent_Model" kenics_mixer_tutorial.cfg_file = "kenics_mixer_tutorial.cfg" kenics_mixer_tutorial.test_iter = 10 - kenics_mixer_tutorial.test_vals = [-7.490438, -6.823937, -6.838581, -6.383852, -7.879414, -3.004710, -7.452189, 5.000000, -1.857319, 4.000000, -5.336948, 3.000000, -6.369478, 0.025670, 0.000000, 0.025670, 0.000000, 62.718000, 8.462700, 46.726000, 7.529400] + kenics_mixer_tutorial.test_vals = [-7.490448, -6.823978, -6.838620, -6.383873, -7.878123, -3.003654, -7.452198, 5.000000, -1.857226, 4.000000, -5.336949, 3.000000, -6.363373, 0.025668, 0.000000, 0.025668, 0.000000, 62.717000, 8.462600, 46.725000, 7.529400] kenics_mixer_tutorial.command = TestCase.Command("mpirun -n 2", "SU2_CFD") test_list.append(kenics_mixer_tutorial) diff --git a/UnitTests/Common/CConfig_tests.cpp b/UnitTests/Common/CConfig_tests.cpp new file mode 100644 index 00000000000..11191878554 --- /dev/null +++ b/UnitTests/Common/CConfig_tests.cpp @@ -0,0 +1,89 @@ +/*! + * \file CConfig_tests.cpp + * \brief Unit tests for option defaults that depend on other options. + * \author SU2 Contributors + * \version 8.5.0 "Harrier" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2026, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "catch.hpp" +#include +#include +#include "../../Common/include/CConfig.hpp" + +namespace { + +/*--- Minimal incompressible case on a box mesh, the options under test are appended to it. ---*/ +const std::string base_options = + "SOLVER= INC_NAVIER_STOKES\n" + "MESH_FORMAT= BOX\n" + "MESH_BOX_SIZE= 5,5,5\n" + "MESH_BOX_LENGTH= 1,1,1\n" + "MESH_BOX_OFFSET= 0,0,0\n" + "MARKER_HEATFLUX= (y_minus, 0.0, y_plus, 0.0)\n" + "MARKER_CUSTOM= (x_minus, x_plus, z_plus, z_minus)\n" + "INC_DENSITY_INIT= 1.1766\n" + "INC_TEMPERATURE_INIT= 300.0\n" + "VISCOSITY_MODEL= CONSTANT_VISCOSITY\n"; + +INIT_OPTION_INC GetInitOptionInc(const std::string& options) { + std::stringstream ss(base_options + options); + auto* orig_buf = std::cout.rdbuf(nullptr); + CConfig config(ss, SU2_COMPONENT::SU2_CFD, false); + std::cout.rdbuf(orig_buf); + return config.GetKind_InitOption_Inc(); +} + +const std::string ideal_gas_options = + "INC_DENSITY_MODEL= VARIABLE\n" + "INC_ENERGY_EQUATION= YES\n" + "FLUID_MODEL= INC_IDEAL_GAS\n"; + +const std::string mixture_options = + "INC_DENSITY_MODEL= VARIABLE\n" + "INC_ENERGY_EQUATION= YES\n" + "FLUID_MODEL= FLUID_MIXTURE\n" + "KIND_SCALAR_MODEL= SPECIES_TRANSPORT\n" + "SPECIES_INIT= 1.0\n" + "MOLECULAR_WEIGHT= 28.96, 16.043\n" + "SPECIFIC_HEAT_CP= 1009.39, 2225.0\n" + "MARKER_SPECIES_STRONG_BC= (x_minus)\n" + "MU_CONSTANT= 1.8551e-05, 1.1e-05\n" + "PRANDTL_LAM= 0.72, 0.72\n" + "PRANDTL_TURB= 0.9, 0.9\n" + "DIFFUSIVITY_CONSTANT= 1.0e-05\n"; + +} // namespace + +TEST_CASE("INIT_OPTION_INC defaults", "[Config]") { + /*--- Without the option each fluid model keeps the density it used before INIT_OPTION_INC existed. ---*/ + + CHECK(GetInitOptionInc(ideal_gas_options) == INIT_OPTION_INC::DENSITY_INIT); + CHECK(GetInitOptionInc(mixture_options) == INIT_OPTION_INC::OPERATING_PRESSURE); + CHECK(GetInitOptionInc("INC_DENSITY_MODEL= CONSTANT\n") == INIT_OPTION_INC::DENSITY_INIT); + + /*--- An explicit setting overrides the default. ---*/ + + CHECK(GetInitOptionInc(ideal_gas_options + "INIT_OPTION_INC= OPERATING_PRESSURE\n") == + INIT_OPTION_INC::OPERATING_PRESSURE); + CHECK(GetInitOptionInc(ideal_gas_options + "INIT_OPTION_INC= DENSITY_INIT\n") == INIT_OPTION_INC::DENSITY_INIT); +} diff --git a/UnitTests/meson.build b/UnitTests/meson.build index aadf034688f..fc99bc101b3 100644 --- a/UnitTests/meson.build +++ b/UnitTests/meson.build @@ -4,7 +4,8 @@ # ------------------------------------------------------------------------- # Direct-mode tests: -su2_cfd_tests = files(['Common/geometry/primal_grid/CPrimalGrid_tests.cpp', +su2_cfd_tests = files(['Common/CConfig_tests.cpp', + 'Common/geometry/primal_grid/CPrimalGrid_tests.cpp', 'Common/geometry/dual_grid/CDualGrid_tests.cpp', 'Common/geometry/CGeometry_test.cpp', 'Common/toolboxes/CQuasiNewtonInvLeastSquares_tests.cpp', diff --git a/config_template.cfg b/config_template.cfg index f2aa561f961..7fefa98aa6f 100644 --- a/config_template.cfg +++ b/config_template.cfg @@ -315,6 +315,13 @@ INC_TEMPERATURE_INIT= 288.15 % INC_*_REF values are ignored unless REFERENCE_VALUES is chosen. INC_NONDIM= INITIAL_VALUES % +% Init option for the incompressible solver to choose between the initial density and the operating +% pressure for initializing the solution (DENSITY_INIT, OPERATING_PRESSURE). The default depends on the +% fluid model: DENSITY_INIT for INC_IDEAL_GAS and INC_IDEAL_GAS_POLY, OPERATING_PRESSURE for +% FLUID_MIXTURE and FLUID_FLAMELET. Not used by CONSTANT_DENSITY, nor by INC_DENSITY_MODEL= FLAMELET +% where the density is looked up in the flamelet manifold. +% INIT_OPTION_INC= DENSITY_INIT +% % Reference density for incompressible flows (1.0 kg/m^3 by default) INC_DENSITY_REF= 1.0 %