From 332591803a45a0c756b61bc368ffa9473614b999 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Mon, 24 Jul 2023 15:09:21 +0200 Subject: [PATCH 01/34] Added preferential diffusion model and additional options for flamelet solution ignition --- Common/include/CConfig.hpp | 48 ++- Common/include/containers/CLookUpTable.hpp | 5 + Common/include/option_structure.hpp | 27 ++ Common/src/CConfig.cpp | 10 +- Common/src/containers/CLookUpTable.cpp | 14 + SU2_CFD/include/fluid/CFluidFlamelet.hpp | 15 +- SU2_CFD/include/fluid/CFluidModel.hpp | 63 ++-- .../solvers/CSpeciesFlameletSolver.hpp | 28 +- SU2_CFD/include/solvers/CSpeciesSolver.hpp | 2 +- SU2_CFD/src/fluid/CFluidFlamelet.cpp | 58 ++- .../src/solvers/CSpeciesFlameletSolver.cpp | 346 ++++++++++++++++-- .../variables/CSpeciesFlameletVariable.cpp | 5 + config_template.cfg | 35 +- 13 files changed, 572 insertions(+), 84 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index dd5bde0606c..a66e94be798 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -1220,8 +1220,12 @@ class CConfig { unsigned short nSpecies_Init; /*!< \brief Number of entries of SPECIES_INIT */ /*--- Additional flamelet solver options ---*/ - su2double flame_init[8]; /*!< \brief Initial solution parameters for flamelet solver.*/ - + FLAMELET_INIT_TYPE flame_init_type = FLAMELET_INIT_TYPE::NONE; /*!< \brief Method for solution ignition for flamelet problems. */ + su2double flame_init[8]; /*!< \brief Flame front initialization parameters. */ + su2double spark_init[6]; /*!< \brief Spark ignition initialization parameters. */ + su2double* spark_reaction_rates; /*!< \brief Source terms for flamelet spark ignition option. */ + bool preferential_diffusion = false; /*!< \brief Preferential diffusion physics for flamelet solver.*/ + /*--- lookup table ---*/ unsigned short n_scalars = 0; /*!< \brief Number of transported scalars for flamelet LUT approach. */ unsigned short n_lookups = 0; /*!< \brief Number of lookup variables, for visualization only. */ @@ -2130,13 +2134,44 @@ class CConfig { /*! * \brief Get the flame initialization. - * (x1,x2,x3) = flame offset. - * (x4,x5,x6) = flame normal, separating unburnt from burnt. + * (x1,x2,x3) = flame offset/spark center location. + * (x4,x5,x6) = flame normal, separating unburnt from burnt or + * spark radius, spark start iteration, spark duration. * (x7) = flame thickness, the length from unburnt to burnt conditions. * (x8) = flame burnt thickness, the length to stay at burnt conditions. - * \return Flame initialization for the flamelet model. + * \return Ignition initialization parameters for the flamelet model. + */ + const su2double* GetFlameInit() const { + switch (flame_init_type) + { + case FLAMELET_INIT_TYPE::FLAME_FRONT: + return flame_init; + break; + case FLAMELET_INIT_TYPE::SPARK: + return spark_init; + break; + default: + return nullptr; + break; + } + } + + /*! + * \brief Get species net reaction rates applied during spark ignition. + */ + const su2double* GetSpark() const { + return spark_reaction_rates; + } + + /*! + * \brief Preferential diffusion combustion problem. + */ + bool GetPreferentialDiffusion() const { return preferential_diffusion; } + + /*! + * \brief Define preferential diffusion combustion problem. */ - const su2double* GetFlameInit() const { return flame_init; } + inline void SetPreferentialDiffusion(bool input) { preferential_diffusion = input; } /*! * \brief Get the number of control variables for flamelet model. @@ -2182,6 +2217,7 @@ class CConfig { if (n_user_sources > 0) return user_source_names[i_user_source]; else return none; } + FLAMELET_INIT_TYPE GetFlameletInitType() const { return flame_init_type; } /*! * \brief Get the number of transported scalars for combustion. */ diff --git a/Common/include/containers/CLookUpTable.hpp b/Common/include/containers/CLookUpTable.hpp index be60704ebfa..0bb2c8a46d9 100644 --- a/Common/include/containers/CLookUpTable.hpp +++ b/Common/include/containers/CLookUpTable.hpp @@ -373,4 +373,9 @@ class CLookUpTable { inline std::pair GetTableLimitsX(unsigned long i_level = 0) const { return limits_table_x[i_level]; } + + /*! + * \brief Check whether provided set of variables are included in the table. + */ + bool CheckForVariables(const std::vector& vars_to_check); }; diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 0a5bdfc8205..ed9a20df717 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -1334,10 +1334,37 @@ enum FLAMELET_SCALAR_SOURCES { */ enum FLAMELET_LOOKUP_OPS { TD, /*!< \brief Thermochemical properties (temperature, density, diffusivity, etc.). */ + PD, /*!< \brief Preferential diffusion scalars. */ SOURCES, /*!< \brief Scalar source terms (controlling variables, passive species).*/ LOOKUP, /*!< \brief Passive look-up variables specified in config. */ }; +/*! + * \brief the preferential diffusion scalar indices for the preferential diffusion model. + */ +enum FLAMELET_PREF_DIFF_SCALARS { + I_BETA_PROGVAR, + I_BETA_ENTH_THERMAL, + I_BETA_ENTH, + I_BETA_MIXFRAC, + N_BETA_TERMS, +}; + +/*! + * \brief Flame initialization options for the flamelet solver. + */ +enum class FLAMELET_INIT_TYPE { + FLAME_FRONT, /*!< \brief Straight flame front. */ + SPARK, /*!< \brief Species reaction rate in a set location. */ + NONE, /*!< \brief No ignition, cold flow only. */ +}; + +static const MapType Flamelet_Init_Map = { + MakePair("NONE", FLAMELET_INIT_TYPE::NONE) + MakePair("FLAME_FRONT", FLAMELET_INIT_TYPE::FLAME_FRONT) + MakePair("SPARK", FLAMELET_INIT_TYPE::SPARK) +}; + /*! * \brief Types of subgrid scale models */ diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 23b84730103..f06173bf6b7 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1361,7 +1361,9 @@ void CConfig::SetConfig_Options() { /*!\brief SPECIES_CLIPPING_MIN \n DESCRIPTION: Minimum values for scalar clipping \ingroup Config*/ addDoubleListOption("SPECIES_CLIPPING_MIN", nSpecies_Clipping_Min, Species_Clipping_Min); - /*!\brief FLAME_INIT \n DESCRIPTION: flame initialization using the flamelet model \ingroup Config*/ + /*!\brief FLAME_INIT_METHOD \n DESCRIPTION: Ignition method for flamelet solver \n DEFAULT: no ignition; cold flow only. */ + addEnumOption("FLAME_INIT_METHOD", flame_init_type, Flamelet_Init_Map, FLAMELET_INIT_TYPE::NONE); + /*!\brief FLAME_INIT \n DESCRIPTION: flame front initialization using the flamelet model \ingroup Config*/ /*--- flame offset (x,y,z) ---*/ flame_init[0] = 0.0; flame_init[1] = 0.0; flame_init[2] = 0.0; /*--- flame normal (nx, ny, nz) ---*/ @@ -1370,6 +1372,12 @@ void CConfig::SetConfig_Options() { flame_init[6] = 0.5e-3; flame_init[7] = 1.0; addDoubleArrayOption("FLAME_INIT", 8,flame_init); + /*!\brief SPARK_INIT \n DESCRIPTION: spark initialization using the flamelet model \ingroup Config*/ + for (auto iSpark=0u; iSpark<6; ++iSpark) spark_init[iSpark]=0; + addDoubleArrayOption("SPARK_INIT", 6, spark_init); + /*!\brief SPARK_REACTION_RATES \n DESCRIPTION: Net source term values applied to species within spark area during spark ignition. \ingroup Config*/ + addDoubleListOption("SPARK_REACTION_RATES", nSpecies_Init, spark_reaction_rates); + /*--- Options related to mass diffusivity and thereby the species solver. ---*/ /*!\brief DIFFUSIVITY_MODEL\n DESCRIPTION: mass diffusivity model \n DEFAULT constant disffusivity \ingroup Config*/ diff --git a/Common/src/containers/CLookUpTable.cpp b/Common/src/containers/CLookUpTable.cpp index bff408de8d0..bddc1abdf3d 100644 --- a/Common/src/containers/CLookUpTable.cpp +++ b/Common/src/containers/CLookUpTable.cpp @@ -800,3 +800,17 @@ bool CLookUpTable::IsInTriangle(su2double val_CV1, su2double val_CV2, unsigned l return (abs(area_tri - (area_0 + area_1 + area_2)) < area_tri * 1e-10); } + +bool CLookUpTable::CheckForVariables(const std::vector& vars_to_check) { + bool variables_are_present {true}; + for (auto iVar=0u; iVar scalars_vector; vector varnames_TD, /*!< \brief Lookup names for thermodynamic state variables. */ - varnames_Sources, varnames_LookUp; + varnames_Sources, varnames_LookUp, varnames_PD; vector val_vars_TD, /*!< \brief References to thermodynamic state variables. */ - val_vars_Sources, val_vars_LookUp; + val_vars_Sources, val_vars_LookUp, val_vars_PD; void PreprocessLookUp(CConfig* config); @@ -127,4 +130,10 @@ class CFluidFlamelet final : public CFluidModel { * \param[out] Mu - value of the laminar viscosity */ inline su2double GetLaminarViscosity() override { return Mu; } + + /*! + * \brief Preferential diffusion as relevant phenomenon in flamelet simulations. + * \return Inclusion of preferential diffusion model. + */ + inline bool GetPreferentialDiffusion() const override { return PreferentialDiffusion; }; }; diff --git a/SU2_CFD/include/fluid/CFluidModel.hpp b/SU2_CFD/include/fluid/CFluidModel.hpp index aa7131f468e..b7c152d6828 100644 --- a/SU2_CFD/include/fluid/CFluidModel.hpp +++ b/SU2_CFD/include/fluid/CFluidModel.hpp @@ -46,34 +46,34 @@ class CLookUpTable; */ class CFluidModel { protected: - su2double StaticEnergy{0.0}; /*!< \brief Internal Energy. */ - su2double Entropy{0.0}; /*!< \brief Entropy. */ - su2double Density{0.0}; /*!< \brief Density. */ - su2double Pressure{0.0}; /*!< \brief Pressure. */ - su2double SoundSpeed2{0.0}; /*!< \brief SpeedSound. */ - su2double Temperature{0.0}; /*!< \brief Temperature. */ - su2double dPdrho_e{0.0}; /*!< \brief DpDd_e. */ - su2double dPde_rho{0.0}; /*!< \brief DpDe_d. */ - su2double dTdrho_e{0.0}; /*!< \brief DTDd_e. */ - su2double dTde_rho{0.0}; /*!< \brief DTDe_d. */ - su2double dhdrho_P{0.0}; /*!< \brief DhDrho_p. */ - su2double dhdP_rho{0.0}; /*!< \brief DhDp_rho. */ - su2double dsdrho_P{0.0}; /*!< \brief DsDrho_p. */ - su2double dsdP_rho{0.0}; /*!< \brief DsDp_rho. */ - su2double Cp{0.0}; /*!< \brief Specific Heat Capacity at constant pressure. */ - su2double Cv{0.0}; /*!< \brief Specific Heat Capacity at constant volume. */ - su2double Mu{0.0}; /*!< \brief Laminar viscosity. */ - su2double Mu_Turb{0.0}; /*!< \brief Eddy viscosity provided by a turbulence model. */ - su2double dmudrho_T{0.0}; /*!< \brief Partial derivative of viscosity w.r.t. density. */ - su2double dmudT_rho{0.0}; /*!< \brief Partial derivative of viscosity w.r.t. temperature. */ - su2double Kt{0.0}; /*!< \brief Thermal conductivity. */ - su2double dktdrho_T{0.0}; /*!< \brief Partial derivative of conductivity w.r.t. density. */ - su2double dktdT_rho{0.0}; /*!< \brief Partial derivative of conductivity w.r.t. temperature. */ - su2double mass_diffusivity{0.0}; /*!< \brief Mass Diffusivity */ + su2double StaticEnergy{0.0}; /*!< \brief Internal Energy. */ + su2double Entropy{0.0}; /*!< \brief Entropy. */ + su2double Density{0.0}; /*!< \brief Density. */ + su2double Pressure{0.0}; /*!< \brief Pressure. */ + su2double SoundSpeed2{0.0}; /*!< \brief SpeedSound. */ + su2double Temperature{0.0}; /*!< \brief Temperature. */ + su2double dPdrho_e{0.0}; /*!< \brief DpDd_e. */ + su2double dPde_rho{0.0}; /*!< \brief DpDe_d. */ + su2double dTdrho_e{0.0}; /*!< \brief DTDd_e. */ + su2double dTde_rho{0.0}; /*!< \brief DTDe_d. */ + su2double dhdrho_P{0.0}; /*!< \brief DhDrho_p. */ + su2double dhdP_rho{0.0}; /*!< \brief DhDp_rho. */ + su2double dsdrho_P{0.0}; /*!< \brief DsDrho_p. */ + su2double dsdP_rho{0.0}; /*!< \brief DsDp_rho. */ + su2double Cp{0.0}; /*!< \brief Specific Heat Capacity at constant pressure. */ + su2double Cv{0.0}; /*!< \brief Specific Heat Capacity at constant volume. */ + su2double Mu{0.0}; /*!< \brief Laminar viscosity. */ + su2double Mu_Turb{0.0}; /*!< \brief Eddy viscosity provided by a turbulence model. */ + su2double dmudrho_T{0.0}; /*!< \brief Partial derivative of viscosity w.r.t. density. */ + su2double dmudT_rho{0.0}; /*!< \brief Partial derivative of viscosity w.r.t. temperature. */ + su2double Kt{0.0}; /*!< \brief Thermal conductivity. */ + su2double dktdrho_T{0.0}; /*!< \brief Partial derivative of conductivity w.r.t. density. */ + su2double dktdT_rho{0.0}; /*!< \brief Partial derivative of conductivity w.r.t. temperature. */ + su2double mass_diffusivity{0.0}; /*!< \brief Mass Diffusivity */ unique_ptr LaminarViscosity; /*!< \brief Laminar Viscosity Model */ unique_ptr ThermalConductivity; /*!< \brief Thermal Conductivity Model */ - unique_ptr MassDiffusivity; /*!< \brief Mass Diffusivity Model */ + unique_ptr MassDiffusivity; /*!< \brief Mass Diffusivity Model */ /*! * \brief Instantiate the right type of viscosity model based on config. @@ -147,7 +147,10 @@ class CFluidModel { * \brief Evaluate data manifold for flamelet or data-driven fluid problems. * \param[in] input - input data for manifold regression. */ - virtual unsigned long EvaluateDataSet(const vector &input_scalar, unsigned short lookup_type, vector &output_refs) { return 0; } + virtual unsigned long EvaluateDataSet(const vector& input_scalar, unsigned short lookup_type, + vector& output_refs) { + return 0; + } /*! * \brief Get fluid dynamic viscosity. @@ -331,7 +334,7 @@ class CFluidModel { * \brief Virtual member. * \param[in] T - Temperature value at the point. */ - virtual void SetTDState_T(su2double val_Temperature, const su2double* val_scalars = nullptr) { } + virtual void SetTDState_T(su2double val_Temperature, const su2double* val_scalars = nullptr) {} /*! * \brief Set fluid eddy viscosity provided by a turbulence model needed for computing effective thermal conductivity. @@ -344,6 +347,12 @@ class CFluidModel { */ virtual unsigned long GetExtrapolation() const { return 0; } + /*! + * \brief Preferential diffusion as relevant phenomenon in flamelet simulations. + * \return Inclusion of preferential diffusion model. + */ + virtual bool GetPreferentialDiffusion() const { return false; } + /*! * \brief Get number of Newton solver iterations. * \return Newton solver iteration count at termination. diff --git a/SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp b/SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp index 514a3c9a863..aa01016bb9b 100644 --- a/SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp +++ b/SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp @@ -37,7 +37,6 @@ */ class CSpeciesFlameletSolver final : public CSpeciesSolver { private: - vector conjugate_var; /*!< \brief CHT variables for each boundary and vertex. */ bool include_mixture_fraction = false; /*!< \brief include mixture fraction as a controlling variable. */ /*! * \brief Compute the preconditioner for low-Mach flows. @@ -63,8 +62,8 @@ class CSpeciesFlameletSolver final : public CSpeciesSolver { * \param[in] val_enth_out - pointer to output enthalpy variable. * \param[out] Converged - 0 if Newton solver converged, 1 if not. */ - unsigned long GetEnthFromTemp(CFluidModel* fluid_model, su2double const val_temp, - const su2double* scalar_solution, su2double* val_enth_out); + unsigned long GetEnthFromTemp(CFluidModel* fluid_model, su2double const val_temp, const su2double* scalar_solution, + su2double* val_enth_out); /*! * \brief Find maximum progress variable value within the manifold for the current solution. @@ -97,6 +96,17 @@ class CSpeciesFlameletSolver final : public CSpeciesSolver { unsigned long SetScalarLookUps(const CConfig* config, CFluidModel* fluid_model_local, unsigned long iPoint, const vector& scalars); + /*! + * \brief Retrieve the preferential diffusion scalar values from manifold. + * \param[in] config - definition of particular problem. + * \param[in] fluid_model_local - pointer to flamelet fluid model. + * \param[in] iPoint - node ID. + * \param[in] scalars - local scalar solution. + * \return - within manifold bounds (0) or outside manifold bounds (1). + */ + unsigned long SetPreferentialDiffusionScalars(const CConfig* config, CFluidModel* fluid_model_local, + unsigned long iPoint, const vector& scalars); + public: /*! * \brief Constructor. @@ -175,4 +185,16 @@ class CSpeciesFlameletSolver final : public CSpeciesSolver { */ void BC_ConjugateHeat_Interface(CGeometry* geometry, CSolver** solver_container, CNumerics* numerics, CConfig* config, unsigned short val_marker) override; + + /*! + * \brief Compute the viscous fluxes of the flamelet species at a particular edge. + * \param[in] iEdge - Edge for which we want to compute the flux + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] numerics - Description of the numerical method. + * \param[in] config - Definition of the particular problem. + * \note Calls a generic implementation after defining a SolverSpecificNumerics object. + */ + void Viscous_Residual(unsigned long iEdge, CGeometry* geometry, CSolver** solver_container, CNumerics* numerics, + CConfig* config) final; }; diff --git a/SU2_CFD/include/solvers/CSpeciesSolver.hpp b/SU2_CFD/include/solvers/CSpeciesSolver.hpp index 1d4eef366de..92a5a26f7a5 100644 --- a/SU2_CFD/include/solvers/CSpeciesSolver.hpp +++ b/SU2_CFD/include/solvers/CSpeciesSolver.hpp @@ -90,7 +90,7 @@ class CSpeciesSolver : public CScalarSolver { * \note Calls a generic implementation after defining a SolverSpecificNumerics object. */ void Viscous_Residual(unsigned long iEdge, CGeometry* geometry, CSolver** solver_container, CNumerics* numerics, - CConfig* config) final; + CConfig* config) override; /*! * \brief Impose the inlet boundary condition. diff --git a/SU2_CFD/src/fluid/CFluidFlamelet.cpp b/SU2_CFD/src/fluid/CFluidFlamelet.cpp index f75a68700a5..6bc2cfdda33 100644 --- a/SU2_CFD/src/fluid/CFluidFlamelet.cpp +++ b/SU2_CFD/src/fluid/CFluidFlamelet.cpp @@ -93,6 +93,11 @@ CFluidFlamelet::CFluidFlamelet(CConfig* config, su2double value_pressure_operati Pressure = value_pressure_operating; PreprocessLookUp(config); + + config->SetPreferentialDiffusion(PreferentialDiffusion); + if (rank == MASTER_NODE) { + cout << "Preferential diffusion: " << (PreferentialDiffusion ? "Enabled" : "Disabled") << endl; + } } CFluidFlamelet::~CFluidFlamelet() { @@ -106,8 +111,10 @@ CFluidFlamelet::~CFluidFlamelet() { delete iomap_Sources; delete iomap_LookUp; delete lookup_mlp; + if (PreferentialDiffusion) delete iomap_PD; + s #endif - break; + break; default: break; } @@ -187,6 +194,39 @@ void CFluidFlamelet::PreprocessLookUp(CConfig* config) { val_vars_LookUp.resize(n_lookups); for (auto iLookup = 0u; iLookup < n_lookups; iLookup++) varnames_LookUp[iLookup] = config->GetLookupName(iLookup); + /*--- Preferential diffusion scalars ---*/ + varnames_PD.resize(FLAMELET_PREF_DIFF_SCALARS::N_BETA_TERMS); + val_vars_PD.resize(FLAMELET_PREF_DIFF_SCALARS::N_BETA_TERMS); + + varnames_PD[FLAMELET_PREF_DIFF_SCALARS::I_BETA_PROGVAR] = "Beta_ProgVar"; + varnames_PD[FLAMELET_PREF_DIFF_SCALARS::I_BETA_ENTH_THERMAL] = "Beta_Enth_Thermal"; + varnames_PD[FLAMELET_PREF_DIFF_SCALARS::I_BETA_ENTH] = "Beta_Enth"; + varnames_PD[FLAMELET_PREF_DIFF_SCALARS::I_BETA_MIXFRAC] = "Beta_MixFrac"; + + val_vars_PD[FLAMELET_PREF_DIFF_SCALARS::I_BETA_PROGVAR] = beta_progvar; + val_vars_PD[FLAMELET_PREF_DIFF_SCALARS::I_BETA_ENTH_THERMAL] = beta_enth_thermal; + val_vars_PD[FLAMELET_PREF_DIFF_SCALARS::I_BETA_ENTH] = beta_enth; + val_vars_PD[FLAMELET_PREF_DIFF_SCALARS::I_BETA_MIXFRAC] = beta_mixfrac; + + size_t n_betas{0}; + PreferentialDiffusion = false; + switch (Kind_DataDriven_Method) { + case ENUM_DATADRIVEN_METHOD::LUT: + PreferentialDiffusion = look_up_table->CheckForVariables(varnames_PD); + break; + case ENUM_DATADRIVEN_METHOD::MLP: +#ifdef USE_MLPCPP + for (auto iMLP = 0u; iMLP < config->GetNDataDriven_Files(); iMLP++) { + auto outputMap = lookup_mlp->FindVariableIndices(iMLP, varnames_PD, false); + n_betas += outputMap.size(); + } + PreferentialDiffusion = (n_betas == varnames_PD.size()); +#endif + break; + default: + break; + } + if (Kind_DataDriven_Method == ENUM_DATADRIVEN_METHOD::MLP) { #ifdef USE_MLPCPP iomap_TD = new MLPToolbox::CIOMap(controlling_variable_names, varnames_TD); @@ -195,6 +235,10 @@ void CFluidFlamelet::PreprocessLookUp(CConfig* config) { lookup_mlp->PairVariableswithMLPs(*iomap_TD); lookup_mlp->PairVariableswithMLPs(*iomap_Sources); lookup_mlp->PairVariableswithMLPs(*iomap_LookUp); + if (PreferentialDiffusion) { + iomap_PD = new MLPToolbox::CIOMap(controlling_variable_names, varnames_PD); + lookup_mlp->PairVariableswithMLPs(*iomap_PD); + } #endif } } @@ -207,11 +251,20 @@ unsigned long CFluidFlamelet::EvaluateDataSet(const vector& input_sca vector varnames; vector val_vars; vector refs_vars; + AD::StartPreacc(); + for (auto iCV = 0u; iCV < n_control_vars; iCV++) AD::SetPreaccIn(input_scalar[iCV]); + switch (lookup_type) { case FLAMELET_LOOKUP_OPS::TD: varnames = varnames_TD; #ifdef USE_MLPCPP iomap_Current = iomap_TD; +#endif + break; + case FLAMELET_LOOKUP_OPS::PD: + varnames = varnames_PD; +#ifdef USE_MLPCPP + iomap_Current = iomap_PD; #endif break; case FLAMELET_LOOKUP_OPS::SOURCES: @@ -251,6 +304,7 @@ unsigned long CFluidFlamelet::EvaluateDataSet(const vector& input_sca default: break; } - + for (auto iVar = 0u; iVar < output_refs.size(); iVar++) AD::SetPreaccOut(output_refs[iVar]); + AD::EndPreacc(); return extrapolation; } diff --git a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp index 2f8297a91a0..3bbe7cd2b49 100644 --- a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp @@ -68,9 +68,23 @@ void CSpeciesFlameletSolver::Preprocessing(CGeometry* geometry, CSolver** solver unsigned short RunTime_EqSystem, bool Output) { unsigned long n_not_in_domain_local = 0, n_not_in_domain_global = 0; vector scalars_vector(nVar); - + su2double spark_location[3]; + su2double spark_radius; + unsigned long spark_iter_start, spark_duration; + bool ignition = false; auto* flowNodes = su2staticcast_p(solver_container[FLOW_SOL]->GetNodes()); + /*--- Retrieve spark ignition parameters for spark-type ignition. ---*/ + if (config->GetFlameletInitType() == FLAMELET_INIT_TYPE::SPARK) { + auto spark_init = config->GetFlameInit(); + for (auto iDim = 0u; iDim < 3; ++iDim) spark_location[iDim] = spark_init[iDim]; + spark_radius = spark_init[3]; + spark_iter_start = ceil(spark_init[4]); + spark_duration = ceil(spark_init[5]); + unsigned long iter = config->GetMultizone_Problem() ? config->GetOuterIter() : config->GetInnerIter(); + ignition = ((iter >= spark_iter_start) && (iter <= (spark_iter_start + spark_duration))); + } + SU2_OMP_SAFE_GLOBAL_ACCESS(config->SetGlobalParam(config->GetKind_Solver(), RunTime_EqSystem);) SU2_OMP_FOR_STAT(omp_chunk_size) @@ -81,6 +95,18 @@ void CSpeciesFlameletSolver::Preprocessing(CGeometry* geometry, CSolver** solver /*--- Compute total source terms from the production and consumption. ---*/ unsigned long misses = SetScalarSources(config, fluid_model_local, i_point, scalars_vector); + + if (ignition) { + /*--- Apply source terms within spark radius. ---*/ + su2double dist_from_center = 0; + for (auto iDim = 0u; iDim < nDim; ++iDim) + dist_from_center += pow(geometry->nodes->GetCoord(i_point, iDim) - spark_location[iDim], 2); + if (sqrt(dist_from_center) < spark_radius) { + for (auto iVar = 0u; iVar < nVar; iVar++) + nodes->SetScalarSource(i_point, iVar, nodes->GetScalarSources(i_point)[iVar] + config->GetSpark()[iVar]); + } + } + nodes->SetTableMisses(i_point, misses); n_not_in_domain_local += misses; /*--- Obtain passive look-up scalars. ---*/ @@ -94,6 +120,10 @@ void CSpeciesFlameletSolver::Preprocessing(CGeometry* geometry, CSolver** solver nodes->SetDiffusivity(i_point, fluid_model_local->GetMassDiffusivity(i_scalar), i_scalar); } + /*--- Obtain preferential diffusion scalar values. ---*/ + if (config->GetPreferentialDiffusion()) + SetPreferentialDiffusionScalars(config, fluid_model_local, i_point, scalars_vector); + if (!Output) LinSysRes.SetBlock_Zero(i_point); } END_SU2_OMP_FOR @@ -102,6 +132,21 @@ void CSpeciesFlameletSolver::Preprocessing(CGeometry* geometry, CSolver** solver SU2_MPI::GetComm()); if ((rank == MASTER_NODE) && (n_not_in_domain_global > 0)) cout << "Number of points outside manifold domain: " << n_not_in_domain_global << endl; + + /*--- Compute preferential diffusion scalar gradients. ---*/ + if (config->GetPreferentialDiffusion()) { + switch (config->GetKind_Gradient_Method_Recon()) { + case GREEN_GAUSS: + SetAuxVar_Gradient_GG(geometry, config); + break; + case WEIGHTED_LEAST_SQUARES: + case LEAST_SQUARES: + SetAuxVar_Gradient_LS(geometry, config); + break; + default: + break; + } + } /*--- Clear Residual and Jacobian. Upwind second order reconstruction and gradients ---*/ CommonPreprocessing(geometry, config, Output); } @@ -115,13 +160,22 @@ void CSpeciesFlameletSolver::SetInitialCondition(CGeometry** geometry, CSolver** cout << "Initializing progress variable and total enthalpy (using temperature)" << endl; } - const su2double* flame_init = config->GetFlameInit(); - const su2double flame_offset[3] = {flame_init[0], flame_init[1], flame_init[2]}; - const su2double flame_normal[3] = {flame_init[3], flame_init[4], flame_init[5]}; - const su2double flame_thickness = flame_init[6]; - const su2double flame_burnt_thickness = flame_init[7]; + su2double flame_offset[3] = {0, 0, 0}, flame_normal[3] = {0, 0, 0}, flame_thickness = 0, flame_burnt_thickness = 0, + flamenorm = 0; + bool flame_front_ignition = (config->GetFlameletInitType() == FLAMELET_INIT_TYPE::FLAME_FRONT); + + if (flame_front_ignition) { + /*--- Collect flame front ignition parameters. ---*/ + auto flame_init = config->GetFlameInit(); + for (auto iDim = 0u; iDim < 3; ++iDim) { + flame_offset[iDim] = flame_init[iDim]; + flame_normal[iDim] = flame_init[3 + iDim]; + } + flame_thickness = flame_init[6]; + flame_burnt_thickness = flame_init[7]; + flamenorm = GeometryToolbox::Norm(nDim, flame_normal); + } - const su2double flamenorm = GeometryToolbox::Norm(nDim, flame_normal); const su2double temp_inlet = config->GetInc_Temperature_Init(); su2double enth_inlet = config->GetSpecies_Init()[I_ENTH]; @@ -134,6 +188,19 @@ void CSpeciesFlameletSolver::SetInitialCondition(CGeometry** geometry, CSolver** const auto& cv_name = config->GetControllingVariableName(iCV); cout << "initial condition: " << cv_name << " = " << config->GetSpecies_Init()[iCV] << endl; } + switch (config->GetFlameletInitType()) { + case FLAMELET_INIT_TYPE::FLAME_FRONT: + cout << "Ignition with a straight flame front" << endl; + break; + case FLAMELET_INIT_TYPE::SPARK: + cout << "Ignition with an artificial spark" << endl; + break; + case FLAMELET_INIT_TYPE::NONE: + cout << "No solution ignition (cold flow)" << endl; + break; + default: + break; + } } CFluidModel* fluid_model_local; @@ -157,37 +224,40 @@ void CSpeciesFlameletSolver::SetInitialCondition(CGeometry** geometry, CSolver** for (unsigned long i_point = 0; i_point < nPoint; i_point++) { auto coords = geometry[i_mesh]->nodes->GetCoord(i_point); - /*--- Determine if point is above or below the plane, assuming the normal - is pointing towards the burned region. ---*/ - point_loc = 0.0; - for (unsigned short i_dim = 0; i_dim < geometry[i_mesh]->GetnDim(); i_dim++) { - point_loc += flame_normal[i_dim] * (coords[i_dim] - flame_offset[i_dim]); - } - - /*--- Compute the exact distance from point to plane. ---*/ - point_loc = point_loc / flamenorm; - - /* --- Unburnt region upstream of the flame. --- */ - if (point_loc <= 0) { - scalar_init[I_PROGVAR] = prog_unburnt; - n_points_unburnt_local++; - - /* --- Flame zone where we lineary increase from unburnt to burnt conditions. --- */ - } else if ((point_loc > 0) && (point_loc <= flame_thickness)) { - scalar_init[I_PROGVAR] = prog_unburnt + point_loc * (prog_burnt - prog_unburnt) / flame_thickness; - n_points_flame_local++; - - /* --- Burnt region behind the flame zone. --- */ - } else if ((point_loc > flame_thickness) && (point_loc <= flame_thickness + flame_burnt_thickness)) { - scalar_init[I_PROGVAR] = prog_burnt; - n_points_burnt_local++; - - /* --- Unburnt region downstream of the flame and burnt region. --- */ + if (flame_front_ignition) { + /*--- Determine if point is above or below the plane, assuming the normal + is pointing towards the burned region. ---*/ + point_loc = 0.0; + for (unsigned short i_dim = 0; i_dim < geometry[i_mesh]->GetnDim(); i_dim++) { + point_loc += flame_normal[i_dim] * (coords[i_dim] - flame_offset[i_dim]); + } + + /*--- Compute the exact distance from point to plane. ---*/ + point_loc = point_loc / flamenorm; + + /* --- Unburnt region upstream of the flame. --- */ + if (point_loc <= 0) { + scalar_init[I_PROGVAR] = prog_unburnt; + n_points_unburnt_local++; + + /* --- Flame zone where we lineary increase from unburnt to burnt conditions. --- */ + } else if ((point_loc > 0) && (point_loc <= flame_thickness)) { + scalar_init[I_PROGVAR] = prog_unburnt + point_loc * (prog_burnt - prog_unburnt) / flame_thickness; + n_points_flame_local++; + + /* --- Burnt region behind the flame zone. --- */ + } else if ((point_loc > flame_thickness) && (point_loc <= flame_thickness + flame_burnt_thickness)) { + scalar_init[I_PROGVAR] = prog_burnt; + n_points_burnt_local++; + + /* --- Unburnt region downstream of the flame and burnt region. --- */ + } else { + scalar_init[I_PROGVAR] = prog_unburnt; + n_points_unburnt_local++; + } } else { scalar_init[I_PROGVAR] = prog_unburnt; - n_points_unburnt_local++; } - /* --- Perform manifold evaluation to check whether initial scalar is out-of-bounds. --- */ fluid_model_local->SetTDState_T(temp_inlet, scalar_init); n_not_in_domain_local += fluid_model_local->GetExtrapolation(); @@ -225,9 +295,11 @@ void CSpeciesFlameletSolver::SetInitialCondition(CGeometry** geometry, CSolver** if (rank == MASTER_NODE) { cout << endl; - cout << " Number of points in unburnt region: " << n_points_unburnt_global << "." << endl; - cout << " Number of points in burnt region : " << n_points_burnt_global << "." << endl; - cout << " Number of points in flame zone : " << n_points_flame_global << "." << endl; + if (flame_front_ignition) { + cout << " Number of points in unburnt region: " << n_points_unburnt_global << "." << endl; + cout << " Number of points in burnt region : " << n_points_burnt_global << "." << endl; + cout << " Number of points in flame zone : " << n_points_flame_global << "." << endl; + } if (n_not_in_domain_global > 0) cout << " Initial condition: Number of points outside of table domain: " << n_not_in_domain_global << " !!!" @@ -466,7 +538,7 @@ unsigned long CSpeciesFlameletSolver::SetScalarSources(const CConfig* config, CF unsigned long CSpeciesFlameletSolver::SetScalarLookUps(const CConfig* config, CFluidModel* fluid_model_local, unsigned long iPoint, const vector& scalars) { - /*--- Compute total source terms from the production and consumption. ---*/ + /*--- Retrieve the passive look-up variables from the manifold. ---*/ vector lookup_scalar(config->GetNLookups()); unsigned long misses = fluid_model_local->EvaluateDataSet(scalars, FLAMELET_LOOKUP_OPS::LOOKUP, lookup_scalar); @@ -477,6 +549,202 @@ unsigned long CSpeciesFlameletSolver::SetScalarLookUps(const CConfig* config, CF return misses; } +unsigned long CSpeciesFlameletSolver::SetPreferentialDiffusionScalars(const CConfig* config, + CFluidModel* fluid_model_local, + unsigned long iPoint, + const vector& scalars) { + /*--- Retrieve the preferential diffusion scalar values from the manifold. ---*/ + + vector beta_scalar(FLAMELET_PREF_DIFF_SCALARS::N_BETA_TERMS); + unsigned long misses = fluid_model_local->EvaluateDataSet(scalars, FLAMELET_LOOKUP_OPS::PD, beta_scalar); + + for (auto i_beta = 0u; i_beta < FLAMELET_PREF_DIFF_SCALARS::N_BETA_TERMS; i_beta++) { + nodes->SetAuxVar(iPoint, i_beta, beta_scalar[i_beta]); + } + return misses; +} + +void CSpeciesFlameletSolver::Viscous_Residual(unsigned long iEdge, CGeometry* geometry, CSolver** solver_container, + CNumerics* numerics, CConfig* config) { + /*--- Overloaded viscous residual method which accounts for preferential diffusion. ---*/ + const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT), + PreferentialDiffusion = config->GetPreferentialDiffusion(); + su2double *scalar_i, *scalar_j, *diff_coeff_beta_i, *diff_coeff_beta_j; + scalar_i = new su2double[nVar]; + scalar_j = new su2double[nVar]; + diff_coeff_beta_i = new su2double[nVar], diff_coeff_beta_j = new su2double[nVar]; + + su2activematrix scalar_grad_i(nVar, nDim), scalar_grad_j(nVar, nDim); + + // Number of active transport scalars + auto n_CV = config->GetNControlVars(); + + /*--- Points in edge ---*/ + auto iPoint = geometry->edges->GetNode(iEdge, 0); + auto jPoint = geometry->edges->GetNode(iEdge, 1); + + auto SolverSpecificNumerics = [&](unsigned long iPoint, unsigned long jPoint) { + /*--- Mass diffusivity coefficients. ---*/ + + numerics->SetDiffusionCoeff(nodes->GetDiffusivity(iPoint), nodes->GetDiffusivity(jPoint)); + }; + + /*--- Regular viscous scalar residual computation. ---*/ + + Viscous_Residual_impl(SolverSpecificNumerics, iEdge, geometry, solver_container, numerics, config); + + /*--- Viscous residual due to preferential diffusion ---*/ + if (PreferentialDiffusion) { + /*--- Looping over spatial dimensions to fill in the diffusion scalar gradients. ---*/ + /*--- The scalar gradient is subtracted to account for regular viscous diffusion. ---*/ + for (auto iScalar = 0u; iScalar < n_CV; ++iScalar) { + for (auto iDim = 0u; iDim < nDim; ++iDim) { + switch (iScalar) { + case I_PROGVAR: + scalar_grad_i[iScalar][iDim] = + nodes->GetAuxVarGradient(iPoint, FLAMELET_PREF_DIFF_SCALARS::I_BETA_PROGVAR, iDim) - + nodes->GetGradient(iPoint, I_PROGVAR, iDim); + scalar_grad_j[iScalar][iDim] = + nodes->GetAuxVarGradient(jPoint, FLAMELET_PREF_DIFF_SCALARS::I_BETA_PROGVAR, iDim) - + nodes->GetGradient(jPoint, I_PROGVAR, iDim); + break; + case I_ENTH: + scalar_grad_i[iScalar][iDim] = + nodes->GetAuxVarGradient(iPoint, FLAMELET_PREF_DIFF_SCALARS::I_BETA_ENTH, iDim) - + nodes->GetGradient(iPoint, I_ENTH, iDim); + scalar_grad_j[iScalar][iDim] = + nodes->GetAuxVarGradient(jPoint, FLAMELET_PREF_DIFF_SCALARS::I_BETA_ENTH, iDim) - + nodes->GetGradient(jPoint, I_ENTH, iDim); + break; + case I_MIXFRAC: + scalar_grad_i[iScalar][iDim] = + nodes->GetAuxVarGradient(iPoint, FLAMELET_PREF_DIFF_SCALARS::I_BETA_MIXFRAC, iDim) - + nodes->GetGradient(iPoint, I_MIXFRAC, iDim); + scalar_grad_j[iScalar][iDim] = + nodes->GetAuxVarGradient(jPoint, FLAMELET_PREF_DIFF_SCALARS::I_BETA_MIXFRAC, iDim) - + nodes->GetGradient(jPoint, I_MIXFRAC, iDim); + break; + default: + break; + } + } + } + /*--- No preferential diffusion modification for passive species. ---*/ + for (auto iScalar = n_CV; iScalar < nVar; ++iScalar) { + for (auto iDim = 0u; iDim < nDim; ++iDim) { + scalar_grad_i[iScalar][iDim] = 0; + scalar_grad_j[iScalar][iDim] = 0; + } + } + + for (auto iScalar = 0u; iScalar < n_CV; ++iScalar) { + /*--- Filling in the preferential diffusion scalars (beta_pv, beta_h2, beta_Z). ---*/ + switch (iScalar) { + case I_PROGVAR: + scalar_i[iScalar] = nodes->GetAuxVar(iPoint, FLAMELET_PREF_DIFF_SCALARS::I_BETA_PROGVAR) - + nodes->GetSolution(iPoint, iScalar); + scalar_j[iScalar] = nodes->GetAuxVar(jPoint, FLAMELET_PREF_DIFF_SCALARS::I_BETA_PROGVAR) - + nodes->GetSolution(jPoint, iScalar); + break; + case I_ENTH: + scalar_i[iScalar] = + nodes->GetAuxVar(iPoint, FLAMELET_PREF_DIFF_SCALARS::I_BETA_ENTH) - nodes->GetSolution(iPoint, iScalar); + scalar_j[iScalar] = + nodes->GetAuxVar(jPoint, FLAMELET_PREF_DIFF_SCALARS::I_BETA_ENTH) - nodes->GetSolution(jPoint, iScalar); + break; + case I_MIXFRAC: + scalar_i[iScalar] = nodes->GetAuxVar(iPoint, FLAMELET_PREF_DIFF_SCALARS::I_BETA_MIXFRAC) - + nodes->GetSolution(iPoint, iScalar); + scalar_j[iScalar] = nodes->GetAuxVar(jPoint, FLAMELET_PREF_DIFF_SCALARS::I_BETA_MIXFRAC) - + nodes->GetSolution(jPoint, iScalar); + break; + default: + break; + } + diff_coeff_beta_i[iScalar] = nodes->GetDiffusivity(iPoint, iScalar); + diff_coeff_beta_j[iScalar] = nodes->GetDiffusivity(jPoint, iScalar); + } + + for (auto iScalar = n_CV; iScalar < nVar; ++iScalar) { + scalar_i[iScalar] = 0; + scalar_j[iScalar] = 0; + diff_coeff_beta_i[iScalar] = 0; + diff_coeff_beta_j[iScalar] = 0; + } + + numerics->SetScalarVar(scalar_i, scalar_j); + + numerics->SetScalarVarGradient(CMatrixView(scalar_grad_i), CMatrixView(scalar_grad_j)); + + numerics->SetDiffusionCoeff(diff_coeff_beta_i, diff_coeff_beta_j); + + /*--- Computing first preferential residual component. ---*/ + auto residual_PD = numerics->ComputeResidual(config); + + if (ReducerStrategy) { + EdgeFluxes.SubtractBlock(iEdge, residual_PD); + + if (implicit) Jacobian.UpdateBlocksSub(iEdge, residual_PD.jacobian_i, residual_PD.jacobian_j); + } else { + LinSysRes.SubtractBlock(iPoint, residual_PD); + LinSysRes.AddBlock(jPoint, residual_PD); + /*--- Set implicit computation ---*/ + if (implicit) Jacobian.UpdateBlocksSub(iEdge, iPoint, jPoint, residual_PD.jacobian_i, residual_PD.jacobian_j); + } + + /* Computing the second preferential diffusion terms due to heat flux */ + for (auto iScalar = 0u; iScalar < nVar; ++iScalar) { + for (auto iDim = 0u; iDim < nDim; ++iDim) { + if (iScalar == I_ENTH) { + /* Setting the temperature gradient */ + scalar_grad_i[iScalar][iDim] = + solver_container[FLOW_SOL]->GetNodes()->GetGradient_Primitive(iPoint, prim_idx.Temperature(), iDim); + scalar_grad_j[iScalar][iDim] = + solver_container[FLOW_SOL]->GetNodes()->GetGradient_Primitive(jPoint, prim_idx.Temperature(), iDim); + } else { + scalar_grad_i[iScalar][iDim] = 0; + scalar_grad_j[iScalar][iDim] = 0; + } + } + + if (iScalar == I_ENTH) { + scalar_i[iScalar] = solver_container[FLOW_SOL]->GetNodes()->GetTemperature(iPoint); + scalar_j[iScalar] = solver_container[FLOW_SOL]->GetNodes()->GetTemperature(jPoint); + diff_coeff_beta_i[iScalar] = nodes->GetAuxVar(iPoint, FLAMELET_PREF_DIFF_SCALARS::I_BETA_ENTH_THERMAL) * + nodes->GetDiffusivity(iPoint, iScalar); + diff_coeff_beta_j[iScalar] = nodes->GetAuxVar(jPoint, FLAMELET_PREF_DIFF_SCALARS::I_BETA_ENTH_THERMAL) * + nodes->GetDiffusivity(jPoint, iScalar); + } else { + scalar_i[iScalar] = 0; + scalar_j[iScalar] = 0; + diff_coeff_beta_i[iScalar] = 0; + diff_coeff_beta_j[iScalar] = 0; + } + } + + numerics->SetScalarVar(scalar_i, scalar_j); + + numerics->SetScalarVarGradient(CMatrixView(scalar_grad_i), CMatrixView(scalar_grad_j)); + + numerics->SetDiffusionCoeff(diff_coeff_beta_i, diff_coeff_beta_j); + + auto residual_thermal = numerics->ComputeResidual(config); + + if (ReducerStrategy) { + EdgeFluxes.SubtractBlock(iEdge, residual_thermal); + if (implicit) Jacobian.UpdateBlocksSub(iEdge, residual_thermal.jacobian_i, residual_thermal.jacobian_j); + } else { + LinSysRes.SubtractBlock(iPoint, residual_thermal); + LinSysRes.AddBlock(jPoint, residual_thermal); + /* No implicit part for the preferential diffusion of heat */ + } + } + delete[] scalar_i; + delete[] scalar_j; + delete[] diff_coeff_beta_i; + delete[] diff_coeff_beta_j; +} + unsigned long CSpeciesFlameletSolver::GetEnthFromTemp(CFluidModel* fluid_model, su2double const val_temp, const su2double* scalar_solution, su2double* val_enth) { /*--- convergence criterion for temperature in [K], high accuracy needed for restarts. ---*/ diff --git a/SU2_CFD/src/variables/CSpeciesFlameletVariable.cpp b/SU2_CFD/src/variables/CSpeciesFlameletVariable.cpp index 16536909bee..e66ecbbf09e 100644 --- a/SU2_CFD/src/variables/CSpeciesFlameletVariable.cpp +++ b/SU2_CFD/src/variables/CSpeciesFlameletVariable.cpp @@ -53,4 +53,9 @@ CSpeciesFlameletVariable::CSpeciesFlameletVariable(const su2double* species_inf, source_scalar.resize(nPoint, config->GetNScalars()) = su2double(0.0); lookup_scalar.resize(nPoint, config->GetNLookups()) = su2double(0.0); table_misses.resize(nPoint) = 0; + + if (config->GetPreferentialDiffusion()) { + AuxVar.resize(nPoint, FLAMELET_PREF_DIFF_SCALARS::N_BETA_TERMS) = su2double(0.0); + Grad_AuxVar.resize(nPoint, FLAMELET_PREF_DIFF_SCALARS::N_BETA_TERMS, nDim, 0.0); + } } diff --git a/config_template.cfg b/config_template.cfg index 5f4fab871b8..915ca7bc168 100644 --- a/config_template.cfg +++ b/config_template.cfg @@ -772,6 +772,11 @@ SPECIES_CLIPPING_MAX= 1.0, ... SPECIES_CLIPPING_MIN= 0.0, ... % --------------------- FLAMELET MODEL -----------------------------% +% The flamelet model uses the prompts INTERPOLATION_METHOD and FILENAMES_INTERPOLATOR +% for definition of the flamelet manifold. Either LUT or MLP can be used as options. +% If the terms "Beta_ProgVar", "Beta_Enth_Thermal", "Beta_Enth", and "Beta_Mixfrac" are +% found in the variables list of the manifold, preferential diffusion is assumed. + % % Names of the user defined (auxiliary) transport equations. USER_SCALAR_NAMES= (Y-CO) @@ -797,8 +802,19 @@ CONTROLLING_VARIABLE_NAMES= (ProgressVariable, EnthalpyTot) % controlling variables without source terms, use "zero" or "null", similar to the % option USER_SOURCE_NAMES. CONTROLLING_VARIABLE_SOURCE_NAMES= (ProdRateTot_PV, NULL) -% -% flamelet initialization + +% Method used to ignite the solution: +% FLAME_FRONT : the flame is initialized using a plane, defined by a point and a normal. On one side, the solution is initialized +% using 'burnt' conditions and on the other side 'unburnt' conditions. The normal points in the direction of the 'burnt' +% condition. +% SPARK : the solution is ignited through application of a set of source terms within a specified region for a set number +% of solver iterations. This artificial spark can be applied after a certain number of iterations has passed, allowing for +% the flow to evolve before igniting the mixture. +% NONE : no artificial solution ignition. +% By default, this option is set to NONE +FLAME_INIT_METHOD= FLAME_FRONT + +% FLAME_FRONT initialization % the flame is initialized using a plane, defined by a point and a normal. On one side, the solution is initialized % using 'burnt' conditions and on the other side 'unburnt' conditions. The normal points in the direction of the 'burnt' % condition. @@ -807,6 +823,21 @@ CONTROLLING_VARIABLE_SOURCE_NAMES= (ProdRateTot_PV, NULL) % (x7) = thickness of the reaction zone, this is the transition from unburnt to burnt conditions. % (x8) = Thickness of the 'burnt' zone, after this length, the conditions will be 'unburnt' again. FLAME_INIT= (0.004, 0.0, 0.0, 1.0, 0.0, 0.0, 0.2e-3, 1.0) + +% SPARK initialization +% the solution is ignited through application of a set of source terms within a specified region for a set number +% of solver iterations. This artificial spark can be applied after a certain number of iterations has passed, allowing for +% the flow to evolve before igniting the mixture. +% (x1,x2,x3) = spark center location. +% (x4) = spark radius where within the artificial spark is applied. +% (x5,x6) = spark iteration start and number of iterations in which the artifical spark is applied. For single-zone problems +% the number of iterations are inner-loop iterations, for multi-zone problems, outer-loop iterations are considered. +SPARK_INIT= (0.004, 0.0, 0.0, 1e-4, 100, 10) + +% Source terms (density times species time rate of change) applied to the species equations in the spark region for the duration of the spark. +% The number of terms should equate the total number of species in the flamelet problem. +SPARK_REACTION_RATES= (1000, 0, 0) + % % --------------------- INVERSE DESIGN SIMULATION -----------------------------% % From 78f995c1d06dcece5cde5d2c0e5fc6c45fee60c6 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Wed, 26 Jul 2023 10:39:15 +0200 Subject: [PATCH 02/34] buf fix for spark initialization method --- Common/src/CConfig.cpp | 3 ++- SU2_CFD/src/fluid/CFluidFlamelet.cpp | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index f06173bf6b7..f49232bf521 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1375,8 +1375,9 @@ void CConfig::SetConfig_Options() { /*!\brief SPARK_INIT \n DESCRIPTION: spark initialization using the flamelet model \ingroup Config*/ for (auto iSpark=0u; iSpark<6; ++iSpark) spark_init[iSpark]=0; addDoubleArrayOption("SPARK_INIT", 6, spark_init); + unsigned short dummy; /*!\brief SPARK_REACTION_RATES \n DESCRIPTION: Net source term values applied to species within spark area during spark ignition. \ingroup Config*/ - addDoubleListOption("SPARK_REACTION_RATES", nSpecies_Init, spark_reaction_rates); + addDoubleListOption("SPARK_REACTION_RATES", dummy, spark_reaction_rates); /*--- Options related to mass diffusivity and thereby the species solver. ---*/ diff --git a/SU2_CFD/src/fluid/CFluidFlamelet.cpp b/SU2_CFD/src/fluid/CFluidFlamelet.cpp index 6bc2cfdda33..81cca434cce 100644 --- a/SU2_CFD/src/fluid/CFluidFlamelet.cpp +++ b/SU2_CFD/src/fluid/CFluidFlamelet.cpp @@ -112,7 +112,6 @@ CFluidFlamelet::~CFluidFlamelet() { delete iomap_LookUp; delete lookup_mlp; if (PreferentialDiffusion) delete iomap_PD; - s #endif break; default: From c3f2da9082f42e2c32a59f0c6166d8fdeda2d5a5 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Wed, 23 Aug 2023 11:31:41 +0200 Subject: [PATCH 03/34] Merged with develop --- SU2_CFD/src/fluid/CFluidFlamelet.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/SU2_CFD/src/fluid/CFluidFlamelet.cpp b/SU2_CFD/src/fluid/CFluidFlamelet.cpp index 6bc2cfdda33..81cca434cce 100644 --- a/SU2_CFD/src/fluid/CFluidFlamelet.cpp +++ b/SU2_CFD/src/fluid/CFluidFlamelet.cpp @@ -112,7 +112,6 @@ CFluidFlamelet::~CFluidFlamelet() { delete iomap_LookUp; delete lookup_mlp; if (PreferentialDiffusion) delete iomap_PD; - s #endif break; default: From e5e151bbbec7e7a3b0323417f84ed4ce0674bfdd Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Fri, 1 Sep 2023 14:29:44 +0200 Subject: [PATCH 04/34] Pulled the new version of Develop --- Common/src/CConfig.cpp | 3 ++- Common/src/containers/CLookUpTable.cpp | 16 +++++++--------- SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp | 14 +++++++------- config_template.cfg | 18 +++++++++--------- 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index c7dae5810c4..89fec11d16e 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1375,8 +1375,9 @@ void CConfig::SetConfig_Options() { /*!\brief SPARK_INIT \n DESCRIPTION: spark initialization using the flamelet model \ingroup Config*/ for (auto iSpark=0u; iSpark<6; ++iSpark) spark_init[iSpark]=0; addDoubleArrayOption("SPARK_INIT", 6, spark_init); + unsigned short dummy; /*!\brief SPARK_REACTION_RATES \n DESCRIPTION: Net source term values applied to species within spark area during spark ignition. \ingroup Config*/ - addDoubleListOption("SPARK_REACTION_RATES", nSpecies_Init, spark_reaction_rates); + addDoubleListOption("SPARK_REACTION_RATES", dummy, spark_reaction_rates); /*--- Options related to mass diffusivity and thereby the species solver. ---*/ diff --git a/Common/src/containers/CLookUpTable.cpp b/Common/src/containers/CLookUpTable.cpp index 0321528ac21..698a042a3d5 100644 --- a/Common/src/containers/CLookUpTable.cpp +++ b/Common/src/containers/CLookUpTable.cpp @@ -802,15 +802,13 @@ bool CLookUpTable::IsInTriangle(su2double val_CV1, su2double val_CV2, unsigned l } bool CLookUpTable::CheckForVariables(const std::vector& vars_to_check) { - bool variables_are_present {true}; - for (auto iVar=0u; iVarGetMultizone_Problem() ? config->GetOuterIter() : config->GetInnerIter(); - ignition = ((iter >= spark_iter_start) && (iter <= (spark_iter_start + spark_duration))); + ignition = ((iter >= spark_iter_start) && (iter <= (spark_iter_start + spark_duration)) && !config->GetRestart()); } SU2_OMP_SAFE_GLOBAL_ACCESS(config->SetGlobalParam(config->GetKind_Solver(), RunTime_EqSystem);) @@ -403,8 +403,8 @@ void CSpeciesFlameletSolver::BC_Inlet(CGeometry* geometry, CSolver** solver_cont SU2_OMP_FOR_STAT(OMP_MIN_SIZE) for (auto iVertex = 0u; iVertex < geometry->nVertex[val_marker]; iVertex++) { Inlet_SpeciesVars[val_marker][iVertex][I_ENTH] = enth_inlet; - END_SU2_OMP_FOR } + END_SU2_OMP_FOR /*--- Call the general inlet boundary condition implementation. ---*/ CSpeciesSolver::BC_Inlet(geometry, solver_container, conv_numerics, visc_numerics, config, val_marker); @@ -514,13 +514,13 @@ unsigned long CSpeciesFlameletSolver::SetScalarSources(const CConfig* config, CF vector table_sources(config->GetNControlVars() + 2 * config->GetNUserScalars()); unsigned long misses = fluid_model_local->EvaluateDataSet(scalars, FLAMELET_LOOKUP_OPS::SOURCES, table_sources); + table_sources[I_PROGVAR] = fmax(0, table_sources[I_PROGVAR]); nodes->SetTableMisses(iPoint, misses); /*--- The source term for progress variable is always positive, we clip from below to makes sure. --- */ vector source_scalar(config->GetNScalars()); for (auto iCV = 0u; iCV < config->GetNControlVars(); iCV++) source_scalar[iCV] = table_sources[iCV]; - source_scalar[I_PROGVAR] = fmax(EPS, source_scalar[I_PROGVAR]); /*--- Source term for the auxiliary species transport equations. ---*/ for (size_t i_aux = 0; i_aux < config->GetNUserScalars(); i_aux++) { @@ -748,19 +748,19 @@ void CSpeciesFlameletSolver::Viscous_Residual(unsigned long iEdge, CGeometry* ge unsigned long CSpeciesFlameletSolver::GetEnthFromTemp(CFluidModel* fluid_model, su2double const val_temp, const su2double* scalar_solution, su2double* val_enth) { /*--- convergence criterion for temperature in [K], high accuracy needed for restarts. ---*/ - su2double delta_temp_final = 0.001; + su2double delta_temp_final = 1e-10; su2double enth_iter = scalar_solution[I_ENTH]; su2double delta_enth; su2double delta_temp_iter = 1e10; unsigned long exit_code = 0; - const int counter_limit = 1000; + const int counter_limit = 5000; int counter = 0; su2double val_scalars[MAXNVAR]; for (auto iVar = 0u; iVar < nVar; iVar++) val_scalars[iVar] = scalar_solution[iVar]; - while ((abs(delta_temp_iter) > delta_temp_final) && (counter++ < counter_limit)) { + while ((abs(delta_temp_iter / val_temp) > delta_temp_final) && (counter++ < counter_limit)) { /*--- Add all quantities and their names to the look up vectors. ---*/ val_scalars[I_ENTH] = enth_iter; fluid_model->SetTDState_T(val_temp, val_scalars); @@ -772,7 +772,7 @@ unsigned long CSpeciesFlameletSolver::GetEnthFromTemp(CFluidModel* fluid_model, delta_enth = Cp * delta_temp_iter; - enth_iter += delta_enth; + enth_iter += 0.5 * delta_enth; } *val_enth = enth_iter; diff --git a/config_template.cfg b/config_template.cfg index b96c363cf5b..2dfe390d759 100644 --- a/config_template.cfg +++ b/config_template.cfg @@ -774,7 +774,7 @@ SPECIES_CLIPPING_MIN= 0.0, ... % --------------------- FLAMELET MODEL -----------------------------% % The flamelet model uses the prompts INTERPOLATION_METHOD and FILENAMES_INTERPOLATOR % for definition of the flamelet manifold. Either LUT or MLP can be used as options. -% If the terms "Beta_ProgVar", "Beta_Enth_Thermal", "Beta_Enth", and "Beta_Mixfrac" are +% If the terms "Beta_ProgVar", "Beta_Enth_Thermal", "Beta_Enth", and "Beta_Mixfrac" are % found in the variables list of the manifold, preferential diffusion is assumed. % @@ -803,15 +803,15 @@ CONTROLLING_VARIABLE_NAMES= (ProgressVariable, EnthalpyTot) % option USER_SOURCE_NAMES. CONTROLLING_VARIABLE_SOURCE_NAMES= (ProdRateTot_PV, NULL) -% Method used to ignite the solution: +% Method used to ignite the solution: % FLAME_FRONT : the flame is initialized using a plane, defined by a point and a normal. On one side, the solution is initialized % using 'burnt' conditions and on the other side 'unburnt' conditions. The normal points in the direction of the 'burnt' % condition. -% SPARK : the solution is ignited through application of a set of source terms within a specified region for a set number +% SPARK : the solution is ignited through application of a set of source terms within a specified region for a set number % of solver iterations. This artificial spark can be applied after a certain number of iterations has passed, allowing for -% the flow to evolve before igniting the mixture. +% the flow to evolve before igniting the mixture. % NONE : no artificial solution ignition. -% By default, this option is set to NONE +% By default, this option is set to NONE FLAME_INIT_METHOD= FLAME_FRONT % FLAME_FRONT initialization @@ -824,17 +824,17 @@ FLAME_INIT_METHOD= FLAME_FRONT % (x8) = Thickness of the 'burnt' zone, after this length, the conditions will be 'unburnt' again. FLAME_INIT= (0.004, 0.0, 0.0, 1.0, 0.0, 0.0, 0.2e-3, 1.0) -% SPARK initialization -% the solution is ignited through application of a set of source terms within a specified region for a set number +% SPARK initialization +% the solution is ignited through application of a set of source terms within a specified region for a set number % of solver iterations. This artificial spark can be applied after a certain number of iterations has passed, allowing for -% the flow to evolve before igniting the mixture. +% the flow to evolve before igniting the mixture. % (x1,x2,x3) = spark center location. % (x4) = spark radius where within the artificial spark is applied. % (x5,x6) = spark iteration start and number of iterations in which the artifical spark is applied. For single-zone problems % the number of iterations are inner-loop iterations, for multi-zone problems, outer-loop iterations are considered. SPARK_INIT= (0.004, 0.0, 0.0, 1e-4, 100, 10) -% Source terms (density times species time rate of change) applied to the species equations in the spark region for the duration of the spark. +% Source terms (density times species time rate of change) applied to the species equations in the spark region for the duration of the spark. % The number of terms should equate the total number of species in the flamelet problem. SPARK_REACTION_RATES= (1000, 0, 0) From 7897bee347b45ea057cb3b462a6921c908d384bc Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Wed, 6 Sep 2023 16:26:35 +0200 Subject: [PATCH 05/34] Replaced isothermal getter function in config to be compatible with flow problems without isothermal walls --- Common/src/CConfig.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 89fec11d16e..36d2a1c3b5b 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -9177,7 +9177,7 @@ su2double CConfig::GetIsothermal_Temperature(const string& val_marker) const { if (Marker_Isothermal[iMarker_Isothermal] == val_marker) return Isothermal_Temperature[iMarker_Isothermal]; - return Isothermal_Temperature[0]; + return Temperature_FreeStream;// Isothermal_Temperature[0]; } su2double CConfig::GetWall_HeatFlux(const string& val_marker) const { From a8e66ed21930d95b2199f639098d57cca8bd36d8 Mon Sep 17 00:00:00 2001 From: bigfooted Date: Mon, 25 Sep 2023 12:34:45 +0200 Subject: [PATCH 06/34] fix memory allocation crash --- Common/include/CConfig.hpp | 1 + Common/src/CConfig.cpp | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 8fe5f2ef2a4..b7d16ab1065 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -1224,6 +1224,7 @@ class CConfig { su2double flame_init[8]; /*!< \brief Flame front initialization parameters. */ su2double spark_init[6]; /*!< \brief Spark ignition initialization parameters. */ su2double* spark_reaction_rates; /*!< \brief Source terms for flamelet spark ignition option. */ + unsigned short nspark; bool preferential_diffusion = false; /*!< \brief Preferential diffusion physics for flamelet solver.*/ /*--- lookup table ---*/ diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 36d2a1c3b5b..5ad4855bc64 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -972,7 +972,7 @@ void CConfig::SetPointersNull() { Species_Init = nullptr; Species_Clipping_Min = nullptr; Species_Clipping_Max = nullptr; - + spark_reaction_rates = nullptr; /*--- Moving mesh pointers ---*/ nKind_SurfaceMovement = 0; @@ -1375,9 +1375,8 @@ void CConfig::SetConfig_Options() { /*!\brief SPARK_INIT \n DESCRIPTION: spark initialization using the flamelet model \ingroup Config*/ for (auto iSpark=0u; iSpark<6; ++iSpark) spark_init[iSpark]=0; addDoubleArrayOption("SPARK_INIT", 6, spark_init); - unsigned short dummy; /*!\brief SPARK_REACTION_RATES \n DESCRIPTION: Net source term values applied to species within spark area during spark ignition. \ingroup Config*/ - addDoubleListOption("SPARK_REACTION_RATES", dummy, spark_reaction_rates); + addDoubleListOption("SPARK_REACTION_RATES", nspark, spark_reaction_rates); /*--- Options related to mass diffusivity and thereby the species solver. ---*/ From 16d6405a8eb05c040106912a19b941df9e290e27 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Thu, 5 Oct 2023 15:57:24 +0200 Subject: [PATCH 07/34] Pulled develop --- externals/mel | 2 +- subprojects/CoolProp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/externals/mel b/externals/mel index 46205ab019e..2484cd3258e 160000 --- a/externals/mel +++ b/externals/mel @@ -1 +1 @@ -Subproject commit 46205ab019e5224559091375a6d71aabae6bc5b9 +Subproject commit 2484cd3258ef800a10e361016cb341834ee7930b diff --git a/subprojects/CoolProp b/subprojects/CoolProp index bafdea1f39e..0ce42fcf3bb 160000 --- a/subprojects/CoolProp +++ b/subprojects/CoolProp @@ -1 +1 @@ -Subproject commit bafdea1f39ee873a6bb9833e3a21fe41f90b85e8 +Subproject commit 0ce42fcf3bb2c373512bc825a4f0c1973a78f307 From 0d10cbde07e4939cc1e3196126fbd8dca60edbe2 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Wed, 1 Nov 2023 11:33:59 +0100 Subject: [PATCH 08/34] Quality of life changes to usability of flamelet solver --- Docs/docmain.hpp | 6 --- .../solvers/CSpeciesFlameletSolver.hpp | 5 +- SU2_CFD/src/fluid/CFluidFlamelet.cpp | 13 +++-- .../src/solvers/CSpeciesFlameletSolver.cpp | 51 ++++++++++--------- 4 files changed, 39 insertions(+), 36 deletions(-) diff --git a/Docs/docmain.hpp b/Docs/docmain.hpp index fcda1b961ec..ab8b45fa8ec 100644 --- a/Docs/docmain.hpp +++ b/Docs/docmain.hpp @@ -225,9 +225,3 @@ * \brief Classes for explicit (done by the programmer) vectorization (SIMD) of computations. * \ingroup Toolboxes */ - -/*! - * \defgroup Multi-Layer Perceptrons (MLP) - * \brief Data look up and interpolation via dense, feed-forward multi-layer perceptrons. - * \ingroup Toolboxes - */ diff --git a/SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp b/SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp index aa01016bb9b..555de8085df 100644 --- a/SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp +++ b/SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp @@ -109,11 +109,10 @@ class CSpeciesFlameletSolver final : public CSpeciesSolver { public: /*! - * \brief Constructor. + * \brief Define a Flamelet Generated Manifold species solver. * \param[in] geometry - Geometrical definition of the problem. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. - * \param[in] FluidModel */ CSpeciesFlameletSolver(CGeometry* geometry, CConfig* config, unsigned short iMesh); @@ -187,7 +186,7 @@ class CSpeciesFlameletSolver final : public CSpeciesSolver { unsigned short val_marker) override; /*! - * \brief Compute the viscous fluxes of the flamelet species at a particular edge. + * \brief Compute the fluxes due to viscous and preferential diffusion effects of the flamelet species at a particular edge. * \param[in] iEdge - Edge for which we want to compute the flux * \param[in] geometry - Geometrical definition of the problem. * \param[in] solver_container - Container vector with all the solutions. diff --git a/SU2_CFD/src/fluid/CFluidFlamelet.cpp b/SU2_CFD/src/fluid/CFluidFlamelet.cpp index 81cca434cce..6d51075a05a 100644 --- a/SU2_CFD/src/fluid/CFluidFlamelet.cpp +++ b/SU2_CFD/src/fluid/CFluidFlamelet.cpp @@ -189,9 +189,16 @@ void CFluidFlamelet::PreprocessLookUp(CConfig* config) { /*--- Passive look-up terms ---*/ size_t n_lookups = config->GetNLookups(); - varnames_LookUp.resize(n_lookups); - val_vars_LookUp.resize(n_lookups); - for (auto iLookup = 0u; iLookup < n_lookups; iLookup++) varnames_LookUp[iLookup] = config->GetLookupName(iLookup); + if (n_lookups == 0) { + varnames_LookUp.resize(1); + val_vars_LookUp.resize(1); + varnames_LookUp[0] = "NULL"; + val_vars_LookUp[0] = NULL; + } else { + varnames_LookUp.resize(n_lookups); + val_vars_LookUp.resize(n_lookups); + for (auto iLookup = 0u; iLookup < n_lookups; iLookup++) varnames_LookUp[iLookup] = config->GetLookupName(iLookup); + } /*--- Preferential diffusion scalars ---*/ varnames_PD.resize(FLAMELET_PREF_DIFF_SCALARS::N_BETA_TERMS); diff --git a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp index 3bbe7cd2b49..e3e86d4d104 100644 --- a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp @@ -75,7 +75,7 @@ void CSpeciesFlameletSolver::Preprocessing(CGeometry* geometry, CSolver** solver auto* flowNodes = su2staticcast_p(solver_container[FLOW_SOL]->GetNodes()); /*--- Retrieve spark ignition parameters for spark-type ignition. ---*/ - if (config->GetFlameletInitType() == FLAMELET_INIT_TYPE::SPARK) { + if ((config->GetFlameletInitType() == FLAMELET_INIT_TYPE::SPARK) && !config->GetRestart()) { auto spark_init = config->GetFlameInit(); for (auto iDim = 0u; iDim < 3; ++iDim) spark_location[iDim] = spark_init[iDim]; spark_radius = spark_init[3]; @@ -539,13 +539,17 @@ unsigned long CSpeciesFlameletSolver::SetScalarSources(const CConfig* config, CF unsigned long CSpeciesFlameletSolver::SetScalarLookUps(const CConfig* config, CFluidModel* fluid_model_local, unsigned long iPoint, const vector& scalars) { /*--- Retrieve the passive look-up variables from the manifold. ---*/ - - vector lookup_scalar(config->GetNLookups()); - unsigned long misses = fluid_model_local->EvaluateDataSet(scalars, FLAMELET_LOOKUP_OPS::LOOKUP, lookup_scalar); - - for (auto i_lookup = 0u; i_lookup < config->GetNLookups(); i_lookup++) { - nodes->SetLookupScalar(iPoint, lookup_scalar[i_lookup], i_lookup); + unsigned long misses{0}; + /*--- Skip if no passive look-ups are listed ---*/ + if (config->GetNLookups() > 0) { + vector lookup_scalar(config->GetNLookups()); + misses = fluid_model_local->EvaluateDataSet(scalars, FLAMELET_LOOKUP_OPS::LOOKUP, lookup_scalar); + + for (auto i_lookup = 0u; i_lookup < config->GetNLookups(); i_lookup++) { + nodes->SetLookupScalar(iPoint, lookup_scalar[i_lookup], i_lookup); + } } + return misses; } @@ -569,15 +573,6 @@ void CSpeciesFlameletSolver::Viscous_Residual(unsigned long iEdge, CGeometry* ge /*--- Overloaded viscous residual method which accounts for preferential diffusion. ---*/ const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT), PreferentialDiffusion = config->GetPreferentialDiffusion(); - su2double *scalar_i, *scalar_j, *diff_coeff_beta_i, *diff_coeff_beta_j; - scalar_i = new su2double[nVar]; - scalar_j = new su2double[nVar]; - diff_coeff_beta_i = new su2double[nVar], diff_coeff_beta_j = new su2double[nVar]; - - su2activematrix scalar_grad_i(nVar, nDim), scalar_grad_j(nVar, nDim); - - // Number of active transport scalars - auto n_CV = config->GetNControlVars(); /*--- Points in edge ---*/ auto iPoint = geometry->edges->GetNode(iEdge, 0); @@ -595,6 +590,17 @@ void CSpeciesFlameletSolver::Viscous_Residual(unsigned long iEdge, CGeometry* ge /*--- Viscous residual due to preferential diffusion ---*/ if (PreferentialDiffusion) { + CFlowVariable* flowNodes = su2staticcast_p(solver_container[FLOW_SOL]->GetNodes()); + + su2double *scalar_i, *scalar_j, *diff_coeff_beta_i, *diff_coeff_beta_j; + scalar_i = new su2double[nVar]; + scalar_j = new su2double[nVar]; + diff_coeff_beta_i = new su2double[nVar], diff_coeff_beta_j = new su2double[nVar]; + + // Number of active transport scalars + const auto n_CV = config->GetNControlVars(); + + su2activematrix scalar_grad_i(nVar, nDim), scalar_grad_j(nVar, nDim); /*--- Looping over spatial dimensions to fill in the diffusion scalar gradients. ---*/ /*--- The scalar gradient is subtracted to account for regular viscous diffusion. ---*/ for (auto iScalar = 0u; iScalar < n_CV; ++iScalar) { @@ -697,10 +703,8 @@ void CSpeciesFlameletSolver::Viscous_Residual(unsigned long iEdge, CGeometry* ge for (auto iDim = 0u; iDim < nDim; ++iDim) { if (iScalar == I_ENTH) { /* Setting the temperature gradient */ - scalar_grad_i[iScalar][iDim] = - solver_container[FLOW_SOL]->GetNodes()->GetGradient_Primitive(iPoint, prim_idx.Temperature(), iDim); - scalar_grad_j[iScalar][iDim] = - solver_container[FLOW_SOL]->GetNodes()->GetGradient_Primitive(jPoint, prim_idx.Temperature(), iDim); + scalar_grad_i[iScalar][iDim] = flowNodes->GetGradient_Primitive(iPoint, prim_idx.Temperature(), iDim); + scalar_grad_j[iScalar][iDim] = flowNodes->GetGradient_Primitive(jPoint, prim_idx.Temperature(), iDim); } else { scalar_grad_i[iScalar][iDim] = 0; scalar_grad_j[iScalar][iDim] = 0; @@ -708,8 +712,8 @@ void CSpeciesFlameletSolver::Viscous_Residual(unsigned long iEdge, CGeometry* ge } if (iScalar == I_ENTH) { - scalar_i[iScalar] = solver_container[FLOW_SOL]->GetNodes()->GetTemperature(iPoint); - scalar_j[iScalar] = solver_container[FLOW_SOL]->GetNodes()->GetTemperature(jPoint); + scalar_i[iScalar] = flowNodes->GetTemperature(iPoint); + scalar_j[iScalar] = flowNodes->GetTemperature(jPoint); diff_coeff_beta_i[iScalar] = nodes->GetAuxVar(iPoint, FLAMELET_PREF_DIFF_SCALARS::I_BETA_ENTH_THERMAL) * nodes->GetDiffusivity(iPoint, iScalar); diff_coeff_beta_j[iScalar] = nodes->GetAuxVar(jPoint, FLAMELET_PREF_DIFF_SCALARS::I_BETA_ENTH_THERMAL) * @@ -732,17 +736,16 @@ void CSpeciesFlameletSolver::Viscous_Residual(unsigned long iEdge, CGeometry* ge if (ReducerStrategy) { EdgeFluxes.SubtractBlock(iEdge, residual_thermal); - if (implicit) Jacobian.UpdateBlocksSub(iEdge, residual_thermal.jacobian_i, residual_thermal.jacobian_j); } else { LinSysRes.SubtractBlock(iPoint, residual_thermal); LinSysRes.AddBlock(jPoint, residual_thermal); /* No implicit part for the preferential diffusion of heat */ } - } delete[] scalar_i; delete[] scalar_j; delete[] diff_coeff_beta_i; delete[] diff_coeff_beta_j; + } } unsigned long CSpeciesFlameletSolver::GetEnthFromTemp(CFluidModel* fluid_model, su2double const val_temp, From ead4b74aec824bcd0d03cad927910f657845b4e0 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Wed, 1 Nov 2023 11:57:11 +0100 Subject: [PATCH 09/34] Updated codipack submodule --- externals/codi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/externals/codi b/externals/codi index 17232fed052..8ee822a9b0b 160000 --- a/externals/codi +++ b/externals/codi @@ -1 +1 @@ -Subproject commit 17232fed05245dbb8f04a31e274a02d53458c75c +Subproject commit 8ee822a9b0bb8235a2494467b774e27fb64ff14f From f48b3380e941c70a5c45cab72bcbbc5df79feba6 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Wed, 1 Nov 2023 13:03:19 +0100 Subject: [PATCH 10/34] Added hydrogen burner test case --- .github/workflows/regression.yml | 2 +- .../laminar_premixed_h2_flame_cfd.cfg | 120 ++++++++++++++++++ TestCases/parallel_regression.py | 9 ++ externals/codi | 2 +- 4 files changed, 131 insertions(+), 2 deletions(-) create mode 100644 TestCases/flamelet/07_laminar_premixed_h2_flame_cfd/laminar_premixed_h2_flame_cfd.cfg diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index 129913c82cf..5a6f49565d0 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -171,7 +171,7 @@ jobs: uses: docker://ghcr.io/su2code/su2/test-su2:230813-0103 with: # -t -c - args: -b ${{github.ref}} -t develop -c develop -s ${{matrix.testscript}} + args: -b ${{github.ref}} -t develop -c feature_new_flamelet -s ${{matrix.testscript}} - name: Cleanup uses: docker://ghcr.io/su2code/su2/test-su2:230813-0103 with: diff --git a/TestCases/flamelet/07_laminar_premixed_h2_flame_cfd/laminar_premixed_h2_flame_cfd.cfg b/TestCases/flamelet/07_laminar_premixed_h2_flame_cfd/laminar_premixed_h2_flame_cfd.cfg new file mode 100644 index 00000000000..b753483f8f3 --- /dev/null +++ b/TestCases/flamelet/07_laminar_premixed_h2_flame_cfd/laminar_premixed_h2_flame_cfd.cfg @@ -0,0 +1,120 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: Laminar premixed hydrogen flame with heat exchanger % +% Author: Evert Bunschoten % +% Institution: Delft University of Technology % +% Date: 01/11/2023 % +% File Version 8.0.0 "Harrier" % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +SOLVER = INC_NAVIER_STOKES +KIND_TURB_MODEL= NONE +MATH_PROBLEM= DIRECT +RESTART_SOL =YES +% ---------------- INCOMPRESSIBLE FLOW CONDITION DEFINITION -------------------% +% +INC_DENSITY_MODEL= VARIABLE +INC_ENERGY_EQUATION = YES +INC_VELOCITY_INIT= (1.13, 0.0, 0.0 ) +INC_TEMPERATURE_INIT= 300.0 +THERMODYNAMIC_PRESSURE= 101325 +INC_NONDIM= DIMENSIONAL + +% -------------------- FLUID MODEL --------------------------------------- % +% +FLUID_MODEL= FLUID_FLAMELET +VISCOSITY_MODEL= FLAMELET +CONDUCTIVITY_MODEL= FLAMELET +DIFFUSIVITY_MODEL= FLAMELET +KIND_SCALAR_MODEL= FLAMELET +INTERPOLATION_METHOD= MLP +FILENAMES_INTERPOLATOR= (MLP_TD.mlp, MLP_PD.mlp, MLP_PPV.mlp, MLP_null.mlp) + +% -------------------- SCALAR TRANSPORT ---------------------------------------% +% +% Using an artificial spark to ignite the solution at some location and iteration +FLAME_INIT_METHOD= SPARK +% Spark parameters in order: +% x-location of spark center (m) +% y-location of spark center (m) +% z-location of spark center (m) +% Spark radius (m) +% Iteration at which the artificial spark starts +% Spark iteration duration +SPARK_INIT= (0.001, 0.0004, 0, 5e-4, 10, 10) + +% Controlling variable source terms applied within the spark sphere for the spark +% duration. +SPARK_REACTION_RATES= (1000, 0, 0) + +SPECIES_INIT = (-0.49904325357252965, 2226.901776784524, 0.01446751783896619) + +% Passive reactants in flamelet problem + +CONTROLLING_VARIABLE_NAMES= (ProgressVariable, EnthalpyTot, MixtureFraction) +CONTROLLING_VARIABLE_SOURCE_NAMES= (ProdRateTot_PV, NULL, NULL) + +SPECIES_CLIPPING=YES +SPECIES_CLIPPING_MAX=+4.5623852432084366e-01 +8.6731375409855954e+06 1.0 +SPECIES_CLIPPING_MIN= -6.8059708053507162e-01 -4.9308262569627967e+06 0.0 + +MARKER_INLET_SPECIES = (inlet, -0.49904325357252965, 2226.901776784524, 0.01446751783896619) + +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +MARKER_ISOTHERMAL= (burner_wall, 300, hex_wall, 300) +MARKER_SYM= (sides) +INC_INLET_TYPE= VELOCITY_INLET +MARKER_INLET = (inlet, 300.000, 0.575, 1.0, 0.0, 0.0) +INC_OUTLET_TYPE= PRESSURE_OUTLET +MARKER_OUTLET= (outlet, 0.0) +MARKER_ANALYZE_AVERAGE = AREA + +% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% +% +NUM_METHOD_GRAD= GREEN_GAUSS +CFL_NUMBER =50 +CFL_ADAPT= NO +ITER=5 +OUTPUT_WRT_FREQ= 20 +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +LINEAR_SOLVER= FGMRES +LINEAR_SOLVER_PREC= ILU +LINEAR_SOLVER_ERROR= 1E-4 +LINEAR_SOLVER_ITER=20 +% +% -------------------- FLOW AND SPECIES NUMERICAL METHOD DEFINITION -----------------------% +% +CONV_NUM_METHOD_FLOW= FDS +CONV_NUM_METHOD_SPECIES= BOUNDED_SCALAR +MUSCL_FLOW= YES +MUSCL_SPECIES= YES +SLOPE_LIMITER_FLOW = NONE +SLOPE_LIMITER_SPECIES= NONE +TIME_DISCRE_FLOW= EULER_IMPLICIT +TIME_DISCRE_SPECIES= EULER_IMPLICIT + +% --------------------------- CONVERGENCE PARAMETERS --------------------------% +% +CONV_FIELD = RMS_EnthalpyTot +CONV_RESIDUAL_MINVAL= -5 +CONV_STARTITER= 20 +SCREEN_OUTPUT = INNER_ITER RMS_PRESSURE RMS_ProgressVariable RMS_EnthalpyTot RMS_MixtureFraction +HISTORY_OUTPUT = WALL_TIME RMS_RES +VOLUME_OUTPUT = SOLUTION PRIMITIVE SOURCE RESIDUAL + +% ------------------------- INPUT/OUTPUT INFORMATION --------------------------% +% +MESH_FORMAT= SU2 +MESH_FILENAME = 2Dhex_BL.su2 +OUTPUT_FILES = (RESTART,PARAVIEW) +TABULAR_FORMAT = CSV +CONV_FILENAME= history +VOLUME_FILENAME= flow + + diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index f26049592b8..f189cf3ee9e 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -69,6 +69,15 @@ def main(): cfd_flamelet_ch4_partial_premix.new_output = True test_list.append(cfd_flamelet_ch4_partial_premix) + # 2D planar laminar premixed hydrogen flame on isothermal burner with heat exchanger emulator (restart) + cfd_flamelet_h2 = TestCase('cfd_flamelet_h2') + cfd_flamelet_h2.cfg_dir = "flamelet/07_laminar_premixed_h2_flame_cfd" + cfd_flamelet_h2.cfg_file = "lam_premixed_h2_flame_cfd.cfg" + cfd_flamelet_h2.test_iter = 5 + cfd_flamelet_h2.test_vals = [-9.915363, -9.807720, -3.260516, -11.304692] + cfd_flamelet_h2.new_output = True + test_list.append(cfd_flamelet_h2) + ######################### ## NEMO solver ### ######################### diff --git a/externals/codi b/externals/codi index 0ad036f2c82..8ee822a9b0b 160000 --- a/externals/codi +++ b/externals/codi @@ -1 +1 @@ -Subproject commit 0ad036f2c8254fa7b77180a443d99248c047c877 +Subproject commit 8ee822a9b0bb8235a2494467b774e27fb64ff14f From a4de27f96f53d329321a1a7f1484adab87c8f9ac Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Thu, 2 Nov 2023 09:13:49 +0100 Subject: [PATCH 11/34] Fixed build errors --- Common/src/CConfig.cpp | 2 +- SU2_CFD/include/fluid/CFluidFlamelet.hpp | 3 ++- SU2_CFD/src/fluid/CFluidFlamelet.cpp | 4 ++-- SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp | 9 +++------ 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index eb253978ed7..f5bf03ec6dc 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -9177,7 +9177,7 @@ su2double CConfig::GetIsothermal_Temperature(const string& val_marker) const { if (Marker_Isothermal[iMarker_Isothermal] == val_marker) return Isothermal_Temperature[iMarker_Isothermal]; - return Temperature_FreeStream;// Isothermal_Temperature[0]; + return Temperature_FreeStream; } su2double CConfig::GetWall_HeatFlux(const string& val_marker) const { diff --git a/SU2_CFD/include/fluid/CFluidFlamelet.hpp b/SU2_CFD/include/fluid/CFluidFlamelet.hpp index 24bf5715b92..075ea6bfef2 100644 --- a/SU2_CFD/include/fluid/CFluidFlamelet.hpp +++ b/SU2_CFD/include/fluid/CFluidFlamelet.hpp @@ -34,7 +34,7 @@ #define USE_MLPCPP #endif #include "CFluidModel.hpp" - +#include class CFluidFlamelet final : public CFluidModel { private: ENUM_DATADRIVEN_METHOD Kind_DataDriven_Method = @@ -64,6 +64,7 @@ class CFluidFlamelet final : public CFluidModel { /*--- Class variables for the multi-layer perceptron method ---*/ #ifdef USE_MLPCPP + size_t n_betas; MLPToolbox::CLookUp_ANN* lookup_mlp; /*!< \brief Multi-layer perceptron collection. */ MLPToolbox::CIOMap* iomap_TD; /*!< \brief Input-output map for thermochemical properties. */ MLPToolbox::CIOMap* iomap_PD; /*!< \brief Input-output map for the preferential diffusion scalars. */ diff --git a/SU2_CFD/src/fluid/CFluidFlamelet.cpp b/SU2_CFD/src/fluid/CFluidFlamelet.cpp index 377e3e236c0..6721f79292c 100644 --- a/SU2_CFD/src/fluid/CFluidFlamelet.cpp +++ b/SU2_CFD/src/fluid/CFluidFlamelet.cpp @@ -25,6 +25,7 @@ * License along with SU2. If not, see . */ +#include #include "../include/fluid/CFluidFlamelet.hpp" #include "../../../Common/include/containers/CLookUpTable.hpp" #if defined(HAVE_MLPCPP) @@ -47,7 +48,6 @@ CFluidFlamelet::CFluidFlamelet(CConfig* config, su2double value_pressure_operati cout << "Number of user scalars: " << n_user_scalars << endl; cout << "Number of control variables: " << n_control_vars << endl; } - scalars_vector.resize(n_scalars); table_scalar_names.resize(n_scalars); @@ -213,7 +213,6 @@ void CFluidFlamelet::PreprocessLookUp(CConfig* config) { val_vars_PD[FLAMELET_PREF_DIFF_SCALARS::I_BETA_ENTH] = beta_enth; val_vars_PD[FLAMELET_PREF_DIFF_SCALARS::I_BETA_MIXFRAC] = beta_mixfrac; - size_t n_betas{0}; PreferentialDiffusion = false; switch (Kind_DataDriven_Method) { case ENUM_DATADRIVEN_METHOD::LUT: @@ -221,6 +220,7 @@ void CFluidFlamelet::PreprocessLookUp(CConfig* config) { break; case ENUM_DATADRIVEN_METHOD::MLP: #ifdef USE_MLPCPP + n_betas = 0; for (auto iMLP = 0u; iMLP < config->GetNDataDriven_Files(); iMLP++) { auto outputMap = lookup_mlp->FindVariableIndices(iMLP, varnames_PD, false); n_betas += outputMap.size(); diff --git a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp index 5609a0e140e..d7ef5e9a363 100644 --- a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp @@ -68,8 +68,6 @@ void CSpeciesFlameletSolver::Preprocessing(CGeometry* geometry, CSolver** solver unsigned short RunTime_EqSystem, bool Output) { unsigned long n_not_in_domain_local = 0, n_not_in_domain_global = 0; vector scalars_vector(nVar); - su2double spark_location[3]; - su2double spark_radius; unsigned long spark_iter_start, spark_duration; bool ignition = false; auto* flowNodes = su2staticcast_p(solver_container[FLOW_SOL]->GetNodes()); @@ -77,8 +75,6 @@ void CSpeciesFlameletSolver::Preprocessing(CGeometry* geometry, CSolver** solver /*--- Retrieve spark ignition parameters for spark-type ignition. ---*/ if ((config->GetFlameletInitType() == FLAMELET_INIT_TYPE::SPARK) && !config->GetRestart()) { auto spark_init = config->GetFlameInit(); - for (auto iDim = 0u; iDim < 3; ++iDim) spark_location[iDim] = spark_init[iDim]; - spark_radius = spark_init[3]; spark_iter_start = ceil(spark_init[4]); spark_duration = ceil(spark_init[5]); unsigned long iter = config->GetMultizone_Problem() ? config->GetOuterIter() : config->GetInnerIter(); @@ -98,9 +94,10 @@ void CSpeciesFlameletSolver::Preprocessing(CGeometry* geometry, CSolver** solver if (ignition) { /*--- Apply source terms within spark radius. ---*/ - su2double dist_from_center = 0; + su2double dist_from_center = 0, + spark_radius = config->GetFlameInit()[3]; for (auto iDim = 0u; iDim < nDim; ++iDim) - dist_from_center += pow(geometry->nodes->GetCoord(i_point, iDim) - spark_location[iDim], 2); + dist_from_center += pow(geometry->nodes->GetCoord(i_point, iDim) - config->GetFlameInit()[iDim], 2); if (sqrt(dist_from_center) < spark_radius) { for (auto iVar = 0u; iVar < nVar; iVar++) nodes->SetScalarSource(i_point, iVar, nodes->GetScalarSources(i_point)[iVar] + config->GetSpark()[iVar]); From d836e451c67c540d8b77ddfa6ff0b8c98bea2d18 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Mon, 6 Nov 2023 14:27:46 +0100 Subject: [PATCH 12/34] Updated submodules and updated comments around EvaluateDataSet in CFluidFlamelet --- Common/include/option_structure.hpp | 10 +++++----- SU2_CFD/include/fluid/CFluidFlamelet.hpp | 14 +++++++------- SU2_CFD/include/fluid/CFluidModel.hpp | 7 +++++-- externals/codi | 2 +- externals/mel | 2 +- subprojects/CoolProp | 2 +- 6 files changed, 20 insertions(+), 17 deletions(-) diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 69149f6392c..f50dd937b8a 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -1343,11 +1343,11 @@ enum FLAMELET_LOOKUP_OPS { * \brief the preferential diffusion scalar indices for the preferential diffusion model. */ enum FLAMELET_PREF_DIFF_SCALARS { - I_BETA_PROGVAR, - I_BETA_ENTH_THERMAL, - I_BETA_ENTH, - I_BETA_MIXFRAC, - N_BETA_TERMS, + I_BETA_PROGVAR, /*!< \brief Preferential diffusion scalar for the progress variable. */ + I_BETA_ENTH_THERMAL, /*!< \brief Preferential diffusion scalar for temperature. */ + I_BETA_ENTH, /*!< \brief Preferential diffusion scalar for total enthalpy. */ + I_BETA_MIXFRAC, /*!< \brief Preferential diffusion scalar for mixture fraction. */ + N_BETA_TERMS, /*!< \brief Total number of preferential diffusion scalars. */ }; /*! diff --git a/SU2_CFD/include/fluid/CFluidFlamelet.hpp b/SU2_CFD/include/fluid/CFluidFlamelet.hpp index 075ea6bfef2..2e1dd8bb00d 100644 --- a/SU2_CFD/include/fluid/CFluidFlamelet.hpp +++ b/SU2_CFD/include/fluid/CFluidFlamelet.hpp @@ -96,14 +96,14 @@ class CFluidFlamelet final : public CFluidModel { void SetTDState_T(su2double val_temperature, const su2double* val_scalars = nullptr) override; /*! - * \brief Evaluate the flamelet manifold. - * \param[in] input_scalar - scalar solution. - * \param[in] input_varnames - names of variables to evaluate. - * \param[in] output_refs - output data. - * \param[out] Extrapolation - scalar solution is within bounds (0) or out of bounds (1). + * \brief Evaluate data-set for flamelet simulations. + * \param[in] input_scalar - controlling variables used to interpolate manifold. + * \param[in] lookup_type - look-up operation to be performed (FLAMELET_LOOKUP_OPS) + * \param[in] output_refs - output variables where interpolated results are stored. + * \param[out] Extrapolation - query data is within manifold bounds (0) or out of bounds (1). */ - inline unsigned long EvaluateDataSet(const vector& input_scalar, unsigned short lookup_type, - vector& output_refs) override; + unsigned long EvaluateDataSet(const vector& input_scalar, unsigned short lookup_type, + vector& output_refs); /*! * \brief Check for out-of-bounds condition for data set interpolation. diff --git a/SU2_CFD/include/fluid/CFluidModel.hpp b/SU2_CFD/include/fluid/CFluidModel.hpp index 2df09071e13..ebc2c309ab9 100644 --- a/SU2_CFD/include/fluid/CFluidModel.hpp +++ b/SU2_CFD/include/fluid/CFluidModel.hpp @@ -144,8 +144,11 @@ class CFluidModel { virtual inline unsigned short GetNScalars() const { return 0; } /*! - * \brief Evaluate data manifold for flamelet or data-driven fluid problems. - * \param[in] input - input data for manifold regression. + * \brief Evaluate data-set for flamelet or data-driven fluid simulations. + * \param[in] input_scalar - data manifold query data. + * \param[in] lookup_type - look-up operation to be performed. + * \param[in] output_refs - output variables where interpolated results are stored. + * \param[out] Extrapolation - query data is within manifold bounds (0) or out of bounds (1). */ virtual unsigned long EvaluateDataSet(const vector& input_scalar, unsigned short lookup_type, vector& output_refs) { diff --git a/externals/codi b/externals/codi index 8ee822a9b0b..0ad036f2c82 160000 --- a/externals/codi +++ b/externals/codi @@ -1 +1 @@ -Subproject commit 8ee822a9b0bb8235a2494467b774e27fb64ff14f +Subproject commit 0ad036f2c8254fa7b77180a443d99248c047c877 diff --git a/externals/mel b/externals/mel index 2484cd3258e..46205ab019e 160000 --- a/externals/mel +++ b/externals/mel @@ -1 +1 @@ -Subproject commit 2484cd3258ef800a10e361016cb341834ee7930b +Subproject commit 46205ab019e5224559091375a6d71aabae6bc5b9 diff --git a/subprojects/CoolProp b/subprojects/CoolProp index 0ce42fcf3bb..bafdea1f39e 160000 --- a/subprojects/CoolProp +++ b/subprojects/CoolProp @@ -1 +1 @@ -Subproject commit 0ce42fcf3bb2c373512bc825a4f0c1973a78f307 +Subproject commit bafdea1f39ee873a6bb9833e3a21fe41f90b85e8 From 706c0ed9f352c41473f6ae1b1386ec3d63ec6690 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Mon, 20 Nov 2023 16:49:11 +0100 Subject: [PATCH 13/34] Updated hydrogen test case file name in regression tests and set the GetEnthFromTemp convergence settings in accordance with develop --- SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp | 4 ++-- TestCases/parallel_regression.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp index d7ef5e9a363..210fc02095b 100644 --- a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp @@ -748,12 +748,12 @@ void CSpeciesFlameletSolver::Viscous_Residual(unsigned long iEdge, CGeometry* ge unsigned long CSpeciesFlameletSolver::GetEnthFromTemp(CFluidModel* fluid_model, su2double const val_temp, const su2double* scalar_solution, su2double* val_enth) { /*--- convergence criterion for temperature in [K], high accuracy needed for restarts. ---*/ - su2double delta_temp_final = 1e-10; + su2double delta_temp_final = 0.001; su2double enth_iter = scalar_solution[I_ENTH]; su2double delta_enth; su2double delta_temp_iter = 1e10; unsigned long exit_code = 0; - const int counter_limit = 5000; + const int counter_limit = 1000; int counter = 0; diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 6f1ffda08bd..45fe43dcfb1 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -72,7 +72,7 @@ def main(): # 2D planar laminar premixed hydrogen flame on isothermal burner with heat exchanger emulator (restart) cfd_flamelet_h2 = TestCase('cfd_flamelet_h2') cfd_flamelet_h2.cfg_dir = "flamelet/07_laminar_premixed_h2_flame_cfd" - cfd_flamelet_h2.cfg_file = "lam_premixed_h2_flame_cfd.cfg" + cfd_flamelet_h2.cfg_file = "laminar_premixed_h2_flame_cfd.cfg" cfd_flamelet_h2.test_iter = 5 cfd_flamelet_h2.test_vals = [-9.915363, -9.807720, -3.260516, -11.304692] cfd_flamelet_h2.new_output = True From 4cbaeebd53ad20de13b99f4b9d82c189e39725ce Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Wed, 29 Nov 2023 15:00:10 +0100 Subject: [PATCH 14/34] Updated GetEnthFromTemp function for proper restarts on test cases --- SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp index 210fc02095b..f37a34f2f15 100644 --- a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp @@ -760,7 +760,7 @@ unsigned long CSpeciesFlameletSolver::GetEnthFromTemp(CFluidModel* fluid_model, su2double val_scalars[MAXNVAR]; for (auto iVar = 0u; iVar < nVar; iVar++) val_scalars[iVar] = scalar_solution[iVar]; - while ((abs(delta_temp_iter / val_temp) > delta_temp_final) && (counter++ < counter_limit)) { + while ((abs(delta_temp_iter) > delta_temp_final) && (counter++ < counter_limit)) { /*--- Add all quantities and their names to the look up vectors. ---*/ val_scalars[I_ENTH] = enth_iter; fluid_model->SetTDState_T(val_temp, val_scalars); @@ -772,7 +772,7 @@ unsigned long CSpeciesFlameletSolver::GetEnthFromTemp(CFluidModel* fluid_model, delta_enth = Cp * delta_temp_iter; - enth_iter += 0.5 * delta_enth; + enth_iter += delta_enth; } *val_enth = enth_iter; From 3b5c63c291fa21af78831f9b3c5766d545653195 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Wed, 29 Nov 2023 15:56:28 +0100 Subject: [PATCH 15/34] Updated code styling according to pre-commit --- Common/include/CConfig.hpp | 4 ++-- Common/src/CConfig.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 8e0a7f7d483..85f2b81046e 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -1223,7 +1223,7 @@ class CConfig { su2double* spark_reaction_rates; /*!< \brief Source terms for flamelet spark ignition option. */ unsigned short nspark; /*!< \brief Number of source terms for spark initialization. */ bool preferential_diffusion = false; /*!< \brief Preferential diffusion physics for flamelet solver.*/ - + /*--- lookup table ---*/ unsigned short n_scalars = 0; /*!< \brief Number of transported scalars for flamelet LUT approach. */ unsigned short n_lookups = 0; /*!< \brief Number of lookup variables, for visualization only. */ @@ -2143,7 +2143,7 @@ class CConfig { * (x8) = flame burnt thickness, the length to stay at burnt conditions. * \return Ignition initialization parameters for the flamelet model. */ - const su2double* GetFlameInit() const { + const su2double* GetFlameInit() const { switch (flame_init_type) { case FLAMELET_INIT_TYPE::FLAME_FRONT: diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 31db843b22c..4f3e863542e 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1390,7 +1390,7 @@ void CConfig::SetConfig_Options() { /*!\brief SPARK_INIT \n DESCRIPTION: spark initialization using the flamelet model \ingroup Config*/ for (auto iSpark=0u; iSpark<6; ++iSpark) spark_init[iSpark]=0; addDoubleArrayOption("SPARK_INIT", 6, spark_init); - + /*!\brief SPARK_REACTION_RATES \n DESCRIPTION: Net source term values applied to species within spark area during spark ignition. \ingroup Config*/ addDoubleListOption("SPARK_REACTION_RATES", nspark, spark_reaction_rates); From 15a8505a2af340da4da26c0eb8f66e88c1a62389 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Mon, 4 Dec 2023 12:11:28 +0100 Subject: [PATCH 16/34] Updated residual values for hydrogen flamelet regression test --- TestCases/parallel_regression.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 45fe43dcfb1..129a6d8d58c 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -74,7 +74,7 @@ def main(): cfd_flamelet_h2.cfg_dir = "flamelet/07_laminar_premixed_h2_flame_cfd" cfd_flamelet_h2.cfg_file = "laminar_premixed_h2_flame_cfd.cfg" cfd_flamelet_h2.test_iter = 5 - cfd_flamelet_h2.test_vals = [-9.915363, -9.807720, -3.260516, -11.304692] + cfd_flamelet_h2.test_vals = [-9.914406, -9.807959, -3.260701, -11.304908] cfd_flamelet_h2.new_output = True test_list.append(cfd_flamelet_h2) From ee5c4aa2b4c877ad6e0deb539b3693d770a1c847 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Mon, 4 Dec 2023 13:57:25 +0100 Subject: [PATCH 17/34] Updated spaces for codefactor analysis --- TestCases/parallel_regression.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 129a6d8d58c..9996abca751 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1377,7 +1377,7 @@ def main(): pywrapper_unsteadyFSI.test_iter = 4 pywrapper_unsteadyFSI.test_vals = [0, 31, 5, 58, -1.756780, -2.828276, -7.652558, -6.863929, 1.5618e-04] pywrapper_unsteadyFSI.command = TestCase.Command("mpirun -np 2", "python", "run.py") - pywrapper_unsteadyFSI.unsteady = True + pywrapper_unsteadyFSI.unsteady = True pywrapper_unsteadyFSI.multizone = True test_list.append(pywrapper_unsteadyFSI) @@ -1792,13 +1792,13 @@ def main(): # Inviscid NACA0012 (triangles) naca0012_cst = TestCase('naca0012_cst') - naca0012_cst.cfg_dir = "deformation/cst" - naca0012_cst.cfg_file = "naca0012.cfg" - naca0012_cst.test_iter = 10 - naca0012_cst.test_vals = [0.000385514] #residual - naca0012_cst.command = TestCase.Command("mpirun -n 2", "SU2_DEF") - naca0012_cst.timeout = 1600 - naca0012_cst.tol = 1e-8 + naca0012_cst.cfg_dir = "deformation/cst" + naca0012_cst.cfg_file = "naca0012.cfg" + naca0012_cst.test_iter = 10 + naca0012_cst.test_vals = [0.000385514] #residual + naca0012_cst.command = TestCase.Command("mpirun -n 2", "SU2_DEF") + naca0012_cst.timeout = 1600 + naca0012_cst.tol = 1e-8 pass_list.append(naca0012_cst.run_def()) test_list.append(naca0012_cst) From 25e49c57af64c9e9900917792edbc5d175ad415d Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Thu, 1 Feb 2024 14:51:47 +0100 Subject: [PATCH 18/34] Implemented more efficient line search method for inclusion level search in look-up table --- Common/include/containers/CLookUpTable.hpp | 3 +-- Common/src/containers/CLookUpTable.cpp | 29 +++++++++++----------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Common/include/containers/CLookUpTable.hpp b/Common/include/containers/CLookUpTable.hpp index a9a9b9f7910..010c5b4d8fc 100644 --- a/Common/include/containers/CLookUpTable.hpp +++ b/Common/include/containers/CLookUpTable.hpp @@ -56,7 +56,7 @@ class CLookUpTable { unsigned long n_variables, n_table_levels = 1; - su2vector z_values_levels; /*!< \brief Constant z-values of each table level.*/ + std::vector z_values_levels; /*!< \brief Constant z-values of each table level.*/ unsigned short table_dim = 2; /*!< \brief Table dimension.*/ /*! @@ -353,7 +353,6 @@ class CLookUpTable { /*! * \brief Find the table levels with constant z-values directly above and below query val_z. * \param[in] val_CV3 - Value of controlling variable 3. - * \param[in] within_limits - Whether query point lies within table bounds. * \returns Pair of inclusion level indices (first = lower level index, second = upper level index). */ std::pair FindInclusionLevels(const su2double val_CV3); diff --git a/Common/src/containers/CLookUpTable.cpp b/Common/src/containers/CLookUpTable.cpp index 698a042a3d5..8ad60b4ca52 100644 --- a/Common/src/containers/CLookUpTable.cpp +++ b/Common/src/containers/CLookUpTable.cpp @@ -406,21 +406,22 @@ void CLookUpTable::GetInterpMatInv(const su2double* vec_x, const su2double* vec_ std::pair CLookUpTable::FindInclusionLevels(const su2double val_CV3) { /*--- Find the table levels with constant z-values directly below and above the query value val_CV3 ---*/ + + unsigned long i_low{0},i_up{0}; + su2double val_z = val_CV3; /* Check if val_CV3 lies outside table bounds */ - if (val_CV3 >= *limits_table_z.second) { - return std::make_pair(n_table_levels - 1, n_table_levels - 1); - } else if (val_CV3 <= *limits_table_z.first) { - return std::make_pair(0, 0); - } else { - std::pair inclusion_levels; - /* Loop over table levels to find the levels directly above and below the query value */ - for (auto i_level = 0ul; i_level < n_table_levels - 1; i_level++) { - if ((val_CV3 >= z_values_levels[i_level]) && (val_CV3 < z_values_levels[i_level + 1])) { - inclusion_levels = std::make_pair(i_level, i_level + 1); - } - } - return inclusion_levels; - } + if (val_z < z_values_levels.front()) val_z = z_values_levels.front(); + if (val_z > z_values_levels.back()) val_z = z_values_levels.back(); + + /* Perform line search to find upper inclusion level. */ + std::pair::iterator, std::vector::iterator> bounds; + bounds = std::equal_range(z_values_levels.begin(), z_values_levels.end(), val_z); + + /*--- if upper bound = 0, then use the range [0,1] ---*/ + i_up = max(1, bounds.first - z_values_levels.begin()); + i_low = i_up - 1; + + return make_pair(i_low, i_up); } unsigned long CLookUpTable::LookUp_XYZ(const std::string& val_name_var, su2double* val_var, su2double val_CV1, From ec2555305e69effc0806c8a38bc5c65b2e492139 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Tue, 5 Mar 2024 13:53:24 +0100 Subject: [PATCH 19/34] Adapted fluidflamelet to new table architecture --- SU2_CFD/include/fluid/CFluidFlamelet.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SU2_CFD/include/fluid/CFluidFlamelet.hpp b/SU2_CFD/include/fluid/CFluidFlamelet.hpp index adb1238d7f5..23307767726 100644 --- a/SU2_CFD/include/fluid/CFluidFlamelet.hpp +++ b/SU2_CFD/include/fluid/CFluidFlamelet.hpp @@ -64,7 +64,8 @@ class CFluidFlamelet final : public CFluidModel { vector LUT_idx_TD, LUT_idx_Sources, - LUT_idx_LookUp; + LUT_idx_LookUp, + LUT_idx_PD; /*--- Class variables for the multi-layer perceptron method ---*/ #ifdef USE_MLPCPP From d61c8947a33707b4bf087b6c7293c06aae711ff6 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Thu, 7 Mar 2024 13:05:03 +0100 Subject: [PATCH 20/34] Implemented Nijso's comments --- Common/include/option_structure.hpp | 4 ++-- SU2_CFD/include/fluid/CFluidFlamelet.hpp | 8 ++++++-- SU2_CFD/include/fluid/CFluidModel.hpp | 4 ++-- SU2_CFD/include/solvers/CHeatSolver.hpp | 4 ++-- SU2_CFD/include/solvers/CScalarSolver.hpp | 10 +++++----- SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp | 4 ++-- SU2_CFD/include/solvers/CSpeciesSolver.hpp | 4 ++-- SU2_CFD/include/solvers/CTransLMSolver.hpp | 4 ++-- SU2_CFD/include/solvers/CTurbSASolver.hpp | 4 ++-- SU2_CFD/include/solvers/CTurbSSTSolver.hpp | 4 ++-- SU2_CFD/src/fluid/CFluidFlamelet.cpp | 6 +++--- SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp | 8 ++++---- SU2_CFD/src/solvers/CSpeciesSolver.cpp | 4 ++-- SU2_CFD/src/solvers/CTransLMSolver.cpp | 4 ++-- SU2_CFD/src/solvers/CTurbSASolver.cpp | 4 ++-- SU2_CFD/src/solvers/CTurbSSTSolver.cpp | 4 ++-- 16 files changed, 42 insertions(+), 38 deletions(-) diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 202d0620d92..a87c4bafe6c 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -1333,8 +1333,8 @@ enum FLAMELET_SCALAR_SOURCES { * \brief Look-up operations for the flamelet scalar solver. */ enum FLAMELET_LOOKUP_OPS { - TD, /*!< \brief Thermochemical properties (temperature, density, diffusivity, etc.). */ - PD, /*!< \brief Preferential diffusion scalars. */ + THERMO, /*!< \brief Thermochemical properties (temperature, density, diffusivity, etc.). */ + PREFDIF, /*!< \brief Preferential diffusion scalars. */ SOURCES, /*!< \brief Scalar source terms (controlling variables, passive species).*/ LOOKUP, /*!< \brief Passive look-up variables specified in config. */ }; diff --git a/SU2_CFD/include/fluid/CFluidFlamelet.hpp b/SU2_CFD/include/fluid/CFluidFlamelet.hpp index 23307767726..5de0231492d 100644 --- a/SU2_CFD/include/fluid/CFluidFlamelet.hpp +++ b/SU2_CFD/include/fluid/CFluidFlamelet.hpp @@ -81,10 +81,14 @@ class CFluidFlamelet final : public CFluidModel { vector scalars_vector; vector varnames_TD, /*!< \brief Lookup names for thermodynamic state variables. */ - varnames_Sources, varnames_LookUp, varnames_PD; + varnames_Sources, /*!< \brief Lookup names for source terms. */ + varnames_LookUp, /*!< \brief Lookup names for passive look-up terms. */ + varnames_PD; /*!< \brief Lookup names for preferential diffusion scalars. */ vector val_vars_TD, /*!< \brief References to thermodynamic state variables. */ - val_vars_Sources, val_vars_LookUp, val_vars_PD; + val_vars_Sources, /*!< \brief References to source terms. */ + val_vars_LookUp, /*!< \brief References passive look-up terms. */ + val_vars_PD; /*!< \brief References to preferential diffusion scalars. */ void PreprocessLookUp(CConfig* config); diff --git a/SU2_CFD/include/fluid/CFluidModel.hpp b/SU2_CFD/include/fluid/CFluidModel.hpp index babdc248c04..29f0becdb0d 100644 --- a/SU2_CFD/include/fluid/CFluidModel.hpp +++ b/SU2_CFD/include/fluid/CFluidModel.hpp @@ -351,8 +351,8 @@ class CFluidModel { virtual unsigned long GetExtrapolation() const { return 0; } /*! - * \brief Preferential diffusion as relevant phenomenon in flamelet simulations. - * \return Inclusion of preferential diffusion model. + * \brief Get the state of the Preferential diffusion model for flamelet simulations. + * \return True if preferential diffusion model is active, false otherwise. */ virtual bool GetPreferentialDiffusion() const { return false; } diff --git a/SU2_CFD/include/solvers/CHeatSolver.hpp b/SU2_CFD/include/solvers/CHeatSolver.hpp index e82c96881d7..627983ec096 100644 --- a/SU2_CFD/include/solvers/CHeatSolver.hpp +++ b/SU2_CFD/include/solvers/CHeatSolver.hpp @@ -103,8 +103,8 @@ class CHeatSolver final : public CScalarSolver { * \param[in] config - Definition of the particular problem. * \note Calls a generic implementation after defining a SolverSpecificNumerics object. */ - inline void Viscous_Residual(unsigned long iEdge, CGeometry* geometry, CSolver** solver_container, - CNumerics* numerics, CConfig* config) override { + inline void Viscous_Residual(const unsigned long iEdge, const CGeometry* geometry, CSolver** solver_container, + CNumerics* numerics, const CConfig* config) override { const CVariable* flow_nodes = flow ? solver_container[FLOW_SOL]->GetNodes() : nullptr; const su2double const_diffusivity = config->GetThermalDiffusivity(); diff --git a/SU2_CFD/include/solvers/CScalarSolver.hpp b/SU2_CFD/include/solvers/CScalarSolver.hpp index ca84ea7c644..ca4ce3e2483 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.hpp +++ b/SU2_CFD/include/solvers/CScalarSolver.hpp @@ -99,9 +99,9 @@ class CScalarSolver : public CSolver { * \param[in] config - Definition of the particular problem. */ template - FORCEINLINE void Viscous_Residual_impl(const SolverSpecificNumericsFunc& SolverSpecificNumerics, unsigned long iEdge, - CGeometry* geometry, CSolver** solver_container, CNumerics* numerics, - CConfig* config) { + FORCEINLINE void Viscous_Residual_impl(const SolverSpecificNumericsFunc& SolverSpecificNumerics, const unsigned long iEdge, + const CGeometry* geometry, CSolver** solver_container, CNumerics* numerics, + const CConfig* config) { const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); CFlowVariable* flowNodes = solver_container[FLOW_SOL] ? su2staticcast_p(solver_container[FLOW_SOL]->GetNodes()) : nullptr; @@ -307,8 +307,8 @@ class CScalarSolver : public CSolver { * \param[in] config - Definition of the particular problem. * \note Calls a generic implementation after defining a SolverSpecificNumerics object. */ - inline virtual void Viscous_Residual(unsigned long iEdge, CGeometry* geometry, CSolver** solver_container, - CNumerics* numerics, CConfig* config) { + inline virtual void Viscous_Residual(const unsigned long iEdge, const CGeometry* geometry, CSolver** solver_container, + CNumerics* numerics, const CConfig* config) { /*--- Define an empty object for solver specific numerics contribution. In case there are none, this default *--- implementation will be called ---*/ auto SolverSpecificNumerics = [&](unsigned long iPoint, unsigned long jPoint) {}; diff --git a/SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp b/SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp index 8d479ebf8ba..1d1bd498230 100644 --- a/SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp +++ b/SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp @@ -194,6 +194,6 @@ class CSpeciesFlameletSolver final : public CSpeciesSolver { * \param[in] config - Definition of the particular problem. * \note Calls a generic implementation after defining a SolverSpecificNumerics object. */ - void Viscous_Residual(unsigned long iEdge, CGeometry* geometry, CSolver** solver_container, CNumerics* numerics, - CConfig* config) final; + void Viscous_Residual(const unsigned long iEdge, const CGeometry* geometry, CSolver** solver_container, CNumerics* numerics, + const CConfig* config) final; }; diff --git a/SU2_CFD/include/solvers/CSpeciesSolver.hpp b/SU2_CFD/include/solvers/CSpeciesSolver.hpp index e1f53de1977..4fbb9419117 100644 --- a/SU2_CFD/include/solvers/CSpeciesSolver.hpp +++ b/SU2_CFD/include/solvers/CSpeciesSolver.hpp @@ -89,8 +89,8 @@ class CSpeciesSolver : public CScalarSolver { * \param[in] config - Definition of the particular problem. * \note Calls a generic implementation after defining a SolverSpecificNumerics object. */ - void Viscous_Residual(unsigned long iEdge, CGeometry* geometry, CSolver** solver_container, CNumerics* numerics, - CConfig* config) override; + void Viscous_Residual(const unsigned long iEdge, const CGeometry* geometry, CSolver** solver_container, CNumerics* numerics, + const CConfig* config) override; /*! * \brief Impose the inlet boundary condition. diff --git a/SU2_CFD/include/solvers/CTransLMSolver.hpp b/SU2_CFD/include/solvers/CTransLMSolver.hpp index 220f2b01ed7..98595abb266 100644 --- a/SU2_CFD/include/solvers/CTransLMSolver.hpp +++ b/SU2_CFD/include/solvers/CTransLMSolver.hpp @@ -98,8 +98,8 @@ class CTransLMSolver final : public CTurbSolver { * \param[in] config - Definition of the particular problem. * \note Calls a generic implementation after defining a SolverSpecificNumerics object. */ - void Viscous_Residual(unsigned long iEdge, CGeometry* geometry, CSolver** solver_container, - CNumerics* numerics, CConfig* config) override; + void Viscous_Residual(const unsigned long iEdge, const CGeometry* geometry, CSolver** solver_container, + CNumerics* numerics, const CConfig* config) override; /*! * \brief Source term computation. diff --git a/SU2_CFD/include/solvers/CTurbSASolver.hpp b/SU2_CFD/include/solvers/CTurbSASolver.hpp index cb0307817e7..c79649799cc 100644 --- a/SU2_CFD/include/solvers/CTurbSASolver.hpp +++ b/SU2_CFD/include/solvers/CTurbSASolver.hpp @@ -125,8 +125,8 @@ class CTurbSASolver final : public CTurbSolver { * \param[in] config - Definition of the particular problem. * \note Calls a generic implementation after defining a SolverSpecificNumerics object. */ - void Viscous_Residual(unsigned long iEdge, CGeometry* geometry, CSolver** solver_container, - CNumerics* numerics, CConfig* config) override; + void Viscous_Residual(const unsigned long iEdge, const CGeometry* geometry, CSolver** solver_container, + CNumerics* numerics, const CConfig* config) override; /*! * \brief Source term computation. diff --git a/SU2_CFD/include/solvers/CTurbSSTSolver.hpp b/SU2_CFD/include/solvers/CTurbSSTSolver.hpp index f4cf89d38d0..bdb4227a191 100644 --- a/SU2_CFD/include/solvers/CTurbSSTSolver.hpp +++ b/SU2_CFD/include/solvers/CTurbSSTSolver.hpp @@ -107,8 +107,8 @@ class CTurbSSTSolver final : public CTurbSolver { * \param[in] config - Definition of the particular problem. * \note Calls a generic implementation after defining a SolverSpecificNumerics object. */ - void Viscous_Residual(unsigned long iEdge, CGeometry* geometry, CSolver** solver_container, - CNumerics* numerics, CConfig* config) override; + void Viscous_Residual(const unsigned long iEdge, const CGeometry* geometry, CSolver** solver_container, + CNumerics* numerics, const CConfig* config) override; /*! * \brief Source term computation. diff --git a/SU2_CFD/src/fluid/CFluidFlamelet.cpp b/SU2_CFD/src/fluid/CFluidFlamelet.cpp index 01260c6850f..06fd814594d 100644 --- a/SU2_CFD/src/fluid/CFluidFlamelet.cpp +++ b/SU2_CFD/src/fluid/CFluidFlamelet.cpp @@ -127,7 +127,7 @@ void CFluidFlamelet::SetTDState_T(su2double val_temperature, const su2double* va for (auto iVar = 0u; iVar < n_scalars; iVar++) scalars_vector[iVar] = val_scalars[iVar]; /*--- Add all quantities and their names to the look up vectors. ---*/ - EvaluateDataSet(scalars_vector, FLAMELET_LOOKUP_OPS::TD, val_vars_TD); + EvaluateDataSet(scalars_vector, FLAMELET_LOOKUP_OPS::THERMO, val_vars_TD); Temperature = val_vars_TD[LOOKUP_TD::TEMPERATURE]; Cp = val_vars_TD[LOOKUP_TD::HEATCAPACITY]; @@ -290,13 +290,13 @@ unsigned long CFluidFlamelet::EvaluateDataSet(const vector& input_sca vector refs_vars; vector LUT_idx; switch (lookup_type) { - case FLAMELET_LOOKUP_OPS::TD: + case FLAMELET_LOOKUP_OPS::THERMO: LUT_idx = LUT_idx_TD; #ifdef USE_MLPCPP iomap_Current = iomap_TD; #endif break; - case FLAMELET_LOOKUP_OPS::PD: + case FLAMELET_LOOKUP_OPS::PREFDIF: LUT_idx = LUT_idx_PD; #ifdef USE_MLPCPP iomap_Current = iomap_PD; diff --git a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp index cc7cb45c575..af0a2ae62d1 100644 --- a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp @@ -110,7 +110,7 @@ void CSpeciesFlameletSolver::Preprocessing(CGeometry* geometry, CSolver** solver SetScalarLookUps(config, fluid_model_local, i_point, scalars_vector); /*--- Set mass diffusivity based on thermodynamic state. ---*/ - su2double T = flowNodes->GetTemperature(i_point); + auto T = flowNodes->GetTemperature(i_point); fluid_model_local->SetTDState_T(T, scalars); /*--- set the diffusivity in the fluid model to the diffusivity obtained from the lookup table ---*/ for (auto i_scalar = 0u; i_scalar < nVar; ++i_scalar) { @@ -557,7 +557,7 @@ unsigned long CSpeciesFlameletSolver::SetPreferentialDiffusionScalars(const CCon /*--- Retrieve the preferential diffusion scalar values from the manifold. ---*/ vector beta_scalar(FLAMELET_PREF_DIFF_SCALARS::N_BETA_TERMS); - unsigned long misses = fluid_model_local->EvaluateDataSet(scalars, FLAMELET_LOOKUP_OPS::PD, beta_scalar); + unsigned long misses = fluid_model_local->EvaluateDataSet(scalars, FLAMELET_LOOKUP_OPS::PREFDIF, beta_scalar); for (auto i_beta = 0u; i_beta < FLAMELET_PREF_DIFF_SCALARS::N_BETA_TERMS; i_beta++) { nodes->SetAuxVar(iPoint, i_beta, beta_scalar[i_beta]); @@ -565,8 +565,8 @@ unsigned long CSpeciesFlameletSolver::SetPreferentialDiffusionScalars(const CCon return misses; } -void CSpeciesFlameletSolver::Viscous_Residual(unsigned long iEdge, CGeometry* geometry, CSolver** solver_container, - CNumerics* numerics, CConfig* config) { +void CSpeciesFlameletSolver::Viscous_Residual(const unsigned long iEdge, const CGeometry* geometry, CSolver** solver_container, + CNumerics* numerics, const CConfig* config) { /*--- Overloaded viscous residual method which accounts for preferential diffusion. ---*/ const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT), PreferentialDiffusion = config->GetPreferentialDiffusion(); diff --git a/SU2_CFD/src/solvers/CSpeciesSolver.cpp b/SU2_CFD/src/solvers/CSpeciesSolver.cpp index f5f5ed16603..05d43f13ff8 100644 --- a/SU2_CFD/src/solvers/CSpeciesSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesSolver.cpp @@ -314,8 +314,8 @@ void CSpeciesSolver::Preprocessing(CGeometry* geometry, CSolver** solver_contain CommonPreprocessing(geometry, config, Output); } -void CSpeciesSolver::Viscous_Residual(unsigned long iEdge, CGeometry* geometry, CSolver** solver_container, - CNumerics* numerics, CConfig* config) { +void CSpeciesSolver::Viscous_Residual(const unsigned long iEdge, const CGeometry* geometry, CSolver** solver_container, + CNumerics* numerics, const CConfig* config) { /*--- Define an object to set solver specific numerics contribution. ---*/ auto SolverSpecificNumerics = [&](unsigned long iPoint, unsigned long jPoint) { /*--- Mass diffusivity coefficients. ---*/ diff --git a/SU2_CFD/src/solvers/CTransLMSolver.cpp b/SU2_CFD/src/solvers/CTransLMSolver.cpp index b67e1b1af96..af89924ea2e 100644 --- a/SU2_CFD/src/solvers/CTransLMSolver.cpp +++ b/SU2_CFD/src/solvers/CTransLMSolver.cpp @@ -263,8 +263,8 @@ void CTransLMSolver::Postprocessing(CGeometry *geometry, CSolver **solver_contai } -void CTransLMSolver::Viscous_Residual(unsigned long iEdge, CGeometry* geometry, CSolver** solver_container, - CNumerics* numerics, CConfig* config) { +void CTransLMSolver::Viscous_Residual(const unsigned long iEdge, const CGeometry* geometry, CSolver** solver_container, + CNumerics* numerics, const CConfig* config) { /*--- Define an object to set solver specific numerics contribution. ---*/ diff --git a/SU2_CFD/src/solvers/CTurbSASolver.cpp b/SU2_CFD/src/solvers/CTurbSASolver.cpp index f3a6d57b589..d84b56e1dc6 100644 --- a/SU2_CFD/src/solvers/CTurbSASolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSASolver.cpp @@ -291,8 +291,8 @@ void CTurbSASolver::Postprocessing(CGeometry *geometry, CSolver **solver_contain AD::EndNoSharedReading(); } -void CTurbSASolver::Viscous_Residual(unsigned long iEdge, CGeometry* geometry, CSolver** solver_container, - CNumerics* numerics, CConfig* config) { +void CTurbSASolver::Viscous_Residual(const unsigned long iEdge, const CGeometry* geometry, CSolver** solver_container, + CNumerics* numerics, const CConfig* config) { /*--- Define an object to set solver specific numerics contribution. ---*/ auto SolverSpecificNumerics = [&](unsigned long iPoint, unsigned long jPoint) { diff --git a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp index 1973b70a331..ea316e9a0cd 100644 --- a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp @@ -276,8 +276,8 @@ void CTurbSSTSolver::Postprocessing(CGeometry *geometry, CSolver **solver_contai AD::EndNoSharedReading(); } -void CTurbSSTSolver::Viscous_Residual(unsigned long iEdge, CGeometry* geometry, CSolver** solver_container, - CNumerics* numerics, CConfig* config) { +void CTurbSSTSolver::Viscous_Residual(const unsigned long iEdge, const CGeometry* geometry, CSolver** solver_container, + CNumerics* numerics, const CConfig* config) { /*--- Define an object to set solver specific numerics contribution. ---*/ auto SolverSpecificNumerics = [&](unsigned long iPoint, unsigned long jPoint) { From 572ce65b9e454f0308bbbabbfe049492539d9d1b Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Thu, 7 Mar 2024 13:15:29 +0100 Subject: [PATCH 21/34] Added config option for preferential diffusion model --- Common/src/CConfig.cpp | 3 +++ SU2_CFD/src/fluid/CFluidFlamelet.cpp | 6 ++++-- .../laminar_premixed_h2_flame_cfd.cfg | 1 + config_template.cfg | 8 ++++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index ef9ce56469f..70d535c02b5 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -2145,6 +2145,9 @@ void CConfig::SetConfig_Options() { /* DESCRIPTION: Names of the user scalar source terms. */ addStringListOption("USER_SOURCE_NAMES", n_user_sources, user_source_names); + /* DESCRIPTION: Enable preferential diffusion for FGM simulations. \n DEFAULT: false */ + addBoolOption("PREFERENTIAL_DIFFUSION", preferential_diffusion, false); + /*!\brief CONV_FILENAME \n DESCRIPTION: Output file convergence history (w/o extension) \n DEFAULT: history \ingroup Config*/ addStringOption("CONV_FILENAME", Conv_FileName, string("history")); /*!\brief BREAKDOWN_FILENAME \n DESCRIPTION: Output file forces breakdown \ingroup Config*/ diff --git a/SU2_CFD/src/fluid/CFluidFlamelet.cpp b/SU2_CFD/src/fluid/CFluidFlamelet.cpp index 06fd814594d..319265d7379 100644 --- a/SU2_CFD/src/fluid/CFluidFlamelet.cpp +++ b/SU2_CFD/src/fluid/CFluidFlamelet.cpp @@ -98,7 +98,6 @@ CFluidFlamelet::CFluidFlamelet(CConfig* config, su2double value_pressure_operati PreprocessLookUp(config); - config->SetPreferentialDiffusion(PreferentialDiffusion); if (rank == MASTER_NODE) { cout << "Preferential diffusion: " << (PreferentialDiffusion ? "Enabled" : "Disabled") << endl; } @@ -217,7 +216,7 @@ void CFluidFlamelet::PreprocessLookUp(CConfig* config) { val_vars_PD[FLAMELET_PREF_DIFF_SCALARS::I_BETA_ENTH] = beta_enth; val_vars_PD[FLAMELET_PREF_DIFF_SCALARS::I_BETA_MIXFRAC] = beta_mixfrac; - PreferentialDiffusion = false; + PreferentialDiffusion = config->GetPreferentialDiffusion(); switch (Kind_DataDriven_Method) { case ENUM_DATADRIVEN_METHOD::LUT: PreferentialDiffusion = look_up_table->CheckForVariables(varnames_PD); @@ -236,6 +235,9 @@ void CFluidFlamelet::PreprocessLookUp(CConfig* config) { break; } + if (!PreferentialDiffusion && config->GetPreferentialDiffusion()) + SU2_MPI::Error("Preferential diffusion scalars not included in flamelet manifold.", CURRENT_FUNCTION); + if (Kind_DataDriven_Method == ENUM_DATADRIVEN_METHOD::MLP) { #ifdef USE_MLPCPP iomap_TD = new MLPToolbox::CIOMap(controlling_variable_names, varnames_TD); diff --git a/TestCases/flamelet/07_laminar_premixed_h2_flame_cfd/laminar_premixed_h2_flame_cfd.cfg b/TestCases/flamelet/07_laminar_premixed_h2_flame_cfd/laminar_premixed_h2_flame_cfd.cfg index b753483f8f3..314a4aae37d 100644 --- a/TestCases/flamelet/07_laminar_premixed_h2_flame_cfd/laminar_premixed_h2_flame_cfd.cfg +++ b/TestCases/flamelet/07_laminar_premixed_h2_flame_cfd/laminar_premixed_h2_flame_cfd.cfg @@ -33,6 +33,7 @@ DIFFUSIVITY_MODEL= FLAMELET KIND_SCALAR_MODEL= FLAMELET INTERPOLATION_METHOD= MLP FILENAMES_INTERPOLATOR= (MLP_TD.mlp, MLP_PD.mlp, MLP_PPV.mlp, MLP_null.mlp) +PREFERENTIAL_DIFFUSION= YES % -------------------- SCALAR TRANSPORT ---------------------------------------% % diff --git a/config_template.cfg b/config_template.cfg index 6e824a9aa1f..74832ef98db 100644 --- a/config_template.cfg +++ b/config_template.cfg @@ -911,6 +911,14 @@ CONTROLLING_VARIABLE_SOURCE_NAMES= (ProdRateTot_PV, NULL) % By default, this option is set to NONE FLAME_INIT_METHOD= FLAME_FRONT +% Enable preferential diffusion for progress variable, total enthalpy, mixture fraction FGM problems. +% If 'YES', the preferential diffusion model from Efimov et al.(2021) is used for computing the viscous residual terms. +% If enabled, make sure the variables "Beta_ProgVar", "Beta_Enth_Thermal", "Beta_Enth", and "Beta_MixFrac", corresponding +% to the preferential diffusion terms of the progress variable, temperature, total enthalpy, and mixture fraction +% respectively are included in the manifold. +% By default, this option is disabled. +PREFERENTIAL_DIFFUSION= NO + % FLAME_FRONT initialization % the flame is initialized using a plane, defined by a point and a normal. On one side, the solution is initialized % using 'burnt' conditions and on the other side 'unburnt' conditions. The normal points in the direction of the 'burnt' From 3cbdef7df751ea12a2f20e4ea8fe445c21001ac8 Mon Sep 17 00:00:00 2001 From: Evert Bunschoten <38651601+EvertBunschoten@users.noreply.github.com> Date: Thu, 7 Mar 2024 13:17:49 +0100 Subject: [PATCH 22/34] Update Common/include/containers/CLookUpTable.hpp Co-authored-by: Nijso --- Common/include/containers/CLookUpTable.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/include/containers/CLookUpTable.hpp b/Common/include/containers/CLookUpTable.hpp index b8d24f5762a..9f06548c377 100644 --- a/Common/include/containers/CLookUpTable.hpp +++ b/Common/include/containers/CLookUpTable.hpp @@ -410,7 +410,7 @@ class CLookUpTable { } /*! - * \brief Check whether provided set of variables are included in the table. + * \brief Check whether requested set of variables are included in the table. */ bool CheckForVariables(const std::vector& vars_to_check); From 7ab2deae1b72f4865103047b6d0c2ba6dbff5a4b Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Thu, 7 Mar 2024 13:26:06 +0100 Subject: [PATCH 23/34] Fixed issues from CodeFactor --- TestCases/parallel_regression.py | 36 ++++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 259925d064a..8b1ad47fde7 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1066,8 +1066,8 @@ def main(): axial_stage2D.cfg_dir = "turbomachinery/axial_stage_2D" axial_stage2D.cfg_file = "Axial_stage2D.cfg" axial_stage2D.test_iter = 20 - axial_stage2D.test_vals = [0.983754, 1.534455, -2.888523, 2.606770, -2.418403, 3.087203, 106380, 106380, 5.7325, 64.711] - axial_stage2D.test_vals_aarch64 = [0.983754, 1.534455, -2.888523, 2.606770, -2.418403, 3.087203, 106380, 106380, 5.7325, 64.711] + axial_stage2D.test_vals = [0.983754, 1.534455, -2.888523, 2.606770, -2.418403, 3.087203, 106380, 106380, 5.7325, 64.711] + axial_stage2D.test_vals_aarch64 = [0.983754, 1.534455, -2.888523, 2.606770, -2.418403, 3.087203, 106380, 106380, 5.7325, 64.711] test_list.append(axial_stage2D) # 2D transonic stator restart @@ -1075,7 +1075,7 @@ def main(): transonic_stator_restart.cfg_dir = "turbomachinery/transonic_stator_2D" transonic_stator_restart.cfg_file = "transonic_stator_restart.cfg" transonic_stator_restart.test_iter = 20 - transonic_stator_restart.test_vals = [-5.011834, -3.091110, -2.757795, 1.087934, -3.544707, 2.166101, -471630, 94.868, -0.035888] + transonic_stator_restart.test_vals = [-5.011834, -3.091110, -2.757795, 1.087934, -3.544707, 2.166101, -471630, 94.868, -0.035888] transonic_stator_restart.test_vals_aarch64 = [-5.011834, -3.091110, -2.757795, 1.087934, -3.544707, 2.166101, -471630, 94.868, -0.035888] test_list.append(transonic_stator_restart) @@ -1571,13 +1571,13 @@ def main(): ##################### # CGNS writer - cgns_writer = TestCase('cgns_writer') - cgns_writer.cfg_dir = "cgns_writer" - cgns_writer.cfg_file = "config.cfg" - cgns_writer.test_iter = 1 - cgns_writer.test_vals = [-2.974473, 0.665204, 5.068846, -7.003873] - cgns_writer.command = TestCase.Command("mpirun -n 2", "SU2_CFD") - cgns_writer.new_output = True + cgns_writer = TestCase('cgns_writer') + cgns_writer.cfg_dir = "cgns_writer" + cgns_writer.cfg_file = "config.cfg" + cgns_writer.test_iter = 1 + cgns_writer.test_vals = [-2.974473, 0.665204, 5.068846, -7.003873] + cgns_writer.command = TestCase.Command("mpirun -n 2", "SU2_CFD") + cgns_writer.new_output = True test_list.append(cgns_writer) ###################################### @@ -1807,14 +1807,14 @@ def main(): test_list.append(sphere_ffd_def_bspline) # Inviscid NACA0012 (triangles) - naca0012_cst = TestCase('naca0012_cst') - naca0012_cst.cfg_dir = "deformation/cst" - naca0012_cst.cfg_file = "naca0012.cfg" - naca0012_cst.test_iter = 10 - naca0012_cst.test_vals = [0.000385514] #residual - naca0012_cst.command = TestCase.Command("mpirun -n 2", "SU2_DEF") - naca0012_cst.timeout = 1600 - naca0012_cst.tol = 1e-8 + naca0012_cst = TestCase('naca0012_cst') + naca0012_cst.cfg_dir = "deformation/cst" + naca0012_cst.cfg_file = "naca0012.cfg" + naca0012_cst.test_iter = 10 + naca0012_cst.test_vals = [0.000385514] #residual + naca0012_cst.command = TestCase.Command("mpirun -n 2", "SU2_DEF") + naca0012_cst.timeout = 1600 + naca0012_cst.tol = 1e-8 pass_list.append(naca0012_cst.run_def()) test_list.append(naca0012_cst) From 7ab1e086d220a31646568d168f622a50ae82332f Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Wed, 17 Apr 2024 16:46:55 +0200 Subject: [PATCH 24/34] Updated tutorials branch --- .github/workflows/regression.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index b9436addd59..159ec2a522b 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -173,7 +173,7 @@ jobs: uses: docker://ghcr.io/su2code/su2/test-su2:230813-0103 with: # -t -c - args: -b ${{github.ref}} -t develop -c feature_new_flamelet -s ${{matrix.testscript}} + args: -b ${{github.ref}} -t feature_new_flamelet -c feature_new_flamelet -s ${{matrix.testscript}} - name: Cleanup uses: docker://ghcr.io/su2code/su2/test-su2:230813-0103 with: From 67a975fcf3278318c86d767471c88c0fc83d9a5c Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Thu, 18 Apr 2024 09:38:55 +0200 Subject: [PATCH 25/34] Corrected gradient method determination for auxilary variables in flamelet solver --- SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp | 3 +-- TestCases/parallel_regression.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp index af0a2ae62d1..8fa2d426d8d 100644 --- a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp @@ -132,12 +132,11 @@ void CSpeciesFlameletSolver::Preprocessing(CGeometry* geometry, CSolver** solver /*--- Compute preferential diffusion scalar gradients. ---*/ if (config->GetPreferentialDiffusion()) { - switch (config->GetKind_Gradient_Method_Recon()) { + switch (config->GetKind_Gradient_Method()) { case GREEN_GAUSS: SetAuxVar_Gradient_GG(geometry, config); break; case WEIGHTED_LEAST_SQUARES: - case LEAST_SQUARES: SetAuxVar_Gradient_LS(geometry, config); break; default: diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 823fb7446cb..2c391651825 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1054,7 +1054,7 @@ def main(): ###################################### # Aachen Turbine restart - Aachen_3D_restart = TestCase('aachen_turbine_restart') + Aachen_3D_restart = TestCase('aachen_turbine_restart') Aachen_3D_restart.cfg_dir = "turbomachinery/Aachen_turbine" Aachen_3D_restart.cfg_file = "aachen_3D_MP_restart.cfg" Aachen_3D_restart.test_iter = 5 From 54e98dc71a224f21a9f6bdcc0d48dc5b26826c45 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Wed, 24 Apr 2024 13:21:41 +0200 Subject: [PATCH 26/34] CodeFactor complaints --- TestCases/parallel_regression.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 2c391651825..452898b3fad 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1054,9 +1054,9 @@ def main(): ###################################### # Aachen Turbine restart - Aachen_3D_restart = TestCase('aachen_turbine_restart') - Aachen_3D_restart.cfg_dir = "turbomachinery/Aachen_turbine" - Aachen_3D_restart.cfg_file = "aachen_3D_MP_restart.cfg" + Aachen_3D_restart = TestCase('aachen_turbine_restart') + Aachen_3D_restart.cfg_dir = "turbomachinery/Aachen_turbine" + Aachen_3D_restart.cfg_file = "aachen_3D_MP_restart.cfg" Aachen_3D_restart.test_iter = 5 Aachen_3D_restart.test_vals = [-15.329206, -15.008622, -15.078888, -13.841072, -12.727840, -9.975729] test_list.append(Aachen_3D_restart) From 147fdf035b598471a51c2f79efc7e0a231032111 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Thu, 25 Apr 2024 09:55:20 +0200 Subject: [PATCH 27/34] Added hydrogen combustion tutorial to tutorial regression tests and updated MLPCpp module --- .../laminar_premixed_h2_flame_cfd.cfg | 2 +- TestCases/tutorials.py | 10 ++++++++++ meson_scripts/init.py | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/TestCases/flamelet/07_laminar_premixed_h2_flame_cfd/laminar_premixed_h2_flame_cfd.cfg b/TestCases/flamelet/07_laminar_premixed_h2_flame_cfd/laminar_premixed_h2_flame_cfd.cfg index 314a4aae37d..8e2a13a7274 100644 --- a/TestCases/flamelet/07_laminar_premixed_h2_flame_cfd/laminar_premixed_h2_flame_cfd.cfg +++ b/TestCases/flamelet/07_laminar_premixed_h2_flame_cfd/laminar_premixed_h2_flame_cfd.cfg @@ -107,7 +107,7 @@ CONV_RESIDUAL_MINVAL= -5 CONV_STARTITER= 20 SCREEN_OUTPUT = INNER_ITER RMS_PRESSURE RMS_ProgressVariable RMS_EnthalpyTot RMS_MixtureFraction HISTORY_OUTPUT = WALL_TIME RMS_RES -VOLUME_OUTPUT = SOLUTION PRIMITIVE SOURCE RESIDUAL +VOLUME_OUTPUT = SOLUTION % ------------------------- INPUT/OUTPUT INFORMATION --------------------------% % diff --git a/TestCases/tutorials.py b/TestCases/tutorials.py index 849a4f85c26..263e0bdf60e 100644 --- a/TestCases/tutorials.py +++ b/TestCases/tutorials.py @@ -120,6 +120,16 @@ def main(): sudo_tutorial.command = TestCase.Command("mpirun -n 2", "SU2_CFD") test_list.append(sudo_tutorial) + ### Incompressible Combustion + + # Pre-mixed, laminar hydrogen flame with heat loss + premixed_hydrogen = TestCase('premixed_hydrogen') + premixed_hydrogen.cfg_dir = "../Tutorials/incompressible_flow/Inc_Combustion/1__premixed_hydrogen" + premixed_hydrogen.cfg_file = "H2_burner.cfg" + premixed_hydrogen.test_iter = 10 + premixed_hydrogen.test_vals = [-9.828673,-10.420037,-11.041527,-4.321735,-11.868641] + test_list.append(premixed_hydrogen) + ### Compressible Flow # Inviscid Bump diff --git a/meson_scripts/init.py b/meson_scripts/init.py index 787bfb56e2f..bc58f9a9564 100755 --- a/meson_scripts/init.py +++ b/meson_scripts/init.py @@ -71,7 +71,7 @@ def init_submodules( github_repo_coolprop = "https://github.com/CoolProp/CoolProp" sha_version_mel = "46205ab019e5224559091375a6d71aabae6bc5b9" github_repo_mel = "https://github.com/pcarruscag/MEL" - sha_version_mlpcpp = "665c45b7d3533c977eb1f637918d5b8b75c07d3b" + sha_version_mlpcpp = "c19c53ea2b85ccfb185f1c6c87044dc0b5bc7ae0" github_repo_mlpcpp = "https://github.com/EvertBunschoten/MLPCpp" medi_name = "MeDiPack" From 1effb945fe7f57553ecca2fa2f4259fcc7efbace Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Thu, 25 Apr 2024 10:00:58 +0200 Subject: [PATCH 28/34] Addressed CodeFactor complaints --- TestCases/tutorials.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/TestCases/tutorials.py b/TestCases/tutorials.py index 263e0bdf60e..310d974ab3d 100644 --- a/TestCases/tutorials.py +++ b/TestCases/tutorials.py @@ -123,9 +123,9 @@ def main(): ### Incompressible Combustion # Pre-mixed, laminar hydrogen flame with heat loss - premixed_hydrogen = TestCase('premixed_hydrogen') - premixed_hydrogen.cfg_dir = "../Tutorials/incompressible_flow/Inc_Combustion/1__premixed_hydrogen" - premixed_hydrogen.cfg_file = "H2_burner.cfg" + premixed_hydrogen = TestCase('premixed_hydrogen') + premixed_hydrogen.cfg_dir = "../Tutorials/incompressible_flow/Inc_Combustion/1__premixed_hydrogen" + premixed_hydrogen.cfg_file = "H2_burner.cfg" premixed_hydrogen.test_iter = 10 premixed_hydrogen.test_vals = [-9.828673,-10.420037,-11.041527,-4.321735,-11.868641] test_list.append(premixed_hydrogen) From 3a2895d971738126870e74433d66daacfa8ffde0 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Thu, 25 Apr 2024 14:29:40 +0200 Subject: [PATCH 29/34] Updated MLPCpp module --- subprojects/MLPCpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/MLPCpp b/subprojects/MLPCpp index 665c45b7d35..c19c53ea2b8 160000 --- a/subprojects/MLPCpp +++ b/subprojects/MLPCpp @@ -1 +1 @@ -Subproject commit 665c45b7d3533c977eb1f637918d5b8b75c07d3b +Subproject commit c19c53ea2b85ccfb185f1c6c87044dc0b5bc7ae0 From bde5980835b944e447a594c94b7ab28f84ba16aa Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Thu, 25 Apr 2024 15:08:48 +0200 Subject: [PATCH 30/34] Updated regression test values for hydrogen combustion case --- TestCases/parallel_regression.py | 2 +- TestCases/tutorials.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 452898b3fad..b891e7d9a84 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -74,7 +74,7 @@ def main(): cfd_flamelet_h2.cfg_dir = "flamelet/07_laminar_premixed_h2_flame_cfd" cfd_flamelet_h2.cfg_file = "laminar_premixed_h2_flame_cfd.cfg" cfd_flamelet_h2.test_iter = 5 - cfd_flamelet_h2.test_vals = [-9.914406, -9.807959, -3.260701, -11.304908] + cfd_flamelet_h2.test_vals = [-10.003106, -9.843748, -3.289857, -11.338273] cfd_flamelet_h2.new_output = True test_list.append(cfd_flamelet_h2) diff --git a/TestCases/tutorials.py b/TestCases/tutorials.py index 310d974ab3d..f63fb81c990 100644 --- a/TestCases/tutorials.py +++ b/TestCases/tutorials.py @@ -127,7 +127,7 @@ def main(): premixed_hydrogen.cfg_dir = "../Tutorials/incompressible_flow/Inc_Combustion/1__premixed_hydrogen" premixed_hydrogen.cfg_file = "H2_burner.cfg" premixed_hydrogen.test_iter = 10 - premixed_hydrogen.test_vals = [-9.828673,-10.420037,-11.041527,-4.321735,-11.868641] + premixed_hydrogen.test_vals = [-9.905856, -10.449512, -11.035999, -4.331440, -11.882740] test_list.append(premixed_hydrogen) ### Compressible Flow From 65f06c477ef19dd1098f7d12c2786ac512e64dac Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Thu, 25 Apr 2024 19:41:48 +0200 Subject: [PATCH 31/34] Implemented Pedro's comments --- Common/include/CConfig.hpp | 4 ++++ Common/include/containers/CLookUpTable.hpp | 2 +- Common/include/option_structure.hpp | 2 +- Common/src/CConfig.cpp | 3 ++- Common/src/containers/CLookUpTable.cpp | 2 +- .../src/solvers/CSpeciesFlameletSolver.cpp | 22 +++++++------------ .../laminar_premixed_h2_flame_cfd.cfg | 1 - 7 files changed, 17 insertions(+), 19 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index cb65388d1e3..bab87d1b2ac 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -2226,7 +2226,11 @@ class CConfig { if (n_user_sources > 0) return user_source_names[i_user_source]; else return none; } + /*! + * \brief Get the ignition method used for combustion problems. + */ FLAMELET_INIT_TYPE GetFlameletInitType() const { return flame_init_type; } + /*! * \brief Get the number of transported scalars for combustion. */ diff --git a/Common/include/containers/CLookUpTable.hpp b/Common/include/containers/CLookUpTable.hpp index 9f06548c377..230b009fc92 100644 --- a/Common/include/containers/CLookUpTable.hpp +++ b/Common/include/containers/CLookUpTable.hpp @@ -412,7 +412,7 @@ class CLookUpTable { /*! * \brief Check whether requested set of variables are included in the table. */ - bool CheckForVariables(const std::vector& vars_to_check); + bool CheckForVariables(const std::vector& vars_to_check) const; /*! * \brief Returns the index to the variable in the lookup table. diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index a87c4bafe6c..919aefa65b9 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -1340,7 +1340,7 @@ enum FLAMELET_LOOKUP_OPS { }; /*! - * \brief the preferential diffusion scalar indices for the preferential diffusion model. + * \brief The preferential diffusion scalar indices for the preferential diffusion model. */ enum FLAMELET_PREF_DIFF_SCALARS { I_BETA_PROGVAR, /*!< \brief Preferential diffusion scalar for the progress variable. */ diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 70d535c02b5..ff2ffaf1eb9 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -988,6 +988,7 @@ void CConfig::SetPointersNull() { Species_Clipping_Min = nullptr; Species_Clipping_Max = nullptr; spark_reaction_rates = nullptr; + /*--- Moving mesh pointers ---*/ nKind_SurfaceMovement = 0; @@ -9233,7 +9234,7 @@ su2double CConfig::GetIsothermal_Temperature(const string& val_marker) const { if (Marker_Isothermal[iMarker_Isothermal] == val_marker) return Isothermal_Temperature[iMarker_Isothermal]; - return Temperature_FreeStream; + return Isothermal_Temperature[0]; } su2double CConfig::GetWall_HeatFlux(const string& val_marker) const { diff --git a/Common/src/containers/CLookUpTable.cpp b/Common/src/containers/CLookUpTable.cpp index e467070e621..5d6ba81b9b4 100644 --- a/Common/src/containers/CLookUpTable.cpp +++ b/Common/src/containers/CLookUpTable.cpp @@ -803,7 +803,7 @@ bool CLookUpTable::IsInTriangle(su2double val_CV1, su2double val_CV2, unsigned l return (abs(area_tri - (area_0 + area_1 + area_2)) < area_tri * 1e-10); } -bool CLookUpTable::CheckForVariables(const std::vector& vars_to_check) { +bool CLookUpTable::CheckForVariables(const std::vector& vars_to_check) const { bool variables_are_present{true}; for (auto iVar = 0u; iVar < vars_to_check.size(); iVar++) { bool var_is_present{false}; diff --git a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp index 8fa2d426d8d..d31a071a4e1 100644 --- a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp @@ -96,9 +96,8 @@ void CSpeciesFlameletSolver::Preprocessing(CGeometry* geometry, CSolver** solver /*--- Apply source terms within spark radius. ---*/ su2double dist_from_center = 0, spark_radius = config->GetFlameInit()[3]; - for (auto iDim = 0u; iDim < nDim; ++iDim) - dist_from_center += pow(geometry->nodes->GetCoord(i_point, iDim) - config->GetFlameInit()[iDim], 2); - if (sqrt(dist_from_center) < spark_radius) { + dist_from_center = GeometryToolbox::SquaredDistance(nDim, geometry->nodes->GetCoord(i_point), config->GetFlameInit()); + if (dist_from_center < pow(spark_radius,2)) { for (auto iVar = 0u; iVar < nVar; iVar++) nodes->SetScalarSource(i_point, iVar, nodes->GetScalarSources(i_point)[iVar] + config->GetSpark()[iVar]); } @@ -411,10 +410,8 @@ void CSpeciesFlameletSolver::BC_Isothermal_Wall_Generic(CGeometry* geometry, CSo CConfig* config, unsigned short val_marker, bool cht_mode) { const bool implicit = config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT; const string Marker_Tag = config->GetMarker_All_TagBound(val_marker); - su2double temp_wall; CFluidModel* fluid_model_local = solver_container[FLOW_SOL]->GetFluidModel(); auto* flowNodes = su2staticcast_p(solver_container[FLOW_SOL]->GetNodes()); - su2double enth_wall; unsigned long n_not_iterated = 0; /*--- Loop over all the vertices on this boundary marker. ---*/ @@ -422,6 +419,7 @@ void CSpeciesFlameletSolver::BC_Isothermal_Wall_Generic(CGeometry* geometry, CSo for (unsigned long iVertex = 0; iVertex < geometry->nVertex[val_marker]; iVertex++) { unsigned long iPoint = geometry->vertex[val_marker][iVertex]->GetNode(); + su2double temp_wall, enth_wall; if (cht_mode) temp_wall = solver_container[FLOW_SOL]->GetConjugateHeatVariable(val_marker, iVertex, 0); else @@ -588,15 +586,15 @@ void CSpeciesFlameletSolver::Viscous_Residual(const unsigned long iEdge, const C if (PreferentialDiffusion) { CFlowVariable* flowNodes = su2staticcast_p(solver_container[FLOW_SOL]->GetNodes()); - su2double *scalar_i, *scalar_j, *diff_coeff_beta_i, *diff_coeff_beta_j; - scalar_i = new su2double[nVar]; - scalar_j = new su2double[nVar]; - diff_coeff_beta_i = new su2double[nVar], diff_coeff_beta_j = new su2double[nVar]; + su2double scalar_i[MAXNVAR] = {0}, + scalar_j[MAXNVAR] = {0}, + diff_coeff_beta_i[MAXNVAR] = {0}, + diff_coeff_beta_j[MAXNVAR] = {0}; // Number of active transport scalars const auto n_CV = config->GetNControlVars(); - su2activematrix scalar_grad_i(nVar, nDim), scalar_grad_j(nVar, nDim); + su2activematrix scalar_grad_i(MAXNVAR, MAXNDIM), scalar_grad_j(MAXNVAR, MAXNDIM); /*--- Looping over spatial dimensions to fill in the diffusion scalar gradients. ---*/ /*--- The scalar gradient is subtracted to account for regular viscous diffusion. ---*/ for (auto iScalar = 0u; iScalar < n_CV; ++iScalar) { @@ -737,10 +735,6 @@ void CSpeciesFlameletSolver::Viscous_Residual(const unsigned long iEdge, const C LinSysRes.AddBlock(jPoint, residual_thermal); /* No implicit part for the preferential diffusion of heat */ } - delete[] scalar_i; - delete[] scalar_j; - delete[] diff_coeff_beta_i; - delete[] diff_coeff_beta_j; } } diff --git a/TestCases/flamelet/07_laminar_premixed_h2_flame_cfd/laminar_premixed_h2_flame_cfd.cfg b/TestCases/flamelet/07_laminar_premixed_h2_flame_cfd/laminar_premixed_h2_flame_cfd.cfg index 8e2a13a7274..3f294865a17 100644 --- a/TestCases/flamelet/07_laminar_premixed_h2_flame_cfd/laminar_premixed_h2_flame_cfd.cfg +++ b/TestCases/flamelet/07_laminar_premixed_h2_flame_cfd/laminar_premixed_h2_flame_cfd.cfg @@ -5,7 +5,6 @@ % Author: Evert Bunschoten % % Institution: Delft University of Technology % % Date: 01/11/2023 % -% File Version 8.0.0 "Harrier" % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% From 9b0351d0d0b9a131319ec1444b5f38d92469b0ed Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Fri, 26 Apr 2024 10:09:46 +0200 Subject: [PATCH 32/34] Implemented suggestions from Nijso and Pedro --- Common/include/CConfig.hpp | 9 +++-- Common/src/CConfig.cpp | 4 +- Common/src/containers/CLookUpTable.cpp | 14 +++---- SU2_CFD/include/fluid/CFluidFlamelet.hpp | 6 +-- SU2_CFD/src/fluid/CFluidFlamelet.cpp | 40 +++++++------------ .../src/solvers/CSpeciesFlameletSolver.cpp | 2 +- 6 files changed, 32 insertions(+), 43 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index bab87d1b2ac..bc32b5407b1 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -1224,9 +1224,10 @@ class CConfig { unsigned short nSpecies_Init; /*!< \brief Number of entries of SPECIES_INIT */ /*--- Additional flamelet solver options ---*/ + ///TODO: Add python wrapper initialization option FLAMELET_INIT_TYPE flame_init_type = FLAMELET_INIT_TYPE::NONE; /*!< \brief Method for solution ignition for flamelet problems. */ - su2double flame_init[8]; /*!< \brief Flame front initialization parameters. */ - su2double spark_init[6]; /*!< \brief Spark ignition initialization parameters. */ + std::array flame_init; /*!< \brief Flame front initialization parameters. */ + std::array spark_init; /*!< \brief Spark ignition initialization parameters. */ su2double* spark_reaction_rates; /*!< \brief Source terms for flamelet spark ignition option. */ unsigned short nspark; /*!< \brief Number of source terms for spark initialization. */ bool preferential_diffusion = false; /*!< \brief Preferential diffusion physics for flamelet solver.*/ @@ -2154,10 +2155,10 @@ class CConfig { switch (flame_init_type) { case FLAMELET_INIT_TYPE::FLAME_FRONT: - return flame_init; + return flame_init.data(); break; case FLAMELET_INIT_TYPE::SPARK: - return spark_init; + return spark_init.data(); break; default: return nullptr; diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index ff2ffaf1eb9..63810ab3e03 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1386,11 +1386,11 @@ void CConfig::SetConfig_Options() { flame_init[3] = 1.0; flame_init[4] = 0.0; flame_init[5] = 0.0; /*--- flame thickness (x) and flame burnt thickness (after this thickness, we have unburnt conditions again) ---*/ flame_init[6] = 0.5e-3; flame_init[7] = 1.0; - addDoubleArrayOption("FLAME_INIT", 8,flame_init); + addDoubleArrayOption("FLAME_INIT", 8,flame_init.begin()); /*!\brief SPARK_INIT \n DESCRIPTION: spark initialization using the flamelet model \ingroup Config*/ for (auto iSpark=0u; iSpark<6; ++iSpark) spark_init[iSpark]=0; - addDoubleArrayOption("SPARK_INIT", 6, spark_init); + addDoubleArrayOption("SPARK_INIT", 6, spark_init.begin()); /*!\brief SPARK_REACTION_RATES \n DESCRIPTION: Net source term values applied to species within spark area during spark ignition. \ingroup Config*/ addDoubleListOption("SPARK_REACTION_RATES", nspark, spark_reaction_rates); diff --git a/Common/src/containers/CLookUpTable.cpp b/Common/src/containers/CLookUpTable.cpp index 5d6ba81b9b4..16c042efba7 100644 --- a/Common/src/containers/CLookUpTable.cpp +++ b/Common/src/containers/CLookUpTable.cpp @@ -804,13 +804,11 @@ bool CLookUpTable::IsInTriangle(su2double val_CV1, su2double val_CV2, unsigned l } bool CLookUpTable::CheckForVariables(const std::vector& vars_to_check) const { - bool variables_are_present{true}; - for (auto iVar = 0u; iVar < vars_to_check.size(); iVar++) { - bool var_is_present{false}; - for (auto jVar = 0u; jVar < names_var.size(); jVar++) { - if (vars_to_check[iVar].compare(names_var[jVar]) == 0) var_is_present = true; - } - if (!var_is_present) variables_are_present = false; + for (const string& var_to_check : vars_to_check) { + if (!std::any_of(names_var.begin(), names_var.end(), + [var_to_check](const std::string& n) { return var_to_check == n; })) { + return false; + }; } - return variables_are_present; + return true; } diff --git a/SU2_CFD/include/fluid/CFluidFlamelet.hpp b/SU2_CFD/include/fluid/CFluidFlamelet.hpp index 5de0231492d..49273b2a9e6 100644 --- a/SU2_CFD/include/fluid/CFluidFlamelet.hpp +++ b/SU2_CFD/include/fluid/CFluidFlamelet.hpp @@ -34,7 +34,7 @@ #define USE_MLPCPP #endif #include "CFluidModel.hpp" -#include + class CFluidFlamelet final : public CFluidModel { private: ENUM_DATADRIVEN_METHOD Kind_DataDriven_Method = @@ -46,7 +46,7 @@ class CFluidFlamelet final : public CFluidModel { int rank; bool include_mixture_fraction = false, /*!< \brief include mixture fraction in controlling variables. */ - PreferentialDiffusion = false; /*!< \brief use preferential diffusion physics. */ + preferential_diffusion = false; /*!< \brief use preferential diffusion physics. */ unsigned short n_scalars, n_lookups, n_user_scalars, /*!< \brief number of passive reactant species. */ n_control_vars; /*!< \brief number of controlling variables. */ @@ -156,5 +156,5 @@ class CFluidFlamelet final : public CFluidModel { * \brief Preferential diffusion as relevant phenomenon in flamelet simulations. * \return Inclusion of preferential diffusion model. */ - inline bool GetPreferentialDiffusion() const override { return PreferentialDiffusion; }; + inline bool GetPreferentialDiffusion() const override { return preferential_diffusion; } }; diff --git a/SU2_CFD/src/fluid/CFluidFlamelet.cpp b/SU2_CFD/src/fluid/CFluidFlamelet.cpp index df87592dc04..0f4c38dcb93 100644 --- a/SU2_CFD/src/fluid/CFluidFlamelet.cpp +++ b/SU2_CFD/src/fluid/CFluidFlamelet.cpp @@ -26,6 +26,7 @@ */ #include +#include #include "../include/fluid/CFluidFlamelet.hpp" #include "../../../Common/include/containers/CLookUpTable.hpp" #if defined(HAVE_MLPCPP) @@ -33,10 +34,6 @@ #define USE_MLPCPP #endif -#include -#include -#include - CFluidFlamelet::CFluidFlamelet(CConfig* config, su2double value_pressure_operating) : CFluidModel() { rank = SU2_MPI::GetRank(); Kind_DataDriven_Method = config->GetKind_DataDriven_Method(); @@ -99,27 +96,20 @@ CFluidFlamelet::CFluidFlamelet(CConfig* config, su2double value_pressure_operati PreprocessLookUp(config); if (rank == MASTER_NODE) { - cout << "Preferential diffusion: " << (PreferentialDiffusion ? "Enabled" : "Disabled") << endl; + cout << "Preferential diffusion: " << (preferential_diffusion ? "Enabled" : "Disabled") << endl; } } CFluidFlamelet::~CFluidFlamelet() { - switch (Kind_DataDriven_Method) { - case ENUM_DATADRIVEN_METHOD::LUT: - delete look_up_table; - break; - case ENUM_DATADRIVEN_METHOD::MLP: + if (Kind_DataDriven_Method == ENUM_DATADRIVEN_METHOD::LUT) + delete look_up_table; #ifdef USE_MLPCPP - delete iomap_TD; - delete iomap_Sources; - delete iomap_LookUp; - delete lookup_mlp; - if (PreferentialDiffusion) delete iomap_PD; + delete iomap_TD; + delete iomap_Sources; + delete iomap_LookUp; + delete lookup_mlp; + if (preferential_diffusion) delete iomap_PD; #endif - break; - default: - break; - } } void CFluidFlamelet::SetTDState_T(su2double val_temperature, const su2double* val_scalars) { @@ -216,10 +206,10 @@ void CFluidFlamelet::PreprocessLookUp(CConfig* config) { val_vars_PD[FLAMELET_PREF_DIFF_SCALARS::I_BETA_ENTH] = beta_enth; val_vars_PD[FLAMELET_PREF_DIFF_SCALARS::I_BETA_MIXFRAC] = beta_mixfrac; - PreferentialDiffusion = config->GetPreferentialDiffusion(); + preferential_diffusion = config->GetPreferentialDiffusion(); switch (Kind_DataDriven_Method) { case ENUM_DATADRIVEN_METHOD::LUT: - PreferentialDiffusion = look_up_table->CheckForVariables(varnames_PD); + preferential_diffusion = look_up_table->CheckForVariables(varnames_PD); break; case ENUM_DATADRIVEN_METHOD::MLP: #ifdef USE_MLPCPP @@ -228,14 +218,14 @@ void CFluidFlamelet::PreprocessLookUp(CConfig* config) { auto outputMap = lookup_mlp->FindVariableIndices(iMLP, varnames_PD, false); n_betas += outputMap.size(); } - PreferentialDiffusion = (n_betas == varnames_PD.size()); + preferential_diffusion = (n_betas == varnames_PD.size()); #endif break; default: break; } - if (!PreferentialDiffusion && config->GetPreferentialDiffusion()) + if (!preferential_diffusion && config->GetPreferentialDiffusion()) SU2_MPI::Error("Preferential diffusion scalars not included in flamelet manifold.", CURRENT_FUNCTION); if (Kind_DataDriven_Method == ENUM_DATADRIVEN_METHOD::MLP) { @@ -246,7 +236,7 @@ void CFluidFlamelet::PreprocessLookUp(CConfig* config) { lookup_mlp->PairVariableswithMLPs(*iomap_TD); lookup_mlp->PairVariableswithMLPs(*iomap_Sources); lookup_mlp->PairVariableswithMLPs(*iomap_LookUp); - if (PreferentialDiffusion) { + if (preferential_diffusion) { iomap_PD = new MLPToolbox::CIOMap(controlling_variable_names, varnames_PD); lookup_mlp->PairVariableswithMLPs(*iomap_PD); } @@ -272,7 +262,7 @@ void CFluidFlamelet::PreprocessLookUp(CConfig* config) { LUT_idx = look_up_table->GetIndexOfVar(varnames_LookUp[iVar]); LUT_idx_LookUp.push_back(LUT_idx); } - if (PreferentialDiffusion) { + if (preferential_diffusion) { for (auto iVar=0u; iVar < varnames_PD.size(); iVar++) { LUT_idx_PD.push_back(look_up_table->GetIndexOfVar(varnames_PD[iVar])); } diff --git a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp index d31a071a4e1..661c9543024 100644 --- a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp @@ -468,7 +468,7 @@ void CSpeciesFlameletSolver::BC_Isothermal_Wall_Generic(CGeometry* geometry, CSo su2double dist_ij = sqrt(dist_ij_2); /*--- Compute the normal gradient in temperature using Twall. ---*/ - + ///TODO: Account for preferential diffusion in computation of the heat flux su2double dTdn = -(flowNodes->GetTemperature(Point_Normal) - temp_wall) / dist_ij; /*--- Get thermal conductivity. ---*/ From a44c51cd10f365825a0274a5da6eecf784d092b0 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Fri, 26 Apr 2024 10:52:02 +0200 Subject: [PATCH 33/34] Fixed bug in CFluidFlamelet destructor --- SU2_CFD/src/fluid/CFluidFlamelet.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/SU2_CFD/src/fluid/CFluidFlamelet.cpp b/SU2_CFD/src/fluid/CFluidFlamelet.cpp index 0f4c38dcb93..18dbcd2a43a 100644 --- a/SU2_CFD/src/fluid/CFluidFlamelet.cpp +++ b/SU2_CFD/src/fluid/CFluidFlamelet.cpp @@ -104,11 +104,13 @@ CFluidFlamelet::~CFluidFlamelet() { if (Kind_DataDriven_Method == ENUM_DATADRIVEN_METHOD::LUT) delete look_up_table; #ifdef USE_MLPCPP - delete iomap_TD; - delete iomap_Sources; - delete iomap_LookUp; - delete lookup_mlp; - if (preferential_diffusion) delete iomap_PD; + if (Kind_DataDriven_Method == ENUM_DATADRIVEN_METHOD::MLP) { + delete iomap_TD; + delete iomap_Sources; + delete iomap_LookUp; + delete lookup_mlp; + if (preferential_diffusion) delete iomap_PD; + } #endif } From 06649f74fa5f7a1d16ecba2d8e3899c7a692f0cb Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Sat, 27 Apr 2024 18:54:29 +0200 Subject: [PATCH 34/34] Set branches for test cases and tutorials back to develop --- .github/workflows/regression.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index 159ec2a522b..c001fedf53f 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -173,7 +173,7 @@ jobs: uses: docker://ghcr.io/su2code/su2/test-su2:230813-0103 with: # -t -c - args: -b ${{github.ref}} -t feature_new_flamelet -c feature_new_flamelet -s ${{matrix.testscript}} + args: -b ${{github.ref}} -t develop -c develop -s ${{matrix.testscript}} - name: Cleanup uses: docker://ghcr.io/su2code/su2/test-su2:230813-0103 with: