From 332591803a45a0c756b61bc368ffa9473614b999 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Mon, 24 Jul 2023 15:09:21 +0200 Subject: [PATCH 01/60] 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/60] 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/60] 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/60] 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/60] 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/60] 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/60] 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/60] 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/60] 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/60] 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/60] 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/60] 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/60] 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/60] 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/60] 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/60] 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/60] 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/60] 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/60] 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/60] 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/60] 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/60] 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/60] 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 9c4e37aacfd5f5c788fee495b46ca9f7cbcfe3f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Thu, 21 Mar 2024 11:00:54 +0100 Subject: [PATCH 24/60] Update container image tags. --- .github/workflows/regression.yml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index c001fedf53f..1b28776de3b 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -52,12 +52,12 @@ jobs: key: ${{ matrix.config_set }}-${{ github.sha }} restore-keys: ${{ matrix.config_set }} - name: Pre Cleanup - uses: docker://ghcr.io/su2code/su2/build-su2:230813-0103 + uses: docker://ghcr.io/su2code/su2/build-su2:240320-1536 with: entrypoint: /bin/rm args: -rf install install_bin.tgz src ccache ${{ matrix.config_set }} - name: Build - uses: docker://ghcr.io/su2code/su2/build-su2:230813-0103 + uses: docker://ghcr.io/su2code/su2/build-su2:240320-1536 with: args: -b ${{github.ref}} -f "${{matrix.flags}}" - name: Compress binaries @@ -68,7 +68,7 @@ jobs: name: ${{ matrix.config_set }} path: install_bin.tgz - name: Post Cleanup - uses: docker://ghcr.io/su2code/su2/build-su2:230813-0103 + uses: docker://ghcr.io/su2code/su2/build-su2:240320-1536 with: entrypoint: /bin/rm args: -rf install install_bin.tgz src ccache ${{ matrix.config_set }} @@ -97,12 +97,12 @@ jobs: key: ${{ matrix.config_set }}-${{ github.sha }} restore-keys: ${{ matrix.config_set }} - name: Pre Cleanup - uses: docker://ghcr.io/su2code/su2/build-su2-tsan:230813-0103 + uses: docker://ghcr.io/su2code/su2/build-su2-tsan:240320-1536 with: entrypoint: /bin/rm args: -rf install install_bin.tgz src ccache ${{ matrix.config_set }} - name: Build - uses: docker://ghcr.io/su2code/su2/build-su2-tsan:230813-0103 + uses: docker://ghcr.io/su2code/su2/build-su2-tsan:240320-1536 with: args: -b ${{github.ref}} -f "${{matrix.flags}}" - name: Compress binaries @@ -113,7 +113,7 @@ jobs: name: ${{ matrix.config_set }} path: install_bin.tgz - name: Post Cleanup - uses: docker://ghcr.io/su2code/su2/build-su2-tsan:230813-0103 + uses: docker://ghcr.io/su2code/su2/build-su2-tsan:240320-1536 with: entrypoint: /bin/rm args: -rf install install_bin.tgz src ccache ${{ matrix.config_set }} @@ -144,7 +144,7 @@ jobs: tag: OMP steps: - name: Pre Cleanup - uses: docker://ghcr.io/su2code/su2/test-su2:230813-0103 + uses: docker://ghcr.io/su2code/su2/test-su2:240320-1536 with: entrypoint: /bin/rm args: -rf install install_bin.tgz src ccache ${{ matrix.config_set }} @@ -170,12 +170,12 @@ jobs: chmod a+x $BIN_FOLDER/* ls -lahR $BIN_FOLDER - name: Run Tests in Container - uses: docker://ghcr.io/su2code/su2/test-su2:230813-0103 + uses: docker://ghcr.io/su2code/su2/test-su2:240320-1536 with: # -t -c args: -b ${{github.ref}} -t develop -c develop -s ${{matrix.testscript}} - name: Cleanup - uses: docker://ghcr.io/su2code/su2/test-su2:230813-0103 + uses: docker://ghcr.io/su2code/su2/test-su2:240320-1536 with: entrypoint: /bin/rm args: -rf install install_bin.tgz src ccache ${{ matrix.config_set }} @@ -192,7 +192,7 @@ jobs: - name: Reduce ASLR entropy for tsan run: sudo sysctl -w vm.mmap_rnd_bits=28 - name: Pre Cleanup - uses: docker://ghcr.io/su2code/su2/test-su2-tsan:230813-0103 + uses: docker://ghcr.io/su2code/su2/test-su2-tsan:240320-1536 with: entrypoint: /bin/rm args: -rf install install_bin.tgz src ccache ${{ matrix.config_set }} @@ -218,12 +218,12 @@ jobs: chmod a+x $BIN_FOLDER/* ls -lahR $BIN_FOLDER - name: Run Tests in Container - uses: docker://ghcr.io/su2code/su2/test-su2-tsan:230813-0103 + uses: docker://ghcr.io/su2code/su2/test-su2-tsan:240320-1536 with: # -t -c args: -b ${{github.ref}} -t develop -c develop -s ${{matrix.testscript}} -a "--tsan" - name: Cleanup - uses: docker://ghcr.io/su2code/su2/test-su2-tsan:230813-0103 + uses: docker://ghcr.io/su2code/su2/test-su2-tsan:240320-1536 with: entrypoint: /bin/rm args: -rf install install_bin.tgz src ccache ${{ matrix.config_set }} @@ -244,7 +244,7 @@ jobs: tag: MPI steps: - name: Pre Cleanup - uses: docker://ghcr.io/su2code/su2/test-su2:230813-0103 + uses: docker://ghcr.io/su2code/su2/test-su2:240320-1536 with: entrypoint: /bin/rm args: -rf install install_bin.tgz src ccache ${{ matrix.config_set }} @@ -305,11 +305,11 @@ jobs: echo $PWD ls -lahR - name: Run Unit Tests - uses: docker://ghcr.io/su2code/su2/test-su2:230813-0103 + uses: docker://ghcr.io/su2code/su2/test-su2:240320-1536 with: entrypoint: install/bin/${{matrix.testdriver}} - name: Post Cleanup - uses: docker://ghcr.io/su2code/su2/test-su2:230813-0103 + uses: docker://ghcr.io/su2code/su2/test-su2:240320-1536 with: entrypoint: /bin/rm args: -rf install install_bin.tgz src ccache ${{ matrix.config_set }} From c2a2c572661cce158eb6b2cb2da1a6932bc5543a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Thu, 21 Mar 2024 14:15:45 +0100 Subject: [PATCH 25/60] Add job for building SU2 with the address sanitizer. --- .github/workflows/regression.yml | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index 1b28776de3b..d1126341605 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -117,6 +117,46 @@ jobs: with: entrypoint: /bin/rm args: -rf install install_bin.tgz src ccache ${{ matrix.config_set }} + build_asan: + name: Build SU2 (asan) + strategy: + fail-fast: false + matrix: + config_set: [BaseNoMPI-asan, ReverseNoMPI-asan] + include: + - config_set: BaseNoMPI-asan + flags: '--buildtype=debugoptimized -Denable-pywrapper=true -Denable-openblas=true -Dwith-mpi=disabled -Denable-mlpcpp=true -Denable-tests=true --warnlevel=3 --werror' + - config_set: ReverseNoMPI-asan + flags: '--buildtype=debugoptimized -Denable-autodiff=true -Denable-normal=false -Dwith-mpi=disabled -Denable-pywrapper=true -Denable-tests=true --warnlevel=3 --werror' + runs-on: ${{ inputs.runner || 'ubuntu-latest' }} + steps: + - name: Reduce ASLR entropy for asan + run: sudo sysctl -w vm.mmap_rnd_bits=28 + - name: Cache Object Files + uses: actions/cache@v4 + with: + path: ccache + key: ${{ matrix.config_set }}-${{ github.sha }} + restore-keys: ${{ matrix.config_set }} + - name: Pre Cleanup + uses: docker://ghcr.io/su2code/su2/build-su2-asan:240320-1536 + with: + entrypoint: /bin/rm + args: -rf install install_bin.tgz src ccache ${{ matrix.config_set }} + - name: Build + run: docker run --rm -it --cap-add=SYS_PTRACE -v $(pwd):/${{ github.workspace }} -w ${{ github.workspace }} ghcr.io/su2code/su2/build-su2-asan:240320-1536 -b ${{github.ref}} -f "${{matrix.flags}}" + - name: Compress binaries + run: tar -zcvf install_bin.tgz install/* + - name: Upload Binaries + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.config_set }} + path: install_bin.tgz + - name: Post Cleanup + uses: docker://ghcr.io/su2code/su2/build-su2-asan:240320-1536 + with: + entrypoint: /bin/rm + args: -rf install install_bin.tgz src ccache ${{ matrix.config_set }} regression_tests: runs-on: ${{ inputs.runner || 'ubuntu-latest' }} name: Regression Tests From 5ff2348da749023b7a271882c3954a7db5a2a539 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Thu, 21 Mar 2024 14:33:13 +0100 Subject: [PATCH 26/60] Fix. --- .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 d1126341605..ce0aa58bd90 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -144,7 +144,7 @@ jobs: entrypoint: /bin/rm args: -rf install install_bin.tgz src ccache ${{ matrix.config_set }} - name: Build - run: docker run --rm -it --cap-add=SYS_PTRACE -v $(pwd):/${{ github.workspace }} -w ${{ github.workspace }} ghcr.io/su2code/su2/build-su2-asan:240320-1536 -b ${{github.ref}} -f "${{matrix.flags}}" + run: docker run --rm --cap-add=SYS_PTRACE -v $(pwd):/${{ github.workspace }} -w ${{ github.workspace }} ghcr.io/su2code/su2/build-su2-asan:240320-1536 -b ${{github.ref}} -f "${{matrix.flags}}" - name: Compress binaries run: tar -zcvf install_bin.tgz install/* - name: Upload Binaries From bc6362f4b3063412c410872f8de995ae698cbeb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Thu, 21 Mar 2024 14:56:22 +0100 Subject: [PATCH 27/60] Remove slash. --- .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 ce0aa58bd90..fdf619a57cb 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -144,7 +144,7 @@ jobs: entrypoint: /bin/rm args: -rf install install_bin.tgz src ccache ${{ matrix.config_set }} - name: Build - run: docker run --rm --cap-add=SYS_PTRACE -v $(pwd):/${{ github.workspace }} -w ${{ github.workspace }} ghcr.io/su2code/su2/build-su2-asan:240320-1536 -b ${{github.ref}} -f "${{matrix.flags}}" + run: docker run --rm --cap-add=SYS_PTRACE -v $(pwd):${{ github.workspace }} -w ${{ github.workspace }} ghcr.io/su2code/su2/build-su2-asan:240320-1536 -b ${{github.ref}} -f "${{matrix.flags}}" - name: Compress binaries run: tar -zcvf install_bin.tgz install/* - name: Upload Binaries From 3c32cd4f7d007dc14c9b47108c3796d653577aad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Fri, 22 Mar 2024 13:08:08 +0100 Subject: [PATCH 28/60] Address sanitizer builds without python wrapper and unit tests. --- .github/workflows/regression.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index fdf619a57cb..29d47f6bccd 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -125,9 +125,9 @@ jobs: config_set: [BaseNoMPI-asan, ReverseNoMPI-asan] include: - config_set: BaseNoMPI-asan - flags: '--buildtype=debugoptimized -Denable-pywrapper=true -Denable-openblas=true -Dwith-mpi=disabled -Denable-mlpcpp=true -Denable-tests=true --warnlevel=3 --werror' + flags: '--buildtype=debugoptimized -Denable-pywrapper=true -Denable-openblas=true -Dwith-mpi=disabled -Denable-mlpcpp=true --warnlevel=3 --werror' - config_set: ReverseNoMPI-asan - flags: '--buildtype=debugoptimized -Denable-autodiff=true -Denable-normal=false -Dwith-mpi=disabled -Denable-pywrapper=true -Denable-tests=true --warnlevel=3 --werror' + flags: '--buildtype=debugoptimized -Denable-autodiff=true -Denable-normal=false -Dwith-mpi=disabled --warnlevel=3 --werror' runs-on: ${{ inputs.runner || 'ubuntu-latest' }} steps: - name: Reduce ASLR entropy for asan @@ -144,7 +144,7 @@ jobs: entrypoint: /bin/rm args: -rf install install_bin.tgz src ccache ${{ matrix.config_set }} - name: Build - run: docker run --rm --cap-add=SYS_PTRACE -v $(pwd):${{ github.workspace }} -w ${{ github.workspace }} ghcr.io/su2code/su2/build-su2-asan:240320-1536 -b ${{github.ref}} -f "${{matrix.flags}}" + run: docker run --rm --cap-add SYS_PTRACE -v $(pwd):${{ github.workspace }} -w ${{ github.workspace }} ghcr.io/su2code/su2/build-su2-asan:240320-1536 -b ${{github.ref}} -f "${{matrix.flags}}" - name: Compress binaries run: tar -zcvf install_bin.tgz install/* - name: Upload Binaries From acd1a760f3f12ea16a870585b46665370574db63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Mon, 25 Mar 2024 15:35:33 +0100 Subject: [PATCH 29/60] Add --asan flag, add with_asan parameter. --- .github/workflows/regression.yml | 2 +- TestCases/TestCase.py | 31 +++++++++++++++++-------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index 29d47f6bccd..274918a2e2f 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -125,7 +125,7 @@ jobs: config_set: [BaseNoMPI-asan, ReverseNoMPI-asan] include: - config_set: BaseNoMPI-asan - flags: '--buildtype=debugoptimized -Denable-pywrapper=true -Denable-openblas=true -Dwith-mpi=disabled -Denable-mlpcpp=true --warnlevel=3 --werror' + flags: '--buildtype=debugoptimized -Denable-openblas=true -Dwith-mpi=disabled -Denable-mlpcpp=true --warnlevel=3 --werror' - config_set: ReverseNoMPI-asan flags: '--buildtype=debugoptimized -Denable-autodiff=true -Denable-normal=false -Dwith-mpi=disabled --warnlevel=3 --werror' runs-on: ${{ inputs.runner || 'ubuntu-latest' }} diff --git a/TestCases/TestCase.py b/TestCases/TestCase.py index 6d577b47df4..ce63fddd5c6 100644 --- a/TestCases/TestCase.py +++ b/TestCases/TestCase.py @@ -45,6 +45,7 @@ def is_float(test_string): def parse_args(description: str): parser = argparse.ArgumentParser(description=description) parser.add_argument('--tsan', action='store_true', help='Run thread sanitizer tests. Requires a tsan-enabled SU2 build.') + parser.add_argument('--asan', action='store_true', help='Run address sanitizer tests. Requires an asan-enabled SU2 build.') return parser.parse_args() class TestCase: @@ -114,6 +115,7 @@ def __init__(self,tag_in): self.cpu_arch = platform.machine().casefold() self.enabled_on_cpu_arch = ["x86_64","amd64","aarch64","arm64"] self.enabled_with_tsan = True + self.enabled_with_asan = True self.command = self.Command() self.timeout = 0 self.tol = 0.0 @@ -125,9 +127,9 @@ def __init__(self,tag_in): self.reference_file_aarch64 = "" self.test_file = "of_grad.dat" - def run_test(self, running_with_tsan=False): + def run_test(self, with_tsan=False, with_asan=False): - if not self.is_enabled(running_with_tsan): + if not self.is_enabled(with_tsan, with_asan): return True print('==================== Start Test: %s ===================='%self.tag) @@ -142,7 +144,7 @@ def run_test(self, running_with_tsan=False): # Adjust the number of iterations in the config file if len(self.test_vals) != 0: - self.adjust_iter(running_with_tsan) + self.adjust_iter(with_tsan, with_asan) # Check for disabling the restart if self.no_restart: @@ -186,7 +188,7 @@ def run_test(self, running_with_tsan=False): delta_vals = [] sim_vals = [] - if not running_with_tsan: # tsan findings result in non-zero return code, no need to examine the output + if not with_tsan and not with_asan: # sanitizer findings result in non-zero return code, no need to examine the output # Examine the output f = open(logfilename,'r') output = f.readlines() @@ -260,7 +262,7 @@ def run_test(self, running_with_tsan=False): if not start_solver: print('ERROR: The code was not able to get to the "Begin solver" section.') - if not running_with_tsan and iter_missing: + if not with_tsan and not with_asan and iter_missing: print('ERROR: The iteration number %d could not be found.'%self.test_iter) print('CPU architecture=%s' % self.cpu_arch) @@ -281,9 +283,9 @@ def run_test(self, running_with_tsan=False): os.chdir(workdir) return passed - def run_filediff(self, running_with_tsan=False): + def run_filediff(self, with_tsan=False, with_asan=False): - if not self.is_enabled(running_with_tsan): + if not self.is_enabled(with_tsan, with_asan): return True print('==================== Start Test: %s ===================='%self.tag) @@ -291,7 +293,7 @@ def run_filediff(self, running_with_tsan=False): timed_out = False # Adjust the number of iterations in the config file - self.adjust_iter(running_with_tsan) + self.adjust_iter(with_tsan, with_asan) self.adjust_test_data() @@ -330,7 +332,7 @@ def run_filediff(self, running_with_tsan=False): print("Output from the failed case:") subprocess.call(["cat", logfilename]) - if not running_with_tsan: # thread sanitizer tests only check the return code, no need to compare outputs + if not with_tsan and not with_asan: # sanitizer tests only check the return code, no need to compare outputs diff_time_start = datetime.datetime.now() if not timed_out and passed: # Compare files @@ -850,7 +852,7 @@ def run_def(self): os.chdir(workdir) return passed - def adjust_iter(self, running_with_tsan=False): + def adjust_iter(self, with_tsan=False, with_asan=False): # Read the cfg file workdir = os.getcwd() @@ -861,7 +863,7 @@ def adjust_iter(self, running_with_tsan=False): new_iter = self.test_iter + 1 - if running_with_tsan: + if with_tsan or with_asan: # detect restart restart_iter = 0 @@ -942,18 +944,19 @@ def disable_restart(self): return - def is_enabled(self, running_with_tsan=False): + def is_enabled(self, with_tsan=False, with_asan=False): is_enabled_on_arch = self.cpu_arch in self.enabled_on_cpu_arch if not is_enabled_on_arch: print('Ignoring test "%s" because it is not enabled for the current CPU architecture: %s' % (self.tag, self.cpu_arch)) - tsan_compatible = not running_with_tsan or self.enabled_with_tsan + tsan_compatible = not with_tsan or self.enabled_with_tsan + asan_compatible = not with_asan or self.enabled_with_asan if not tsan_compatible: print('Ignoring test "%s" because it is not enabled to run with the thread sanitizer.' % self.tag) - return is_enabled_on_arch and tsan_compatible + return is_enabled_on_arch and tsan_compatible and asan_compatible def adjust_test_data(self): From c16aab20c0e8744d8a4d41ce6df4b4075b6e0ed8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Mon, 25 Mar 2024 16:05:28 +0100 Subject: [PATCH 30/60] Add basic tsan/asan checks to further run_* routines. --- TestCases/TestCase.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/TestCases/TestCase.py b/TestCases/TestCase.py index ce63fddd5c6..ec6499245b3 100644 --- a/TestCases/TestCase.py +++ b/TestCases/TestCase.py @@ -470,9 +470,9 @@ def run_filediff(self, with_tsan=False, with_asan=False): os.chdir(workdir) return passed - def run_opt(self): + def run_opt(self, with_tsan=False, with_asan=False): - if not self.is_enabled(): + if not self.is_enabled(with_tsan, with_asan): return True print('==================== Start Test: %s ===================='%self.tag) @@ -595,9 +595,9 @@ def run_opt(self): os.chdir(workdir) return passed - def run_geo(self): + def run_geo(self, with_tsan=False, with_asan=False): - if not self.is_enabled(): + if not self.is_enabled(with_tsan, with_asan): return True print('==================== Start Test: %s ===================='%self.tag) @@ -727,9 +727,9 @@ def run_geo(self): os.chdir(workdir) return passed - def run_def(self): + def run_def(self, with_tsan=False, with_asan=False): - if not self.is_enabled(): + if not self.is_enabled(with_tsan, with_asan): return True print('==================== Start Test: %s ===================='%self.tag) From c84780e94d63d7180638b7abe356b6a7c21a1e63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Mon, 25 Mar 2024 16:13:04 +0100 Subject: [PATCH 31/60] Enable address sanitizer execution of SU2_CFD serial regression tests. --- TestCases/serial_regression.py | 86 +++++++++++++++++++++++----------- 1 file changed, 58 insertions(+), 28 deletions(-) diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index cecb6408e22..9964395d837 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -28,12 +28,15 @@ from __future__ import print_function, division, absolute_import import sys from TestCase import TestCase +from TestCase import parse_args def main(): '''This program runs SU2 and ensures that the output matches specified values. This will be used to do checks when code is pushed to github to make sure nothing is broken. ''' + args = parse_args('Serial Regression Tests') + test_list = [] ######################### @@ -1188,7 +1191,7 @@ def main(): if test.tol == 0.0: test.tol = 0.00001 - pass_list = [ test.run_test() for test in test_list ] + pass_list = [ test.run_test(args.tsan, args.asan) for test in test_list ] ###################################### @@ -1203,7 +1206,8 @@ def main(): naca0012_geo.command = TestCase.Command(exec = "SU2_GEO") naca0012_geo.timeout = 1600 naca0012_geo.tol = 0.00001 - pass_list.append(naca0012_geo.run_geo()) + naca0012_geo.enabled_with_asan = False + pass_list.append(naca0012_geo.run_geo(args.tsan, args.asan)) test_list.append(naca0012_geo) ###################################### @@ -1219,8 +1223,9 @@ def main(): intersect_def.command = TestCase.Command(exec = "SU2_DEF") intersect_def.timeout = 1600 intersect_def.tol = 1e-04 + intersect_def.enabled_with_asan = False - pass_list.append(intersect_def.run_def()) + pass_list.append(intersect_def.run_def(args.tsan, args.asan)) test_list.append(intersect_def) # Inviscid NACA0012 (triangles) @@ -1232,8 +1237,9 @@ def main(): naca0012_def.command = TestCase.Command(exec = "SU2_DEF") naca0012_def.timeout = 1600 naca0012_def.tol = 1e-08 + naca0012_def.enabled_with_asan = False - pass_list.append(naca0012_def.run_def()) + pass_list.append(naca0012_def.run_def(args.tsan, args.asan)) test_list.append(naca0012_def) # Inviscid NACA0012 based on SURFACE_FILE input (surface_bump.dat) @@ -1245,8 +1251,9 @@ def main(): naca0012_def_file.command = TestCase.Command(exec = "SU2_DEF") naca0012_def_file.timeout = 1600 naca0012_def_file.tol = 1e-8 + naca0012_def_file.enabled_with_asan = False - pass_list.append(naca0012_def_file.run_def()) + pass_list.append(naca0012_def_file.run_def(args.tsan, args.asan)) test_list.append(naca0012_def_file) # RAE2822 (mixed tris + quads) @@ -1258,8 +1265,9 @@ def main(): rae2822_def.command = TestCase.Command(exec = "SU2_DEF") rae2822_def.timeout = 1600 rae2822_def.tol = 1e-13 + rae2822_def.enabled_with_asan = False - pass_list.append(rae2822_def.run_def()) + pass_list.append(rae2822_def.run_def(args.tsan, args.asan)) test_list.append(rae2822_def) # Turb NACA4412 (quads, wall distance) @@ -1271,8 +1279,9 @@ def main(): naca4412_def.command = TestCase.Command(exec = "SU2_DEF") naca4412_def.timeout = 1600 naca4412_def.tol = 1e-12 + naca4412_def.enabled_with_asan = False - pass_list.append(naca4412_def.run_def()) + pass_list.append(naca4412_def.run_def(args.tsan, args.asan)) test_list.append(naca4412_def) # Brick of tets (inverse volume) @@ -1284,8 +1293,9 @@ def main(): brick_tets_def.command = TestCase.Command(exec = "SU2_DEF") brick_tets_def.timeout = 1600 brick_tets_def.tol = 1e-09 + brick_tets_def.enabled_with_asan = False - pass_list.append(brick_tets_def.run_def()) + pass_list.append(brick_tets_def.run_def(args.tsan, args.asan)) test_list.append(brick_tets_def) # Brick of isotropic hexas (inverse volume) @@ -1297,8 +1307,9 @@ def main(): brick_hex_def.command = TestCase.Command(exec = "SU2_DEF") brick_hex_def.timeout = 1600 brick_hex_def.tol = 1e-09 + brick_hex_def.enabled_with_asan = False - pass_list.append(brick_hex_def.run_def()) + pass_list.append(brick_hex_def.run_def(args.tsan, args.asan)) test_list.append(brick_hex_def) # Brick with a pyramid layer (inverse volume) @@ -1310,8 +1321,9 @@ def main(): brick_pyra_def.command = TestCase.Command(exec = "SU2_DEF") brick_pyra_def.timeout = 1600 brick_pyra_def.tol = 1e-08 + brick_pyra_def.enabled_with_asan = False - pass_list.append(brick_pyra_def.run_def()) + pass_list.append(brick_pyra_def.run_def(args.tsan, args.asan)) test_list.append(brick_pyra_def) # Brick of isotropic prisms (inverse volume) @@ -1323,8 +1335,9 @@ def main(): brick_prism_def.command = TestCase.Command(exec = "SU2_DEF") brick_prism_def.timeout = 1600 brick_prism_def.tol = 1e-08 + brick_prism_def.enabled_with_asan = False - pass_list.append(brick_prism_def.run_def()) + pass_list.append(brick_prism_def.run_def(args.tsan, args.asan)) test_list.append(brick_prism_def) # Brick of prisms with high aspect ratio cells near the wall (wall distance) @@ -1336,8 +1349,9 @@ def main(): brick_prism_rans_def.command = TestCase.Command(exec = "SU2_DEF") brick_prism_rans_def.timeout = 1600 brick_prism_rans_def.tol = 1e-12 + brick_prism_rans_def.enabled_with_asan = False - pass_list.append(brick_prism_rans_def.run_def()) + pass_list.append(brick_prism_rans_def.run_def(args.tsan, args.asan)) test_list.append(brick_prism_rans_def) # Brick of hexas with high aspect ratio cells near the wall (inverse volume) @@ -1349,8 +1363,9 @@ def main(): brick_hex_rans_def.command = TestCase.Command(exec = "SU2_DEF") brick_hex_rans_def.timeout = 1600 brick_hex_rans_def.tol = 1e-12 + brick_hex_rans_def.enabled_with_asan = False - pass_list.append(brick_hex_rans_def.run_def()) + pass_list.append(brick_hex_rans_def.run_def(args.tsan, args.asan)) test_list.append(brick_hex_rans_def) # Cylindrical FFD test @@ -1362,8 +1377,9 @@ def main(): cylinder_ffd_def.command = TestCase.Command(exec = "SU2_DEF") cylinder_ffd_def.timeout = 1600 cylinder_ffd_def.tol = 1e-09 + cylinder_ffd_def.enabled_with_asan = False - pass_list.append(cylinder_ffd_def.run_def()) + pass_list.append(cylinder_ffd_def.run_def(args.tsan, args.asan)) test_list.append(cylinder_ffd_def) # Spherical FFD test @@ -1375,8 +1391,9 @@ def main(): sphere_ffd_def.command = TestCase.Command(exec = "SU2_DEF") sphere_ffd_def.timeout = 1600 sphere_ffd_def.tol = 1e-08 + sphere_ffd_def.enabled_with_asan = False - pass_list.append(sphere_ffd_def.run_def()) + pass_list.append(sphere_ffd_def.run_def(args.tsan, args.asan)) test_list.append(sphere_ffd_def) # Spherical FFD test using BSplines @@ -1388,8 +1405,9 @@ def main(): sphere_ffd_def_bspline.command = TestCase.Command(exec = "SU2_DEF") sphere_ffd_def_bspline.timeout = 1600 sphere_ffd_def_bspline.tol = 1e-08 + sphere_ffd_def_bspline.enabled_with_asan = False - pass_list.append(sphere_ffd_def_bspline.run_def()) + pass_list.append(sphere_ffd_def_bspline.run_def(args.tsan, args.asan)) test_list.append(sphere_ffd_def_bspline) ###################################### @@ -1405,7 +1423,8 @@ def main(): contadj_euler_py.timeout = 1600 contadj_euler_py.reference_file = "of_grad_cd.dat.ref" contadj_euler_py.test_file = "of_grad_cd.dat" - pass_list.append(contadj_euler_py.run_filediff()) + contadj_euler_py.enabled_with_asan = False + pass_list.append(contadj_euler_py.run_filediff(args.tsan, args.asan)) test_list.append(contadj_euler_py) # test shape_optimization.py @@ -1417,7 +1436,8 @@ def main(): shape_opt_euler_py.command = TestCase.Command(exec = "shape_optimization.py", param = "-g CONTINUOUS_ADJOINT -f") shape_opt_euler_py.timeout = 1600 shape_opt_euler_py.tol = 0.00001 - pass_list.append(shape_opt_euler_py.run_opt()) + shape_opt_euler_py.enabled_with_asan = False + pass_list.append(shape_opt_euler_py.run_opt(args.tsan, args.asan)) test_list.append(shape_opt_euler_py) # Multiple functionals with the continuous adjoint @@ -1429,7 +1449,8 @@ def main(): contadj_multi_py.timeout = 1600 contadj_multi_py.reference_file = "of_grad_combo.dat.ref" contadj_multi_py.test_file = "of_grad_combo.dat" - pass_list.append(contadj_multi_py.run_filediff()) + contadj_multi_py.enabled_with_asan = False + pass_list.append(contadj_multi_py.run_filediff(args.tsan, args.asan)) test_list.append(contadj_multi_py) # Optimization with multiple objectives, with gradients evaluated individually @@ -1467,7 +1488,8 @@ def main(): opt_multiobj1surf_py.command = TestCase.Command(exec = "shape_optimization.py", param = "-g CONTINUOUS_ADJOINT -f") opt_multiobj1surf_py.timeout = 1600 opt_multiobj1surf_py.tol = 0.00001 - pass_list.append(opt_multiobj1surf_py.run_opt()) + opt_multiobj1surf_py.enabled_with_asan = False + pass_list.append(opt_multiobj1surf_py.run_opt(args.tsan, args.asan)) test_list.append(opt_multiobj1surf_py) # test optimization, with a single objective evaluated on multiple surfaces @@ -1479,7 +1501,8 @@ def main(): opt_2surf1obj_py.command = TestCase.Command(exec = "shape_optimization.py", param = "-g CONTINUOUS_ADJOINT -f") opt_2surf1obj_py.timeout = 1600 opt_2surf1obj_py.tol = 0.00001 - pass_list.append(opt_2surf1obj_py.run_opt()) + opt_2surf1obj_py.enabled_with_asan = False + pass_list.append(opt_2surf1obj_py.run_opt(args.tsan, args.asan)) test_list.append(opt_2surf1obj_py) ########################## @@ -1495,8 +1518,9 @@ def main(): pywrapper_naca0012.command = TestCase.Command(exec = "SU2_CFD.py", param = "-f") pywrapper_naca0012.timeout = 1600 pywrapper_naca0012.tol = 0.00001 + pywrapper_naca0012.enabled_with_asan = False test_list.append(pywrapper_naca0012) - pass_list.append(pywrapper_naca0012.run_test()) + pass_list.append(pywrapper_naca0012.run_test(args.tsan, args.asan)) # NACA0012 (SST, FUN3D results for finest grid: CL=1.0840, CD=0.01253) pywrapper_turb_naca0012_sst = TestCase('pywrapper_turb_naca0012_sst') @@ -1508,8 +1532,9 @@ def main(): pywrapper_turb_naca0012_sst.command = TestCase.Command(exec = "SU2_CFD.py", param = "-f") pywrapper_turb_naca0012_sst.timeout = 3200 pywrapper_turb_naca0012_sst.tol = 0.00001 + pywrapper_turb_naca0012_sst.enabled_with_asan = False test_list.append(pywrapper_turb_naca0012_sst) - pass_list.append(pywrapper_turb_naca0012_sst.run_test()) + pass_list.append(pywrapper_turb_naca0012_sst.run_test(args.tsan, args.asan)) # Square cylinder pywrapper_square_cylinder = TestCase('pywrapper_square_cylinder') @@ -1521,8 +1546,9 @@ def main(): pywrapper_square_cylinder.timeout = 1600 pywrapper_square_cylinder.tol = 0.00001 pywrapper_square_cylinder.unsteady = True + pywrapper_square_cylinder.enabled_with_asan = False test_list.append(pywrapper_square_cylinder) - pass_list.append(pywrapper_square_cylinder.run_test()) + pass_list.append(pywrapper_square_cylinder.run_test(args.tsan, args.asan)) # Aeroelastic pywrapper_aeroelastic = TestCase('pywrapper_aeroelastic') @@ -1534,8 +1560,9 @@ def main(): pywrapper_aeroelastic.timeout = 1600 pywrapper_aeroelastic.tol = 0.00001 pywrapper_aeroelastic.unsteady = True + pywrapper_aeroelastic.enabled_with_asan = False test_list.append(pywrapper_aeroelastic) - pass_list.append(pywrapper_aeroelastic.run_test()) + pass_list.append(pywrapper_aeroelastic.run_test(args.tsan, args.asan)) # FSI, 2d pywrapper_fsi2d = TestCase('pywrapper_fsi2d') @@ -1548,8 +1575,9 @@ def main(): pywrapper_fsi2d.multizone = True pywrapper_fsi2d.timeout = 1600 pywrapper_fsi2d.tol = 0.00001 + pywrapper_fsi2d.enabled_with_asan = False test_list.append(pywrapper_fsi2d) - pass_list.append(pywrapper_fsi2d.run_test()) + pass_list.append(pywrapper_fsi2d.run_test(args.tsan, args.asan)) # Unsteady CHT pywrapper_unsteadyCHT = TestCase('pywrapper_unsteadyCHT') @@ -1561,8 +1589,9 @@ def main(): pywrapper_unsteadyCHT.timeout = 1600 pywrapper_unsteadyCHT.tol = 0.00001 pywrapper_unsteadyCHT.unsteady = True + pywrapper_unsteadyCHT.enabled_with_asan = False test_list.append(pywrapper_unsteadyCHT) - pass_list.append(pywrapper_unsteadyCHT.run_test()) + pass_list.append(pywrapper_unsteadyCHT.run_test(args.tsan, args.asan)) # Rigid motion pywrapper_rigidMotion = TestCase('pywrapper_rigidMotion') @@ -1574,8 +1603,9 @@ def main(): pywrapper_rigidMotion.timeout = 1600 pywrapper_rigidMotion.tol = 0.00001 pywrapper_rigidMotion.unsteady = True + pywrapper_rigidMotion.enabled_with_asan = False test_list.append(pywrapper_rigidMotion) - pass_list.append(pywrapper_rigidMotion.run_test()) + pass_list.append(pywrapper_rigidMotion.run_test(args.tsan, args.asan)) # Tests summary print('==================================================================') From 8a79faa2ebfba86bae4e2bd432fbb3877496c7da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Mon, 25 Mar 2024 16:44:37 +0100 Subject: [PATCH 32/60] Add job for address sanitizer tests. --- .github/workflows/regression.yml | 47 ++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index 274918a2e2f..b80cd8f4384 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -267,6 +267,53 @@ jobs: with: entrypoint: /bin/rm args: -rf install install_bin.tgz src ccache ${{ matrix.config_set }} + address_sanitizer_tests: + runs-on: ${{ inputs.runner || 'ubuntu-latest' }} + name: Address Sanitizer Tests + needs: build_asan + strategy: + fail-fast: false + matrix: + testscript: ['serial_regression.py'] + steps: + - name: Reduce ASLR entropy for asan + run: sudo sysctl -w vm.mmap_rnd_bits=28 + - name: Pre Cleanup + uses: docker://ghcr.io/su2code/su2/test-su2-asan:240320-1536 + with: + entrypoint: /bin/rm + args: -rf install install_bin.tgz src ccache ${{ matrix.config_set }} + - name: Download All artifacts + uses: actions/download-artifact@v4 + - name: Uncompress and Move Binaries + run: | + BIN_FOLDER="$PWD/install/bin" + mkdir -p $BIN_FOLDER + ls -lah $BIN_FOLDER + for type in Base Reverse Forward; do + TYPE_FOLDER="${type}NoMPI-asan" + echo "Processing '$TYPE_FOLDER' ..." + if [ -d $TYPE_FOLDER ]; then + pushd $TYPE_FOLDER + ls -lah + tar -zxvf install_bin.tgz + ls -lah install/bin/ + cp -r install/* $BIN_FOLDER/../ + popd; + fi + done + chmod a+x $BIN_FOLDER/* + ls -lahR $BIN_FOLDER + - name: Run Tests in Container + uses: docker://ghcr.io/su2code/su2/test-su2-asan:240320-1536 + with: + # -t -c + args: -b ${{github.ref}} -t develop -c develop -s ${{matrix.testscript}} -a "--asan" + - name: Cleanup + uses: docker://ghcr.io/su2code/su2/test-su2-asan:240320-1536 + with: + entrypoint: /bin/rm + args: -rf install install_bin.tgz src ccache ${{ matrix.config_set }} unit_tests: runs-on: ${{ inputs.runner || 'ubuntu-latest' }} name: Unit Tests From 3e426993752690a0f8b22e98e1781e8748418fb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Tue, 26 Mar 2024 17:19:12 +0100 Subject: [PATCH 33/60] Avoid reallocation of surface_movement. --- SU2_CFD/src/drivers/CDriver.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 7160cc93e6f..6c1a6170a04 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -2389,7 +2389,9 @@ void CDriver::PreprocessDynamicMesh(CConfig *config, CGeometry **geometry, CSolv cout << "Setting dynamic mesh structure for zone "<< iZone + 1<<"." << endl; grid_movement = new CVolumetricMovement(geometry[MESH_0], config); - surface_movement = new CSurfaceMovement(); + if (surface_movement != nullptr) + surface_movement = new CSurfaceMovement(); + surface_movement->CopyBoundary(geometry[MESH_0], config); if (config->GetTime_Marching() == TIME_MARCHING::HARMONIC_BALANCE){ if (rank == MASTER_NODE) cout << endl << "Instance "<< iInst + 1 <<":" << endl; From a65d31cd0532529f3addf977011923c23cf38d56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Wed, 27 Mar 2024 16:00:43 +0100 Subject: [PATCH 34/60] Enable address sanitizer execution of SU2_CFD_AD serial regression AD tests. --- .github/workflows/regression.yml | 2 +- TestCases/serial_regression_AD.py | 29 ++++++++++++++++++++--------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index b80cd8f4384..af6f6c60875 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -274,7 +274,7 @@ jobs: strategy: fail-fast: false matrix: - testscript: ['serial_regression.py'] + testscript: ['serial_regression.py', 'serial_regression_AD.py'] steps: - name: Reduce ASLR entropy for asan run: sudo sysctl -w vm.mmap_rnd_bits=28 diff --git a/TestCases/serial_regression_AD.py b/TestCases/serial_regression_AD.py index 2a0ac757097..ac268040cd5 100644 --- a/TestCases/serial_regression_AD.py +++ b/TestCases/serial_regression_AD.py @@ -30,12 +30,15 @@ import sys from TestCase import TestCase +from TestCase import parse_args def main(): '''This program runs SU2 and ensures that the output matches specified values. This will be used to do checks when code is pushed to github to make sure nothing is broken. ''' + args = parse_args('Serial Regression AD Tests') + test_list = [] ##################################### @@ -223,7 +226,7 @@ def main(): if test.tol == 0.0: test.tol = 0.00001 - pass_list = [ test.run_test() for test in test_list ] + pass_list = [ test.run_test(args.tsan, args.asan) for test in test_list ] ################################### ### Coupled RHT-CFD Adjoint ### @@ -239,7 +242,8 @@ def main(): discadj_rht.reference_file = "of_grad_cd.csv.ref" discadj_rht.reference_file_aarch64 = "of_grad_cd_aarch64.csv.ref" discadj_rht.test_file = "of_grad_cd.csv" - pass_list.append(discadj_rht.run_filediff()) + discadj_rht.enabled_with_asan = False + pass_list.append(discadj_rht.run_filediff(args.tsan, args.asan)) test_list.append(discadj_rht) ###################################### @@ -256,7 +260,8 @@ def main(): discadj_euler_py.reference_file = "of_grad_cd_disc.dat.ref" discadj_euler_py.reference_file_aarch64 = "of_grad_cd_disc_aarch64.dat.ref" discadj_euler_py.test_file = "of_grad_cd.dat" - pass_list.append(discadj_euler_py.run_filediff()) + discadj_euler_py.enabled_with_asan = False + pass_list.append(discadj_euler_py.run_filediff(args.tsan, args.asan)) test_list.append(discadj_euler_py) # test discrete_adjoint with multiple ffd boxes @@ -269,7 +274,8 @@ def main(): discadj_multiple_ffd_py.reference_file = "of_grad_cd.dat.ref" discadj_multiple_ffd_py.reference_file_aarch64 = "of_grad_cd_aarch64.dat.ref" discadj_multiple_ffd_py.test_file = "of_grad_cd.dat" - pass_list.append(discadj_multiple_ffd_py.run_filediff()) + discadj_multiple_ffd_py.enabled_with_asan = False + pass_list.append(discadj_multiple_ffd_py.run_filediff(args.tsan, args.asan)) test_list.append(discadj_multiple_ffd_py) # test direct_differentiation.py @@ -282,7 +288,8 @@ def main(): directdiff_euler_py.reference_file = "of_grad_directdiff.dat.ref" directdiff_euler_py.reference_file_aarch64 = "of_grad_directdiff_aarch64.dat.ref" directdiff_euler_py.test_file = "DIRECTDIFF/of_grad_directdiff.dat" - pass_list.append(directdiff_euler_py.run_filediff()) + directdiff_euler_py.enabled_with_asan = False + pass_list.append(directdiff_euler_py.run_filediff(args.tsan, args.asan)) test_list.append(directdiff_euler_py) # test direct_differentiation.py with multiple ffd boxes @@ -295,7 +302,8 @@ def main(): directdiff_multiple_ffd_py.reference_file = "of_grad_directdiff.dat.ref" directdiff_multiple_ffd_py.reference_file_aarch64 = "of_grad_directdiff_aarch64.dat.ref" directdiff_multiple_ffd_py.test_file = "DIRECTDIFF/of_grad_directdiff.dat" - pass_list.append(directdiff_multiple_ffd_py.run_filediff()) + directdiff_multiple_ffd_py.enabled_with_asan = False + pass_list.append(directdiff_multiple_ffd_py.run_filediff(args.tsan, args.asan)) test_list.append(directdiff_multiple_ffd_py) # test continuous_adjoint.py, with multiple objectives @@ -320,8 +328,9 @@ def main(): pywrapper_FEA_AD_FlowLoad.timeout = 1600 pywrapper_FEA_AD_FlowLoad.tol = 0.000001 pywrapper_FEA_AD_FlowLoad.new_output = False + pywrapper_FEA_AD_FlowLoad.enabled_with_asan = False test_list.append(pywrapper_FEA_AD_FlowLoad) - pass_list.append(pywrapper_FEA_AD_FlowLoad.run_test()) + pass_list.append(pywrapper_FEA_AD_FlowLoad.run_test(args.tsan, args.asan)) # Flow AD Mesh Displacement Sensitivity pywrapper_CFD_AD_MeshDisp = TestCase('pywrapper_CFD_AD_MeshDisp') @@ -333,8 +342,9 @@ def main(): pywrapper_CFD_AD_MeshDisp.timeout = 1600 pywrapper_CFD_AD_MeshDisp.tol = 0.000001 pywrapper_CFD_AD_MeshDisp.new_output = False + pywrapper_CFD_AD_MeshDisp.enabled_with_asan = False test_list.append(pywrapper_CFD_AD_MeshDisp) - pass_list.append(pywrapper_CFD_AD_MeshDisp.run_test()) + pass_list.append(pywrapper_CFD_AD_MeshDisp.run_test(args.tsan, args.asan)) ################################### @@ -350,7 +360,8 @@ def main(): grad_smooth_naca0012.reference_file = "of_hess.dat.ref" grad_smooth_naca0012.reference_file_aarch64 = "of_hess_aarch64.dat.ref" grad_smooth_naca0012.test_file = "of_hess.dat" - pass_list.append(grad_smooth_naca0012.run_filediff()) + grad_smooth_naca0012.enabled_with_asan = False + pass_list.append(grad_smooth_naca0012.run_filediff(args.tsan, args.asan)) test_list.append(grad_smooth_naca0012) # Tests summary From 3477fba6e59b07190c385688a609423f9e14ea7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Thu, 28 Mar 2024 18:37:45 +0100 Subject: [PATCH 35/60] Enable asan execution of SU2_GEO and SU2_DEF serial regression tests. --- TestCases/TestCase.py | 166 +++++++++++++++++---------------- TestCases/serial_regression.py | 15 --- 2 files changed, 84 insertions(+), 97 deletions(-) diff --git a/TestCases/TestCase.py b/TestCases/TestCase.py index ec6499245b3..334be29bb01 100644 --- a/TestCases/TestCase.py +++ b/TestCases/TestCase.py @@ -642,52 +642,53 @@ def run_geo(self, with_tsan=False, with_asan=False): timed_out = True passed = False - # Examine the output - f = open(logfilename,'r') - output = f.readlines() - delta_vals = [] - sim_vals = [] - data = [] - if not timed_out: - start_solver = False - for line in output: - if not start_solver: # Don't bother parsing anything before SU2_GEO starts - if line.find('Station 1') > -1: - start_solver=True - elif line.find('Station 2') > -1: # jump out of loop if we hit the next station - break - else: # Found the lines; parse the input - - if line.find('Chord') > -1: - raw_data = line.replace(",", "").split() - data.append(raw_data[1]) - found_chord = True - data.append(raw_data[5]) - found_radius = True - data.append(raw_data[8]) - found_toc = True - data.append(raw_data[10]) - found_aoa = True - - if found_chord and found_radius and found_toc and found_aoa: # Found what we're checking for - iter_missing = False - if not len(self.test_vals)==len(data): # something went wrong... probably bad input - print("Error in test_vals!") - passed = False - for j in range(len(data)): - sim_vals.append( float(data[j]) ) - delta_vals.append( abs(float(data[j])-self.test_vals[j]) ) - if delta_vals[j] > self.tol: - exceed_tol = True - passed = False - else: - iter_missing = True + if not with_tsan and not with_asan: # sanitizer findings result in non-zero return code, no need to examine the output + # Examine the output + f = open(logfilename,'r') + output = f.readlines() + delta_vals = [] + sim_vals = [] + data = [] + if not timed_out: + start_solver = False + for line in output: + if not start_solver: # Don't bother parsing anything before SU2_GEO starts + if line.find('Station 1') > -1: + start_solver=True + elif line.find('Station 2') > -1: # jump out of loop if we hit the next station + break + else: # Found the lines; parse the input + + if line.find('Chord') > -1: + raw_data = line.replace(",", "").split() + data.append(raw_data[1]) + found_chord = True + data.append(raw_data[5]) + found_radius = True + data.append(raw_data[8]) + found_toc = True + data.append(raw_data[10]) + found_aoa = True + + if found_chord and found_radius and found_toc and found_aoa: # Found what we're checking for + iter_missing = False + if not len(self.test_vals)==len(data): # something went wrong... probably bad input + print("Error in test_vals!") + passed = False + for j in range(len(data)): + sim_vals.append( float(data[j]) ) + delta_vals.append( abs(float(data[j])-self.test_vals[j]) ) + if delta_vals[j] > self.tol: + exceed_tol = True + passed = False + else: + iter_missing = True - if not start_solver: - passed = False + if not start_solver: + passed = False - if iter_missing: - passed = False + if iter_missing: + passed = False # Write the test results #for j in output: @@ -769,48 +770,49 @@ def run_def(self, with_tsan=False, with_asan=False): timed_out = True passed = False - # Examine the output - f = open(logfilename,'r') - output = f.readlines() - delta_vals = [] - sim_vals = [] - if not timed_out: - start_solver = False - for line in output: - if not start_solver: # Don't bother parsing anything before -- Volumetric grid deformation --- - if line.find('Volumetric grid deformation') > -1: - start_solver=True - else: # Found the -- Volumetric grid deformation --- line; parse the input - raw_data = line.split() - try: - iter_number = int(raw_data[0]) - data = raw_data[len(raw_data)-1:] # Take the last column for comparison - except ValueError: - continue - except IndexError: - continue + if not with_tsan and not with_asan: # sanitizer findings result in non-zero return code, no need to examine the output + # Examine the output + f = open(logfilename,'r') + output = f.readlines() + delta_vals = [] + sim_vals = [] + if not timed_out: + start_solver = False + for line in output: + if not start_solver: # Don't bother parsing anything before -- Volumetric grid deformation --- + if line.find('Volumetric grid deformation') > -1: + start_solver=True + else: # Found the -- Volumetric grid deformation --- line; parse the input + raw_data = line.split() + try: + iter_number = int(raw_data[0]) + data = raw_data[len(raw_data)-1:] # Take the last column for comparison + except ValueError: + continue + except IndexError: + continue - if iter_number == self.test_iter: # Found the iteration number we're checking for - iter_missing = False - if not len(self.test_vals)==len(data): # something went wrong... probably bad input - print("Error in test_vals!") - passed = False - break - for j in range(len(data)): - sim_vals.append( float(data[j]) ) - delta_vals.append( abs(float(data[j])-self.test_vals[j]) ) - if delta_vals[j] > self.tol: - exceed_tol = True + if iter_number == self.test_iter: # Found the iteration number we're checking for + iter_missing = False + if not len(self.test_vals)==len(data): # something went wrong... probably bad input + print("Error in test_vals!") passed = False - break - else: - iter_missing = True + break + for j in range(len(data)): + sim_vals.append( float(data[j]) ) + delta_vals.append( abs(float(data[j])-self.test_vals[j]) ) + if delta_vals[j] > self.tol: + exceed_tol = True + passed = False + break + else: + iter_missing = True - if not start_solver: - passed = False + if not start_solver: + passed = False - if iter_missing: - passed = False + if iter_missing: + passed = False # Write the test results #for j in output: diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index 9964395d837..ce5de549f41 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -1206,7 +1206,6 @@ def main(): naca0012_geo.command = TestCase.Command(exec = "SU2_GEO") naca0012_geo.timeout = 1600 naca0012_geo.tol = 0.00001 - naca0012_geo.enabled_with_asan = False pass_list.append(naca0012_geo.run_geo(args.tsan, args.asan)) test_list.append(naca0012_geo) @@ -1223,7 +1222,6 @@ def main(): intersect_def.command = TestCase.Command(exec = "SU2_DEF") intersect_def.timeout = 1600 intersect_def.tol = 1e-04 - intersect_def.enabled_with_asan = False pass_list.append(intersect_def.run_def(args.tsan, args.asan)) test_list.append(intersect_def) @@ -1237,7 +1235,6 @@ def main(): naca0012_def.command = TestCase.Command(exec = "SU2_DEF") naca0012_def.timeout = 1600 naca0012_def.tol = 1e-08 - naca0012_def.enabled_with_asan = False pass_list.append(naca0012_def.run_def(args.tsan, args.asan)) test_list.append(naca0012_def) @@ -1251,7 +1248,6 @@ def main(): naca0012_def_file.command = TestCase.Command(exec = "SU2_DEF") naca0012_def_file.timeout = 1600 naca0012_def_file.tol = 1e-8 - naca0012_def_file.enabled_with_asan = False pass_list.append(naca0012_def_file.run_def(args.tsan, args.asan)) test_list.append(naca0012_def_file) @@ -1265,7 +1261,6 @@ def main(): rae2822_def.command = TestCase.Command(exec = "SU2_DEF") rae2822_def.timeout = 1600 rae2822_def.tol = 1e-13 - rae2822_def.enabled_with_asan = False pass_list.append(rae2822_def.run_def(args.tsan, args.asan)) test_list.append(rae2822_def) @@ -1279,7 +1274,6 @@ def main(): naca4412_def.command = TestCase.Command(exec = "SU2_DEF") naca4412_def.timeout = 1600 naca4412_def.tol = 1e-12 - naca4412_def.enabled_with_asan = False pass_list.append(naca4412_def.run_def(args.tsan, args.asan)) test_list.append(naca4412_def) @@ -1293,7 +1287,6 @@ def main(): brick_tets_def.command = TestCase.Command(exec = "SU2_DEF") brick_tets_def.timeout = 1600 brick_tets_def.tol = 1e-09 - brick_tets_def.enabled_with_asan = False pass_list.append(brick_tets_def.run_def(args.tsan, args.asan)) test_list.append(brick_tets_def) @@ -1307,7 +1300,6 @@ def main(): brick_hex_def.command = TestCase.Command(exec = "SU2_DEF") brick_hex_def.timeout = 1600 brick_hex_def.tol = 1e-09 - brick_hex_def.enabled_with_asan = False pass_list.append(brick_hex_def.run_def(args.tsan, args.asan)) test_list.append(brick_hex_def) @@ -1321,7 +1313,6 @@ def main(): brick_pyra_def.command = TestCase.Command(exec = "SU2_DEF") brick_pyra_def.timeout = 1600 brick_pyra_def.tol = 1e-08 - brick_pyra_def.enabled_with_asan = False pass_list.append(brick_pyra_def.run_def(args.tsan, args.asan)) test_list.append(brick_pyra_def) @@ -1335,7 +1326,6 @@ def main(): brick_prism_def.command = TestCase.Command(exec = "SU2_DEF") brick_prism_def.timeout = 1600 brick_prism_def.tol = 1e-08 - brick_prism_def.enabled_with_asan = False pass_list.append(brick_prism_def.run_def(args.tsan, args.asan)) test_list.append(brick_prism_def) @@ -1349,7 +1339,6 @@ def main(): brick_prism_rans_def.command = TestCase.Command(exec = "SU2_DEF") brick_prism_rans_def.timeout = 1600 brick_prism_rans_def.tol = 1e-12 - brick_prism_rans_def.enabled_with_asan = False pass_list.append(brick_prism_rans_def.run_def(args.tsan, args.asan)) test_list.append(brick_prism_rans_def) @@ -1363,7 +1352,6 @@ def main(): brick_hex_rans_def.command = TestCase.Command(exec = "SU2_DEF") brick_hex_rans_def.timeout = 1600 brick_hex_rans_def.tol = 1e-12 - brick_hex_rans_def.enabled_with_asan = False pass_list.append(brick_hex_rans_def.run_def(args.tsan, args.asan)) test_list.append(brick_hex_rans_def) @@ -1377,7 +1365,6 @@ def main(): cylinder_ffd_def.command = TestCase.Command(exec = "SU2_DEF") cylinder_ffd_def.timeout = 1600 cylinder_ffd_def.tol = 1e-09 - cylinder_ffd_def.enabled_with_asan = False pass_list.append(cylinder_ffd_def.run_def(args.tsan, args.asan)) test_list.append(cylinder_ffd_def) @@ -1391,7 +1378,6 @@ def main(): sphere_ffd_def.command = TestCase.Command(exec = "SU2_DEF") sphere_ffd_def.timeout = 1600 sphere_ffd_def.tol = 1e-08 - sphere_ffd_def.enabled_with_asan = False pass_list.append(sphere_ffd_def.run_def(args.tsan, args.asan)) test_list.append(sphere_ffd_def) @@ -1405,7 +1391,6 @@ def main(): sphere_ffd_def_bspline.command = TestCase.Command(exec = "SU2_DEF") sphere_ffd_def_bspline.timeout = 1600 sphere_ffd_def_bspline.tol = 1e-08 - sphere_ffd_def_bspline.enabled_with_asan = False pass_list.append(sphere_ffd_def_bspline.run_def(args.tsan, args.asan)) test_list.append(sphere_ffd_def_bspline) From 38b6658f4292690219b474f14bb2643a4afc8505 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Tue, 2 Apr 2024 11:15:05 +0200 Subject: [PATCH 36/60] Fixes in run_geo and run_def. --- TestCases/TestCase.py | 60 ++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/TestCases/TestCase.py b/TestCases/TestCase.py index 334be29bb01..0818c6074a0 100644 --- a/TestCases/TestCase.py +++ b/TestCases/TestCase.py @@ -642,12 +642,18 @@ def run_geo(self, with_tsan=False, with_asan=False): timed_out = True passed = False + # check for non-zero return code + process.communicate() + if process.returncode != 0: + passed = False + + delta_vals = [] + sim_vals = [] + if not with_tsan and not with_asan: # sanitizer findings result in non-zero return code, no need to examine the output # Examine the output f = open(logfilename,'r') output = f.readlines() - delta_vals = [] - sim_vals = [] data = [] if not timed_out: start_solver = False @@ -706,20 +712,21 @@ def run_geo(self, with_tsan=False, with_asan=False): if timed_out: print('ERROR: Execution timed out. timeout=%d'%self.timeout) - if exceed_tol: - print('ERROR: Difference between computed input and test_vals exceeded tolerance. TOL=%f'%self.tol) + if not with_tsan and not with_asan: + if exceed_tol: + print('ERROR: Difference between computed input and test_vals exceeded tolerance. TOL=%f'%self.tol) - if not start_solver: - print('ERROR: The code was not able to get to the "OBJFUN" section.') + if not start_solver: + print('ERROR: The code was not able to get to the "OBJFUN" section.') - if iter_missing: - print('ERROR: The SU2_GEO values could not be found.') + if iter_missing: + print('ERROR: The SU2_GEO values could not be found.') - print_vals(self.test_vals, name="test_vals (stored)") + print_vals(self.test_vals, name="test_vals (stored)") - print_vals(sim_vals, name="sim_vals (computed)") + print_vals(sim_vals, name="sim_vals (computed)") - print_vals(delta_vals, name="delta_vals") + print_vals(delta_vals, name="delta_vals") print('test duration: %.2f min'%(running_time/60.0)) print('==================== End Test: %s ====================\n'%self.tag) @@ -770,12 +777,18 @@ def run_def(self, with_tsan=False, with_asan=False): timed_out = True passed = False + # check for non-zero return code + process.communicate() + if process.returncode != 0: + passed = False + + delta_vals = [] + sim_vals = [] + if not with_tsan and not with_asan: # sanitizer findings result in non-zero return code, no need to examine the output # Examine the output f = open(logfilename,'r') output = f.readlines() - delta_vals = [] - sim_vals = [] if not timed_out: start_solver = False for line in output: @@ -830,22 +843,23 @@ def run_def(self, with_tsan=False, with_asan=False): if timed_out: print('ERROR: Execution timed out. timeout=%d sec'%self.timeout) - if exceed_tol: - print('ERROR: Difference between computed input and test_vals exceeded tolerance. TOL=%e'%self.tol) + if not with_tsan and not with_asan: + if exceed_tol: + print('ERROR: Difference between computed input and test_vals exceeded tolerance. TOL=%e'%self.tol) - if not start_solver: - print('ERROR: The code was not able to get to the "Begin solver" section.') + if not start_solver: + print('ERROR: The code was not able to get to the "Begin solver" section.') - if iter_missing: - print('ERROR: The iteration number %d could not be found.'%self.test_iter) + if iter_missing: + print('ERROR: The iteration number %d could not be found.'%self.test_iter) - print('test_iter=%d' % self.test_iter) + print('test_iter=%d' % self.test_iter) - print_vals(self.test_vals, name="test_vals (stored)") + print_vals(self.test_vals, name="test_vals (stored)") - print_vals(sim_vals, name="sim_vals (computed)") + print_vals(sim_vals, name="sim_vals (computed)") - print_vals(delta_vals, name="delta_vals") + print_vals(delta_vals, name="delta_vals") print('test duration: %.2f min'%(running_time/60.0)) #print('==================== End Test: %s ====================\n'%self.tag) From 4ce1448e2406dc7a04092c8b630bcdae435faab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Tue, 2 Apr 2024 18:31:19 +0200 Subject: [PATCH 37/60] Fix mismatched allocation/deallocation. --- SU2_GEO/src/SU2_GEO.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SU2_GEO/src/SU2_GEO.cpp b/SU2_GEO/src/SU2_GEO.cpp index 86b9ee5c6e0..cc8b3193c32 100644 --- a/SU2_GEO/src/SU2_GEO.cpp +++ b/SU2_GEO/src/SU2_GEO.cpp @@ -1435,8 +1435,8 @@ int main(int argc, char* argv[]) { delete[] Gradient; for (iPlane = 0; iPlane < nPlane; iPlane++) { - delete Plane_P0[iPlane]; - delete Plane_Normal[iPlane]; + delete[] Plane_P0[iPlane]; + delete[] Plane_Normal[iPlane]; } delete[] Plane_P0; delete[] Plane_Normal; From cf1fab86fc485ebc24e01f60bafc0d072cd1e789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Tue, 2 Apr 2024 18:56:56 +0200 Subject: [PATCH 38/60] Fix missing deallocation. --- SU2_GEO/src/SU2_GEO.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/SU2_GEO/src/SU2_GEO.cpp b/SU2_GEO/src/SU2_GEO.cpp index cc8b3193c32..4e1d3bad9fe 100644 --- a/SU2_GEO/src/SU2_GEO.cpp +++ b/SU2_GEO/src/SU2_GEO.cpp @@ -1429,6 +1429,7 @@ int main(int argc, char* argv[]) { delete[] Xcoord_Airfoil; delete[] Ycoord_Airfoil; delete[] Zcoord_Airfoil; + delete[] Variable_Airfoil; delete[] ObjectiveFunc; delete[] ObjectiveFunc_New; From 9651460281a880491959e7cece4c37d1994c1774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Wed, 3 Apr 2024 10:31:35 +0200 Subject: [PATCH 39/60] Fix memory leak of CFreeFormDefBox::BlendingFunction[2]. --- Common/src/grid_movement/CFreeFormDefBox.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Common/src/grid_movement/CFreeFormDefBox.cpp b/Common/src/grid_movement/CFreeFormDefBox.cpp index 78e4b384c9f..6cfd9cc8c85 100644 --- a/Common/src/grid_movement/CFreeFormDefBox.cpp +++ b/Common/src/grid_movement/CFreeFormDefBox.cpp @@ -144,7 +144,8 @@ CFreeFormDefBox::~CFreeFormDefBox() { for (iCornerPoints = 0; iCornerPoints < nCornerPoints; iCornerPoints++) delete[] Coord_Corner_Points[iCornerPoints]; delete[] Coord_Corner_Points; - for (iDim = 0; iDim < nDim; iDim++) { + /*--- nDim is 3 at allocation but might change later, so we used fixed 3 as upper bound for deallocation ---*/ + for (iDim = 0; iDim < 3; iDim++) { delete BlendingFunction[iDim]; } delete[] BlendingFunction; From 7ad81fb70c592454af074a00d9916f39b6f347d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Wed, 3 Apr 2024 10:34:55 +0200 Subject: [PATCH 40/60] Fix reallocation without freeing and memory leak at exit of CSurfaceMovement::FFDBox. --- Common/src/grid_movement/CSurfaceMovement.cpp | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/Common/src/grid_movement/CSurfaceMovement.cpp b/Common/src/grid_movement/CSurfaceMovement.cpp index 59b0cf7bfe8..9b21d64f2c9 100644 --- a/Common/src/grid_movement/CSurfaceMovement.cpp +++ b/Common/src/grid_movement/CSurfaceMovement.cpp @@ -33,12 +33,21 @@ CSurfaceMovement::CSurfaceMovement() : CGridMovement() { size = SU2_MPI::GetSize(); rank = SU2_MPI::GetRank(); + FFDBox = nullptr; nFFDBox = 0; nLevel = 0; FFDBoxDefinition = false; } -CSurfaceMovement::~CSurfaceMovement() = default; +CSurfaceMovement::~CSurfaceMovement() { + if (FFDBox != nullptr) { + for (unsigned int iFFDBox = 0; iFFDBox < MAX_NUMBER_FFD; ++iFFDBox) { + if (FFDBox[iFFDBox] != nullptr) delete FFDBox[iFFDBox]; + } + delete[] FFDBox; + FFDBox = nullptr; + } +}; vector > CSurfaceMovement::SetSurface_Deformation(CGeometry* geometry, CConfig* config) { unsigned short iFFDBox, iDV, iLevel, iChild, iParent, jFFDBox, iMarker; @@ -60,7 +69,16 @@ vector > CSurfaceMovement::SetSurface_Deformation(CGeometry* g if (config->GetDesign_Variable(0) == FFD_SETTING) { /*--- Definition of the FFD deformation class ---*/ - FFDBox = new CFreeFormDefBox*[MAX_NUMBER_FFD]; + /*--- As this method might be called multiple times, properly delete old objects before allocating new ones. ---*/ + if (FFDBox != nullptr) { + for (unsigned int iFFDBox = 0; iFFDBox < MAX_NUMBER_FFD; ++iFFDBox) { + if (FFDBox[iFFDBox] != nullptr) delete FFDBox[iFFDBox]; + } + delete[] FFDBox; + FFDBox = nullptr; + } + + FFDBox = new CFreeFormDefBox*[MAX_NUMBER_FFD](); /*--- Read the FFD information from the config file ---*/ @@ -167,7 +185,16 @@ vector > CSurfaceMovement::SetSurface_Deformation(CGeometry* g (config->GetDesign_Variable(0) == FFD_THICKNESS) || (config->GetDesign_Variable(0) == FFD_ANGLE_OF_ATTACK)) { /*--- Definition of the FFD deformation class ---*/ - FFDBox = new CFreeFormDefBox*[MAX_NUMBER_FFD]; + /*--- As this method might be called multiple times, properly delete old objects before allocating new ones. ---*/ + if (FFDBox != nullptr) { + for (unsigned int iFFDBox = 0; iFFDBox < MAX_NUMBER_FFD; ++iFFDBox) { + if (FFDBox[iFFDBox] != nullptr) delete FFDBox[iFFDBox]; + } + delete[] FFDBox; + FFDBox = nullptr; + } + + FFDBox = new CFreeFormDefBox*[MAX_NUMBER_FFD](); /*--- Read the FFD information from the grid file ---*/ From 41256dcda5ede6a12c89b7e8643d2194a51ee892 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Wed, 3 Apr 2024 11:14:26 +0200 Subject: [PATCH 41/60] Fix semicolon and variable hiding. --- Common/src/grid_movement/CSurfaceMovement.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Common/src/grid_movement/CSurfaceMovement.cpp b/Common/src/grid_movement/CSurfaceMovement.cpp index 9b21d64f2c9..5c29534fb39 100644 --- a/Common/src/grid_movement/CSurfaceMovement.cpp +++ b/Common/src/grid_movement/CSurfaceMovement.cpp @@ -47,7 +47,7 @@ CSurfaceMovement::~CSurfaceMovement() { delete[] FFDBox; FFDBox = nullptr; } -}; +} vector > CSurfaceMovement::SetSurface_Deformation(CGeometry* geometry, CConfig* config) { unsigned short iFFDBox, iDV, iLevel, iChild, iParent, jFFDBox, iMarker; @@ -71,7 +71,7 @@ vector > CSurfaceMovement::SetSurface_Deformation(CGeometry* g /*--- As this method might be called multiple times, properly delete old objects before allocating new ones. ---*/ if (FFDBox != nullptr) { - for (unsigned int iFFDBox = 0; iFFDBox < MAX_NUMBER_FFD; ++iFFDBox) { + for (iFFDBox = 0; iFFDBox < MAX_NUMBER_FFD; ++iFFDBox) { if (FFDBox[iFFDBox] != nullptr) delete FFDBox[iFFDBox]; } delete[] FFDBox; @@ -187,7 +187,7 @@ vector > CSurfaceMovement::SetSurface_Deformation(CGeometry* g /*--- As this method might be called multiple times, properly delete old objects before allocating new ones. ---*/ if (FFDBox != nullptr) { - for (unsigned int iFFDBox = 0; iFFDBox < MAX_NUMBER_FFD; ++iFFDBox) { + for (iFFDBox = 0; iFFDBox < MAX_NUMBER_FFD; ++iFFDBox) { if (FFDBox[iFFDBox] != nullptr) delete FFDBox[iFFDBox]; } delete[] FFDBox; From c97610b02bc1281eb766847e7ef5ed7ac451dfb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Wed, 3 Apr 2024 14:50:32 +0200 Subject: [PATCH 42/60] Explore fix for heap buffer overflow in CInterface. --- SU2_CFD/src/interfaces/CInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/interfaces/CInterface.cpp b/SU2_CFD/src/interfaces/CInterface.cpp index 050c948bc1f..20e2b2332a4 100644 --- a/SU2_CFD/src/interfaces/CInterface.cpp +++ b/SU2_CFD/src/interfaces/CInterface.cpp @@ -286,7 +286,7 @@ void CInterface::PreprocessAverage(CGeometry *donor_geometry, CGeometry *target_ for(iSpan = 1; iSpan SpanValuesDonor[jSpan]){ From afad3acf5d96e0ed7a3df1fbcaf7443e688b56c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Wed, 10 Apr 2024 16:25:40 +0200 Subject: [PATCH 43/60] Fix comparison. --- SU2_CFD/src/drivers/CDriver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 6c1a6170a04..8476c58dc54 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -2389,7 +2389,7 @@ void CDriver::PreprocessDynamicMesh(CConfig *config, CGeometry **geometry, CSolv cout << "Setting dynamic mesh structure for zone "<< iZone + 1<<"." << endl; grid_movement = new CVolumetricMovement(geometry[MESH_0], config); - if (surface_movement != nullptr) + if (surface_movement == nullptr) surface_movement = new CSurfaceMovement(); surface_movement->CopyBoundary(geometry[MESH_0], config); From 7ab1e086d220a31646568d168f622a50ae82332f Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Wed, 17 Apr 2024 16:46:55 +0200 Subject: [PATCH 44/60] 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 45/60] 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 46/60] 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 47/60] 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 48/60] 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 49/60] 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 50/60] 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 51/60] 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 52/60] 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 53/60] 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 54/60] 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: From aa2787b4437a10e917253020b007f9763ebd984f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Wed, 8 May 2024 10:35:12 +0200 Subject: [PATCH 55/60] Revert "Explore fix for heap buffer overflow in CInterface." This reverts commit c97610b02bc1281eb766847e7ef5ed7ac451dfb9. --- SU2_CFD/src/interfaces/CInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/interfaces/CInterface.cpp b/SU2_CFD/src/interfaces/CInterface.cpp index 20e2b2332a4..050c948bc1f 100644 --- a/SU2_CFD/src/interfaces/CInterface.cpp +++ b/SU2_CFD/src/interfaces/CInterface.cpp @@ -286,7 +286,7 @@ void CInterface::PreprocessAverage(CGeometry *donor_geometry, CGeometry *target_ for(iSpan = 1; iSpan SpanValuesDonor[jSpan]){ From 0f3fc3ec900f1518c0c3ed26c3e971ae27fb974c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Wed, 8 May 2024 10:39:15 +0200 Subject: [PATCH 56/60] Disable address sanitizer runs of the Aachen turbine test. --- TestCases/parallel_regression.py | 1 + TestCases/serial_regression.py | 1 + 2 files changed, 2 insertions(+) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index b891e7d9a84..f8403488070 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1058,6 +1058,7 @@ def main(): 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.enabled_with_asan = False Aachen_3D_restart.test_vals = [-15.329206, -15.008622, -15.078888, -13.841072, -12.727840, -9.975729] test_list.append(Aachen_3D_restart) diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index b0cb0c4ae7b..f7ab332ae7a 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -860,6 +860,7 @@ def main(): 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.enabled_with_asan = False Aachen_3D_restart.test_vals = [-15.137167, -14.551444, -15.078894, -13.486154, -12.724891, -9.717612] test_list.append(Aachen_3D_restart) From ca12a5cb5abc13861af626e3964c56be4cc12fbd Mon Sep 17 00:00:00 2001 From: Cristopher Morales <98025159+Cristopher-Morales@users.noreply.github.com> Date: Tue, 14 May 2024 11:27:01 +0200 Subject: [PATCH 57/60] Using free stream tremperature for initialization of wall temperature for pure conjugate heat transfer problems (#2281) * using freestream temperature as a default value * Update Common/src/CConfig.cpp Co-authored-by: Evert Bunschoten <38651601+EvertBunschoten@users.noreply.github.com> --------- Co-authored-by: Evert Bunschoten <38651601+EvertBunschoten@users.noreply.github.com> --- Common/src/CConfig.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 63810ab3e03..bf6d1e66b43 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -9234,7 +9234,8 @@ 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 free-stream temperature for pure CHT cases. + return Temperature_FreeStream; } su2double CConfig::GetWall_HeatFlux(const string& val_marker) const { From 83cac12a2a33be13378cfeee783e43e9f8ce9879 Mon Sep 17 00:00:00 2001 From: Nijso Date: Tue, 14 May 2024 13:57:17 +0200 Subject: [PATCH 58/60] change MPI_QUANTITIES to enum class (#2279) * change to enum class --- Common/include/geometry/CGeometry.hpp | 6 +- Common/include/linear_algebra/CSysMatrix.hpp | 4 +- Common/include/option_structure.hpp | 2 +- Common/src/geometry/CGeometry.cpp | 40 ++--- Common/src/geometry/CPhysicalGeometry.cpp | 4 +- .../src/grid_movement/CVolumetricMovement.cpp | 4 +- Common/src/linear_algebra/CSysMatrix.cpp | 22 +-- .../include/solvers/CFVMFlowSolverBase.hpp | 16 +- .../include/solvers/CFVMFlowSolverBase.inl | 22 +-- SU2_CFD/include/solvers/CScalarSolver.inl | 4 +- SU2_CFD/include/solvers/CSolver.hpp | 6 +- SU2_CFD/src/drivers/CDriver.cpp | 8 +- SU2_CFD/src/drivers/CDriverBase.cpp | 4 +- .../src/integration/CMultiGridIntegration.cpp | 12 +- .../integration/CSingleGridIntegration.cpp | 8 +- .../src/iteration/CDiscAdjFEAIteration.cpp | 8 +- .../src/iteration/CDiscAdjFluidIteration.cpp | 20 +-- .../src/iteration/CDiscAdjHeatIteration.cpp | 4 +- SU2_CFD/src/solvers/CAdjEulerSolver.cpp | 32 ++-- SU2_CFD/src/solvers/CAdjNSSolver.cpp | 4 +- SU2_CFD/src/solvers/CAdjTurbSolver.cpp | 8 +- SU2_CFD/src/solvers/CBaselineSolver.cpp | 12 +- SU2_CFD/src/solvers/CEulerSolver.cpp | 48 +++--- SU2_CFD/src/solvers/CFEASolver.cpp | 4 +- .../src/solvers/CGradientSmoothingSolver.cpp | 8 +- SU2_CFD/src/solvers/CHeatSolver.cpp | 16 +- SU2_CFD/src/solvers/CMeshSolver.cpp | 22 +-- SU2_CFD/src/solvers/CNEMOEulerSolver.cpp | 4 +- SU2_CFD/src/solvers/CNEMONSSolver.cpp | 2 +- SU2_CFD/src/solvers/CRadP1Solver.cpp | 4 +- SU2_CFD/src/solvers/CRadSolver.cpp | 4 +- SU2_CFD/src/solvers/CSolver.cpp | 142 +++++++++--------- .../src/solvers/CSpeciesFlameletSolver.cpp | 10 +- SU2_CFD/src/solvers/CSpeciesSolver.cpp | 14 +- SU2_CFD/src/solvers/CTransLMSolver.cpp | 12 +- SU2_CFD/src/solvers/CTurbSASolver.cpp | 4 +- SU2_CFD/src/solvers/CTurbSSTSolver.cpp | 4 +- SU2_CFD/src/solvers/CTurbSolver.cpp | 8 +- UnitTests/SU2_CFD/gradients.cpp | 8 +- 39 files changed, 282 insertions(+), 282 deletions(-) diff --git a/Common/include/geometry/CGeometry.hpp b/Common/include/geometry/CGeometry.hpp index 15a726cabec..688f71c7dce 100644 --- a/Common/include/geometry/CGeometry.hpp +++ b/Common/include/geometry/CGeometry.hpp @@ -426,7 +426,7 @@ class CGeometry { * \param[out] COUNT_PER_POINT - Number of communicated variables per point. * \param[out] MPI_TYPE - Enumerated type for the datatype of the quantity to be communicated. */ - void GetCommCountAndType(const CConfig* config, unsigned short commType, unsigned short& COUNT_PER_POINT, + void GetCommCountAndType(const CConfig* config, MPI_QUANTITIES commType, unsigned short& COUNT_PER_POINT, unsigned short& MPI_TYPE) const; /*! @@ -436,14 +436,14 @@ class CGeometry { * \param[in] config - Definition of the particular problem. * \param[in] commType - Enumerated type for the quantity to be communicated. */ - void InitiateComms(CGeometry* geometry, const CConfig* config, unsigned short commType) const; + void InitiateComms(CGeometry* geometry, const CConfig* config, MPI_QUANTITIES commType) const; /*! * \brief Routine to complete the set of non-blocking communications launched by InitiateComms() and unpacking of the * data into the geometry class. \param[in] geometry - Geometrical definition of the problem. \param[in] config - * Definition of the particular problem. \param[in] commType - Enumerated type for the quantity to be unpacked. */ - void CompleteComms(CGeometry* geometry, const CConfig* config, unsigned short commType); + void CompleteComms(CGeometry* geometry, const CConfig* config, MPI_QUANTITIES commType); /*! * \brief Get number of coordinates. diff --git a/Common/include/linear_algebra/CSysMatrix.hpp b/Common/include/linear_algebra/CSysMatrix.hpp index 573e6217d93..02747f8be07 100644 --- a/Common/include/linear_algebra/CSysMatrix.hpp +++ b/Common/include/linear_algebra/CSysMatrix.hpp @@ -92,7 +92,7 @@ struct CSysMatrixComms { */ template static void Initiate(const CSysVector& x, CGeometry* geometry, const CConfig* config, - unsigned short commType = SOLUTION_MATRIX); + MPI_QUANTITIES commType = MPI_QUANTITIES::SOLUTION_MATRIX); /*! * \brief Routine to complete the set of non-blocking communications launched by @@ -104,7 +104,7 @@ struct CSysMatrixComms { */ template static void Complete(CSysVector& x, CGeometry* geometry, const CConfig* config, - unsigned short commType = SOLUTION_MATRIX); + MPI_QUANTITIES commType = MPI_QUANTITIES::SOLUTION_MATRIX); }; /*! diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 919aefa65b9..9bbe613c4bc 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -2498,7 +2498,7 @@ enum PERIODIC_QUANTITIES { /*! * \brief Vertex-based quantities exchanged in MPI point-to-point communications. */ -enum MPI_QUANTITIES { +enum class MPI_QUANTITIES { SOLUTION , /*!< \brief Conservative solution communication. */ SOLUTION_OLD , /*!< \brief Conservative solution old communication. */ SOLUTION_GRADIENT , /*!< \brief Conservative solution gradient communication. */ diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index e1f199999f9..5292fb69a13 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -543,29 +543,29 @@ void CGeometry::PostP2PSends(CGeometry* geometry, const CConfig* config, unsigne END_SU2_OMP_MASTER } -void CGeometry::GetCommCountAndType(const CConfig* config, unsigned short commType, unsigned short& COUNT_PER_POINT, +void CGeometry::GetCommCountAndType(const CConfig* config, MPI_QUANTITIES commType, unsigned short& COUNT_PER_POINT, unsigned short& MPI_TYPE) const { switch (commType) { - case COORDINATES: + case MPI_QUANTITIES::COORDINATES: COUNT_PER_POINT = nDim; MPI_TYPE = COMM_TYPE_DOUBLE; break; - case GRID_VELOCITY: + case MPI_QUANTITIES::GRID_VELOCITY: COUNT_PER_POINT = nDim; MPI_TYPE = COMM_TYPE_DOUBLE; break; - case COORDINATES_OLD: + case MPI_QUANTITIES::COORDINATES_OLD: if (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND) COUNT_PER_POINT = nDim * 2; else COUNT_PER_POINT = nDim; MPI_TYPE = COMM_TYPE_DOUBLE; break; - case MAX_LENGTH: + case MPI_QUANTITIES::MAX_LENGTH: COUNT_PER_POINT = 1; MPI_TYPE = COMM_TYPE_DOUBLE; break; - case NEIGHBORS: + case MPI_QUANTITIES::NEIGHBORS: COUNT_PER_POINT = 1; MPI_TYPE = COMM_TYPE_UNSIGNED_SHORT; break; @@ -575,7 +575,7 @@ void CGeometry::GetCommCountAndType(const CConfig* config, unsigned short commTy } } -void CGeometry::InitiateComms(CGeometry* geometry, const CConfig* config, unsigned short commType) const { +void CGeometry::InitiateComms(CGeometry* geometry, const CConfig* config, MPI_QUANTITIES commType) const { if (nP2PSend == 0) return; /*--- Local variables ---*/ @@ -633,15 +633,15 @@ void CGeometry::InitiateComms(CGeometry* geometry, const CConfig* config, unsign buf_offset = (msg_offset + iSend) * COUNT_PER_POINT; switch (commType) { - case COORDINATES: + case MPI_QUANTITIES::COORDINATES: vector = nodes->GetCoord(iPoint); for (iDim = 0; iDim < nDim; iDim++) bufDSend[buf_offset + iDim] = vector[iDim]; break; - case GRID_VELOCITY: + case MPI_QUANTITIES::GRID_VELOCITY: vector = nodes->GetGridVel(iPoint); for (iDim = 0; iDim < nDim; iDim++) bufDSend[buf_offset + iDim] = vector[iDim]; break; - case COORDINATES_OLD: + case MPI_QUANTITIES::COORDINATES_OLD: vector = nodes->GetCoord_n(iPoint); for (iDim = 0; iDim < nDim; iDim++) { bufDSend[buf_offset + iDim] = vector[iDim]; @@ -653,10 +653,10 @@ void CGeometry::InitiateComms(CGeometry* geometry, const CConfig* config, unsign } } break; - case MAX_LENGTH: + case MPI_QUANTITIES::MAX_LENGTH: bufDSend[buf_offset] = nodes->GetMaxLength(iPoint); break; - case NEIGHBORS: + case MPI_QUANTITIES::NEIGHBORS: bufSSend[buf_offset] = geometry->nodes->GetnNeighbor(iPoint); break; default: @@ -672,7 +672,7 @@ void CGeometry::InitiateComms(CGeometry* geometry, const CConfig* config, unsign } } -void CGeometry::CompleteComms(CGeometry* geometry, const CConfig* config, unsigned short commType) { +void CGeometry::CompleteComms(CGeometry* geometry, const CConfig* config, MPI_QUANTITIES commType) { if (nP2PRecv == 0) return; /*--- Local variables ---*/ @@ -734,21 +734,21 @@ void CGeometry::CompleteComms(CGeometry* geometry, const CConfig* config, unsign /*--- Store the data correctly depending on the quantity. ---*/ switch (commType) { - case COORDINATES: + case MPI_QUANTITIES::COORDINATES: for (iDim = 0; iDim < nDim; iDim++) nodes->SetCoord(iPoint, iDim, bufDRecv[buf_offset + iDim]); break; - case GRID_VELOCITY: + case MPI_QUANTITIES::GRID_VELOCITY: for (iDim = 0; iDim < nDim; iDim++) nodes->SetGridVel(iPoint, iDim, bufDRecv[buf_offset + iDim]); break; - case COORDINATES_OLD: + case MPI_QUANTITIES::COORDINATES_OLD: nodes->SetCoord_n(iPoint, &bufDRecv[buf_offset]); if (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND) nodes->SetCoord_n1(iPoint, &bufDRecv[buf_offset + nDim]); break; - case MAX_LENGTH: + case MPI_QUANTITIES::MAX_LENGTH: nodes->SetMaxLength(iPoint, bufDRecv[buf_offset]); break; - case NEIGHBORS: + case MPI_QUANTITIES::NEIGHBORS: nodes->SetnNeighbor(iPoint, bufSRecv[buf_offset]); break; default: @@ -2327,8 +2327,8 @@ void CGeometry::RegisterCoordinates() const { } void CGeometry::UpdateGeometry(CGeometry** geometry_container, CConfig* config) { - geometry_container[MESH_0]->InitiateComms(geometry_container[MESH_0], config, COORDINATES); - geometry_container[MESH_0]->CompleteComms(geometry_container[MESH_0], config, COORDINATES); + geometry_container[MESH_0]->InitiateComms(geometry_container[MESH_0], config, MPI_QUANTITIES::COORDINATES); + geometry_container[MESH_0]->CompleteComms(geometry_container[MESH_0], config, MPI_QUANTITIES::COORDINATES); geometry_container[MESH_0]->SetControlVolume(config, UPDATE); geometry_container[MESH_0]->SetBoundControlVolume(config, UPDATE); diff --git a/Common/src/geometry/CPhysicalGeometry.cpp b/Common/src/geometry/CPhysicalGeometry.cpp index 8d245ce1206..29f10a492b3 100644 --- a/Common/src/geometry/CPhysicalGeometry.cpp +++ b/Common/src/geometry/CPhysicalGeometry.cpp @@ -6364,8 +6364,8 @@ void CPhysicalGeometry::SetMaxLength(CConfig* config) { } END_SU2_OMP_FOR - InitiateComms(this, config, MAX_LENGTH); - CompleteComms(this, config, MAX_LENGTH); + InitiateComms(this, config, MPI_QUANTITIES::MAX_LENGTH); + CompleteComms(this, config, MPI_QUANTITIES::MAX_LENGTH); } void CPhysicalGeometry::MatchActuator_Disk(const CConfig* config) { diff --git a/Common/src/grid_movement/CVolumetricMovement.cpp b/Common/src/grid_movement/CVolumetricMovement.cpp index 5b09a9cdd71..a3f91fa36c1 100644 --- a/Common/src/grid_movement/CVolumetricMovement.cpp +++ b/Common/src/grid_movement/CVolumetricMovement.cpp @@ -76,8 +76,8 @@ void CVolumetricMovement::UpdateGridCoord(CGeometry* geometry, CConfig* config) * Hence we still need a communication of the transformed coordinates, otherwise periodicity * is not maintained. ---*/ - geometry->InitiateComms(geometry, config, COORDINATES); - geometry->CompleteComms(geometry, config, COORDINATES); + geometry->InitiateComms(geometry, config, MPI_QUANTITIES::COORDINATES); + geometry->CompleteComms(geometry, config, MPI_QUANTITIES::COORDINATES); } void CVolumetricMovement::UpdateDualGrid(CGeometry* geometry, CConfig* config) { diff --git a/Common/src/linear_algebra/CSysMatrix.cpp b/Common/src/linear_algebra/CSysMatrix.cpp index 10747fadbcb..280d05b6b7f 100644 --- a/Common/src/linear_algebra/CSysMatrix.cpp +++ b/Common/src/linear_algebra/CSysMatrix.cpp @@ -226,7 +226,7 @@ void CSysMatrix::Initialize(unsigned long npoint, unsigned long npoi template void CSysMatrixComms::Initiate(const CSysVector& x, CGeometry* geometry, const CConfig* config, - unsigned short commType) { + MPI_QUANTITIES commType) { if (geometry->nP2PSend == 0) return; /*--- Local variables ---*/ @@ -236,13 +236,13 @@ void CSysMatrixComms::Initiate(const CSysVector& x, CGeometry* geometry, cons /*--- Create a boolean for reversing the order of comms. ---*/ - const bool reverse = (commType == SOLUTION_MATRIXTRANS); + const bool reverse = (commType == MPI_QUANTITIES::SOLUTION_MATRIXTRANS); /*--- Set the size of the data packet and type depending on quantity. ---*/ switch (commType) { - case SOLUTION_MATRIX: - case SOLUTION_MATRIXTRANS: + case MPI_QUANTITIES::SOLUTION_MATRIX: + case MPI_QUANTITIES::SOLUTION_MATRIXTRANS: break; default: SU2_MPI::Error("Unrecognized quantity for point-to-point MPI comms.", CURRENT_FUNCTION); @@ -265,7 +265,7 @@ void CSysMatrixComms::Initiate(const CSysVector& x, CGeometry* geometry, cons for (auto iMessage = 0; iMessage < geometry->nP2PSend; iMessage++) { switch (commType) { - case SOLUTION_MATRIX: { + case MPI_QUANTITIES::SOLUTION_MATRIX: { su2double* bufDSend = geometry->bufD_P2PSend; /*--- Get the offset for the start of this message. ---*/ @@ -294,7 +294,7 @@ void CSysMatrixComms::Initiate(const CSysVector& x, CGeometry* geometry, cons break; } - case SOLUTION_MATRIXTRANS: { + case MPI_QUANTITIES::SOLUTION_MATRIXTRANS: { /*--- We are going to communicate in reverse, so we use the recv buffer for the send instead. Also, all of the offsets and counts are derived from the recv data structures. ---*/ @@ -341,7 +341,7 @@ void CSysMatrixComms::Initiate(const CSysVector& x, CGeometry* geometry, cons } template -void CSysMatrixComms::Complete(CSysVector& x, CGeometry* geometry, const CConfig* config, unsigned short commType) { +void CSysMatrixComms::Complete(CSysVector& x, CGeometry* geometry, const CConfig* config, MPI_QUANTITIES commType) { if (geometry->nP2PRecv == 0) return; /*--- Local variables ---*/ @@ -366,7 +366,7 @@ void CSysMatrixComms::Complete(CSysVector& x, CGeometry* geometry, const CCon const auto source = status.MPI_SOURCE; switch (commType) { - case SOLUTION_MATRIX: { + case MPI_QUANTITIES::SOLUTION_MATRIX: { const su2double* bufDRecv = geometry->bufD_P2PRecv; /*--- We know the offsets based on the source rank. ---*/ @@ -400,7 +400,7 @@ void CSysMatrixComms::Complete(CSysVector& x, CGeometry* geometry, const CCon break; } - case SOLUTION_MATRIXTRANS: { + case MPI_QUANTITIES::SOLUTION_MATRIXTRANS: { /*--- We are going to communicate in reverse, so we use the send buffer for the recv instead. Also, all of the offsets and counts are derived from the send data structures. ---*/ @@ -1197,8 +1197,8 @@ void CSysMatrix::ComputePastixPreconditioner(const CSysVector(const CSysVector&, CGeometry*, const CConfig*, unsigned short); \ - template void CSysMatrixComms::Complete(CSysVector&, CGeometry*, const CConfig*, unsigned short); + template void CSysMatrixComms::Initiate(const CSysVector&, CGeometry*, const CConfig*, MPI_QUANTITIES); \ + template void CSysMatrixComms::Complete(CSysVector&, CGeometry*, const CConfig*, MPI_QUANTITIES); #define INSTANTIATE_MATRIX(TYPE) \ template class CSysMatrix; \ diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp index 5e0e34b7a3e..26a69293004 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp @@ -710,8 +710,8 @@ class CFVMFlowSolverBase : public CSolver { /*--- MPI parallelization ---*/ - InitiateComms(geometry, config, MAX_EIGENVALUE); - CompleteComms(geometry, config, MAX_EIGENVALUE); + InitiateComms(geometry, config, MPI_QUANTITIES::MAX_EIGENVALUE); + CompleteComms(geometry, config, MPI_QUANTITIES::MAX_EIGENVALUE); } /*! @@ -780,8 +780,8 @@ class CFVMFlowSolverBase : public CSolver { /*--- MPI parallelization ---*/ - InitiateComms(geometry, config, SENSOR); - CompleteComms(geometry, config, SENSOR); + InitiateComms(geometry, config, MPI_QUANTITIES::SENSOR); + CompleteComms(geometry, config, MPI_QUANTITIES::SENSOR); } @@ -871,8 +871,8 @@ class CFVMFlowSolverBase : public CSolver { /*--- MPI solution ---*/ - InitiateComms(geometry, config, SOLUTION); - CompleteComms(geometry, config, SOLUTION); + InitiateComms(geometry, config, MPI_QUANTITIES::SOLUTION); + CompleteComms(geometry, config, MPI_QUANTITIES::SOLUTION); if (!adjoint) { /*--- For verification cases, compute the global error metrics. ---*/ @@ -996,8 +996,8 @@ class CFVMFlowSolverBase : public CSolver { CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_IMPLICIT); } - InitiateComms(geometry, config, SOLUTION); - CompleteComms(geometry, config, SOLUTION); + InitiateComms(geometry, config, MPI_QUANTITIES::SOLUTION); + CompleteComms(geometry, config, MPI_QUANTITIES::SOLUTION); /*--- For verification cases, compute the global error metrics. ---*/ ComputeVerificationError(geometry, config); diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index c3051311c30..b8efa1e695d 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -266,8 +266,8 @@ void CFVMFlowSolverBase::CommunicateInitialState(CGeometry* geometry, cons /*--- Perform the MPI communication of the solution ---*/ - InitiateComms(geometry, config, SOLUTION); - CompleteComms(geometry, config, SOLUTION); + InitiateComms(geometry, config, MPI_QUANTITIES::SOLUTION); + CompleteComms(geometry, config, MPI_QUANTITIES::SOLUTION); /*--- Store the initial CFL number for all grid points. ---*/ @@ -383,7 +383,7 @@ void CFVMFlowSolverBase::SetPrimitive_Gradient_GG(CGeometry* geometry, con bool reconstruction) { const auto& primitives = nodes->GetPrimitive(); auto& gradient = reconstruction ? nodes->GetGradient_Reconstruction() : nodes->GetGradient_Primitive(); - const auto comm = reconstruction? PRIMITIVE_GRAD_REC : PRIMITIVE_GRADIENT; + const auto comm = reconstruction? MPI_QUANTITIES::PRIMITIVE_GRAD_REC : MPI_QUANTITIES::PRIMITIVE_GRADIENT; const auto commPer = reconstruction? PERIODIC_PRIM_GG_R : PERIODIC_PRIM_GG; computeGradientsGreenGauss(this, comm, commPer, *geometry, *config, primitives, 0, nPrimVarGrad, gradient); @@ -408,7 +408,7 @@ void CFVMFlowSolverBase::SetPrimitive_Gradient_LS(CGeometry* geometry, con const auto& primitives = nodes->GetPrimitive(); auto& rmatrix = nodes->GetRmatrix(); auto& gradient = reconstruction ? nodes->GetGradient_Reconstruction() : nodes->GetGradient_Primitive(); - const auto comm = reconstruction? PRIMITIVE_GRAD_REC : PRIMITIVE_GRADIENT; + const auto comm = reconstruction? MPI_QUANTITIES::PRIMITIVE_GRAD_REC : MPI_QUANTITIES::PRIMITIVE_GRADIENT; computeGradientsLeastSquares(this, comm, commPer, *geometry, *config, weighted, primitives, 0, nPrimVarGrad, gradient, rmatrix); @@ -423,7 +423,7 @@ void CFVMFlowSolverBase::SetPrimitive_Limiter(CGeometry* geometry, const C auto& primMax = nodes->GetSolution_Max(); auto& limiter = nodes->GetLimiter_Primitive(); - computeLimiters(kindLimiter, this, PRIMITIVE_LIMITER, PERIODIC_LIM_PRIM_1, PERIODIC_LIM_PRIM_2, *geometry, *config, 0, + computeLimiters(kindLimiter, this, MPI_QUANTITIES::PRIMITIVE_LIMITER, PERIODIC_LIM_PRIM_1, PERIODIC_LIM_PRIM_2, *geometry, *config, 0, nPrimVarGrad, primitives, gradient, primMin, primMax, limiter); } @@ -929,8 +929,8 @@ void CFVMFlowSolverBase::LoadRestart_impl(CGeometry **geometry, CSolver ** /*--- Compute the grid velocities on the coarser levels. ---*/ if (iMesh) geometry[iMesh]->SetRestricted_GridVelocity(geometry[iMesh - 1]); else { - geometry[MESH_0]->InitiateComms(geometry[MESH_0], config, GRID_VELOCITY); - geometry[MESH_0]->CompleteComms(geometry[MESH_0], config, GRID_VELOCITY); + geometry[MESH_0]->InitiateComms(geometry[MESH_0], config, MPI_QUANTITIES::GRID_VELOCITY); + geometry[MESH_0]->CompleteComms(geometry[MESH_0], config, MPI_QUANTITIES::GRID_VELOCITY); } } } @@ -941,8 +941,8 @@ void CFVMFlowSolverBase::LoadRestart_impl(CGeometry **geometry, CSolver ** on the fine level in order to have all necessary quantities updated, especially if this is a turbulent simulation (eddy viscosity). ---*/ - solver[MESH_0][FLOW_SOL]->InitiateComms(geometry[MESH_0], config, SOLUTION); - solver[MESH_0][FLOW_SOL]->CompleteComms(geometry[MESH_0], config, SOLUTION); + solver[MESH_0][FLOW_SOL]->InitiateComms(geometry[MESH_0], config, MPI_QUANTITIES::SOLUTION); + solver[MESH_0][FLOW_SOL]->CompleteComms(geometry[MESH_0], config, MPI_QUANTITIES::SOLUTION); /*--- For turbulent/species simulations the flow preprocessing is done by the turbulence/species solver * after it loads its variables (they are needed to compute flow primitives). In case turbulence and species, the @@ -957,8 +957,8 @@ void CFVMFlowSolverBase::LoadRestart_impl(CGeometry **geometry, CSolver ** for (auto iMesh = 1u; iMesh <= config->GetnMGLevels(); iMesh++) { MultigridRestriction(*geometry[iMesh - 1], solver[iMesh - 1][FLOW_SOL]->GetNodes()->GetSolution(), *geometry[iMesh], solver[iMesh][FLOW_SOL]->GetNodes()->GetSolution()); - solver[iMesh][FLOW_SOL]->InitiateComms(geometry[iMesh], config, SOLUTION); - solver[iMesh][FLOW_SOL]->CompleteComms(geometry[iMesh], config, SOLUTION); + solver[iMesh][FLOW_SOL]->InitiateComms(geometry[iMesh], config, MPI_QUANTITIES::SOLUTION); + solver[iMesh][FLOW_SOL]->CompleteComms(geometry[iMesh], config, MPI_QUANTITIES::SOLUTION); if (config->GetKind_Turb_Model() == TURB_MODEL::NONE && config->GetKind_Species_Model() == SPECIES_MODEL::NONE) { diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index 6f9aeafac4a..1777fa2e289 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -531,8 +531,8 @@ void CScalarSolver::CompleteImplicitIteration(CGeometry* geometry, CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_IMPLICIT); } - InitiateComms(geometry, config, SOLUTION); - CompleteComms(geometry, config, SOLUTION); + InitiateComms(geometry, config, MPI_QUANTITIES::SOLUTION); + CompleteComms(geometry, config, MPI_QUANTITIES::SOLUTION); } template diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 2b114a7714b..5a52599cfe6 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -240,7 +240,7 @@ class CSolver { * \param[out] MPI_TYPE - Enumerated type for the datatype of the quantity to be communicated. */ void GetCommCountAndType(const CConfig* config, - unsigned short commType, + MPI_QUANTITIES commType, unsigned short &COUNT_PER_POINT, unsigned short &MPI_TYPE) const; @@ -252,7 +252,7 @@ class CSolver { */ void InitiateComms(CGeometry *geometry, const CConfig *config, - unsigned short commType); + MPI_QUANTITIES commType); /*! * \brief Routine to complete the set of non-blocking communications launched by InitiateComms() and unpacking of the data in the solver class. @@ -262,7 +262,7 @@ class CSolver { */ void CompleteComms(CGeometry *geometry, const CConfig *config, - unsigned short commType); + MPI_QUANTITIES commType); /*! * \brief Helper function to define the type and number of variables per point for each communication type. diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 8476c58dc54..14c478c0f47 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -912,8 +912,8 @@ void CDriver::InitializeGeometryFVM(CConfig *config, CGeometry **&geometry) { if ((rank == MASTER_NODE) && (size > SINGLE_NODE) && (iMGlevel == MESH_0)) cout << "Communicating number of neighbors." << endl; - geometry[iMGlevel]->InitiateComms(geometry[iMGlevel], config, NEIGHBORS); - geometry[iMGlevel]->CompleteComms(geometry[iMGlevel], config, NEIGHBORS); + geometry[iMGlevel]->InitiateComms(geometry[iMGlevel], config, MPI_QUANTITIES::NEIGHBORS); + geometry[iMGlevel]->CompleteComms(geometry[iMGlevel], config, MPI_QUANTITIES::NEIGHBORS); } } @@ -2513,7 +2513,7 @@ void CDriver::InitializeInterface(CConfig **config, CSolver***** solver, CGeomet const auto fluidZone = heat_target? donor : target; - if (config[fluidZone]->GetEnergy_Equation() || (config[fluidZone]->GetKind_Regime() == ENUM_REGIME::COMPRESSIBLE) + if (config[fluidZone]->GetEnergy_Equation() || (config[fluidZone]->GetKind_Regime() == ENUM_REGIME::COMPRESSIBLE) || (config[fluidZone]->GetKind_FluidModel() == ENUM_FLUIDMODEL::FLUID_FLAMELET)) interface_type = heat_target? CONJUGATE_HEAT_FS : CONJUGATE_HEAT_SF; else if (config[fluidZone]->GetWeakly_Coupled_Heat()) @@ -2693,7 +2693,7 @@ void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, } } - for (iZone = 0; iZone < nZone-1; iZone++) { + for (iZone = 0; iZone < nZone-1; iZone++) { geometry[nZone-1][INST_0][MESH_0]->SetAvgTurboGeoValues(config[iZone],geometry[iZone][INST_0][MESH_0], iZone); } diff --git a/SU2_CFD/src/drivers/CDriverBase.cpp b/SU2_CFD/src/drivers/CDriverBase.cpp index c964677e623..602e89e3ace 100644 --- a/SU2_CFD/src/drivers/CDriverBase.cpp +++ b/SU2_CFD/src/drivers/CDriverBase.cpp @@ -391,8 +391,8 @@ vector CDriverBase::GetMarkerVertexNormals(unsigned short iMarker } void CDriverBase::CommunicateMeshDisplacements() { - solver_container[selected_zone][INST_0][MESH_0][MESH_SOL]->InitiateComms(main_geometry, main_config, MESH_DISPLACEMENTS); - solver_container[selected_zone][INST_0][MESH_0][MESH_SOL]->CompleteComms(main_geometry, main_config, MESH_DISPLACEMENTS); + solver_container[selected_zone][INST_0][MESH_0][MESH_SOL]->InitiateComms(main_geometry, main_config, MPI_QUANTITIES::MESH_DISPLACEMENTS); + solver_container[selected_zone][INST_0][MESH_0][MESH_SOL]->CompleteComms(main_geometry, main_config, MPI_QUANTITIES::MESH_DISPLACEMENTS); } map CDriverBase::GetSolverIndices() const { diff --git a/SU2_CFD/src/integration/CMultiGridIntegration.cpp b/SU2_CFD/src/integration/CMultiGridIntegration.cpp index a6750435d97..f8a7c1a9645 100644 --- a/SU2_CFD/src/integration/CMultiGridIntegration.cpp +++ b/SU2_CFD/src/integration/CMultiGridIntegration.cpp @@ -366,8 +366,8 @@ void CMultiGridIntegration::GetProlongated_Correction(unsigned short RunTime_EqS /*--- MPI the set solution old ---*/ - sol_coarse->InitiateComms(geo_coarse, config, SOLUTION_OLD); - sol_coarse->CompleteComms(geo_coarse, config, SOLUTION_OLD); + sol_coarse->InitiateComms(geo_coarse, config, MPI_QUANTITIES::SOLUTION_OLD); + sol_coarse->CompleteComms(geo_coarse, config, MPI_QUANTITIES::SOLUTION_OLD); SU2_OMP_FOR_STAT(roundUpDiv(geo_coarse->GetnPointDomain(), omp_get_num_threads())) for (Point_Coarse = 0; Point_Coarse < geo_coarse->GetnPointDomain(); Point_Coarse++) { @@ -479,8 +479,8 @@ void CMultiGridIntegration::SetProlongated_Correction(CSolver *sol_fine, CGeomet /*--- MPI the new interpolated solution ---*/ - sol_fine->InitiateComms(geo_fine, config, SOLUTION); - sol_fine->CompleteComms(geo_fine, config, SOLUTION); + sol_fine->InitiateComms(geo_fine, config, MPI_QUANTITIES::SOLUTION); + sol_fine->CompleteComms(geo_fine, config, MPI_QUANTITIES::SOLUTION); } @@ -608,8 +608,8 @@ void CMultiGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSyst /*--- MPI the new interpolated solution ---*/ - sol_coarse->InitiateComms(geo_coarse, config, SOLUTION); - sol_coarse->CompleteComms(geo_coarse, config, SOLUTION); + sol_coarse->InitiateComms(geo_coarse, config, MPI_QUANTITIES::SOLUTION); + sol_coarse->CompleteComms(geo_coarse, config, MPI_QUANTITIES::SOLUTION); } diff --git a/SU2_CFD/src/integration/CSingleGridIntegration.cpp b/SU2_CFD/src/integration/CSingleGridIntegration.cpp index 56b74282cde..de70accb876 100644 --- a/SU2_CFD/src/integration/CSingleGridIntegration.cpp +++ b/SU2_CFD/src/integration/CSingleGridIntegration.cpp @@ -111,8 +111,8 @@ void CSingleGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSys CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { CSolver::MultigridRestriction(*geo_fine, sol_fine->GetNodes()->GetSolution(), *geo_coarse, sol_coarse->GetNodes()->GetSolution()); - sol_coarse->InitiateComms(geo_coarse, config, SOLUTION); - sol_coarse->CompleteComms(geo_coarse, config, SOLUTION); + sol_coarse->InitiateComms(geo_coarse, config, MPI_QUANTITIES::SOLUTION); + sol_coarse->CompleteComms(geo_coarse, config, MPI_QUANTITIES::SOLUTION); } void CSingleGridIntegration::SetRestricted_EddyVisc(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, @@ -160,7 +160,7 @@ void CSingleGridIntegration::SetRestricted_EddyVisc(unsigned short RunTime_EqSys /*--- MPI the new interpolated solution (this also includes the eddy viscosity) ---*/ - sol_coarse->InitiateComms(geo_coarse, config, SOLUTION_EDDY); - sol_coarse->CompleteComms(geo_coarse, config, SOLUTION_EDDY); + sol_coarse->InitiateComms(geo_coarse, config, MPI_QUANTITIES::SOLUTION_EDDY); + sol_coarse->CompleteComms(geo_coarse, config, MPI_QUANTITIES::SOLUTION_EDDY); } diff --git a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp index d7848499f62..53f1bff6945 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp @@ -233,11 +233,11 @@ void CDiscAdjFEAIteration::SetDependencies(CSolver***** solver, CGeometry**** ge /*--- MPI dependencies. ---*/ - dir_solver->InitiateComms(structural_geometry, config[iZone], SOLUTION_FEA); - dir_solver->CompleteComms(structural_geometry, config[iZone], SOLUTION_FEA); + dir_solver->InitiateComms(structural_geometry, config[iZone], MPI_QUANTITIES::SOLUTION_FEA); + dir_solver->CompleteComms(structural_geometry, config[iZone], MPI_QUANTITIES::SOLUTION_FEA); - structural_geometry->InitiateComms(structural_geometry, config[iZone], COORDINATES); - structural_geometry->CompleteComms(structural_geometry, config[iZone], COORDINATES); + structural_geometry->InitiateComms(structural_geometry, config[iZone], MPI_QUANTITIES::COORDINATES); + structural_geometry->CompleteComms(structural_geometry, config[iZone], MPI_QUANTITIES::COORDINATES); } END_SU2_OMP_PARALLEL diff --git a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp index 6bde7b99418..27173f3357e 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp @@ -468,26 +468,26 @@ void CDiscAdjFluidIteration::SetDependencies(CSolver***** solver, CGeometry**** /*--- Compute coupling between flow, turbulent and species equations ---*/ solvers0[FLOW_SOL]->Preprocessing(geometry0, solvers0, config[iZone], MESH_0, NO_RK_ITER, RUNTIME_FLOW_SYS, true); - solvers0[FLOW_SOL]->InitiateComms(geometry0, config[iZone], SOLUTION); - solvers0[FLOW_SOL]->CompleteComms(geometry0, config[iZone], SOLUTION); + solvers0[FLOW_SOL]->InitiateComms(geometry0, config[iZone], MPI_QUANTITIES::SOLUTION); + solvers0[FLOW_SOL]->CompleteComms(geometry0, config[iZone], MPI_QUANTITIES::SOLUTION); if (turbulent && !config[iZone]->GetFrozen_Visc_Disc()) { solvers0[TURB_SOL]->Postprocessing(geometry0, solvers0, config[iZone], MESH_0); - solvers0[TURB_SOL]->InitiateComms(geometry0, config[iZone], SOLUTION); - solvers0[TURB_SOL]->CompleteComms(geometry0, config[iZone], SOLUTION); + solvers0[TURB_SOL]->InitiateComms(geometry0, config[iZone], MPI_QUANTITIES::SOLUTION); + solvers0[TURB_SOL]->CompleteComms(geometry0, config[iZone], MPI_QUANTITIES::SOLUTION); } if (config[iZone]->GetKind_Species_Model() != SPECIES_MODEL::NONE) { solvers0[SPECIES_SOL]->Preprocessing(geometry0, solvers0, config[iZone], MESH_0, NO_RK_ITER, RUNTIME_FLOW_SYS, true); - solvers0[SPECIES_SOL]->InitiateComms(geometry0, config[iZone], SOLUTION); - solvers0[SPECIES_SOL]->CompleteComms(geometry0, config[iZone], SOLUTION); + solvers0[SPECIES_SOL]->InitiateComms(geometry0, config[iZone], MPI_QUANTITIES::SOLUTION); + solvers0[SPECIES_SOL]->CompleteComms(geometry0, config[iZone], MPI_QUANTITIES::SOLUTION); } if (config[iZone]->GetWeakly_Coupled_Heat()) { solvers0[HEAT_SOL]->Set_Heatflux_Areas(geometry0, config[iZone]); solvers0[HEAT_SOL]->Preprocessing(geometry0, solvers0, config[iZone], MESH_0, NO_RK_ITER, RUNTIME_HEAT_SYS, true); solvers0[HEAT_SOL]->Postprocessing(geometry0, solvers0, config[iZone], MESH_0); - solvers0[HEAT_SOL]->InitiateComms(geometry0, config[iZone], SOLUTION); - solvers0[HEAT_SOL]->CompleteComms(geometry0, config[iZone], SOLUTION); + solvers0[HEAT_SOL]->InitiateComms(geometry0, config[iZone], MPI_QUANTITIES::SOLUTION); + solvers0[HEAT_SOL]->CompleteComms(geometry0, config[iZone], MPI_QUANTITIES::SOLUTION); } } @@ -495,8 +495,8 @@ void CDiscAdjFluidIteration::SetDependencies(CSolver***** solver, CGeometry**** if (config[iZone]->AddRadiation()) { solvers0[RAD_SOL]->Postprocessing(geometry0, solvers0, config[iZone], MESH_0); - solvers0[RAD_SOL]->InitiateComms(geometry0, config[iZone], SOLUTION); - solvers0[RAD_SOL]->CompleteComms(geometry0, config[iZone], SOLUTION); + solvers0[RAD_SOL]->InitiateComms(geometry0, config[iZone], MPI_QUANTITIES::SOLUTION); + solvers0[RAD_SOL]->CompleteComms(geometry0, config[iZone], MPI_QUANTITIES::SOLUTION); } } diff --git a/SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp index 1c3666d5216..f0c14d4168a 100644 --- a/SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp @@ -213,8 +213,8 @@ void CDiscAdjHeatIteration::SetDependencies(CSolver***** solver, CGeometry**** g solvers0[HEAT_SOL]->Preprocessing(geometries[MESH_0], solvers0, config[iZone], MESH_0, NO_RK_ITER, RUNTIME_HEAT_SYS, true); solvers0[HEAT_SOL]->Postprocessing(geometries[MESH_0], solvers0, config[iZone], MESH_0); - solvers0[HEAT_SOL]->InitiateComms(geometries[MESH_0], config[iZone], SOLUTION); - solvers0[HEAT_SOL]->CompleteComms(geometries[MESH_0], config[iZone], SOLUTION); + solvers0[HEAT_SOL]->InitiateComms(geometries[MESH_0], config[iZone], MPI_QUANTITIES::SOLUTION); + solvers0[HEAT_SOL]->CompleteComms(geometries[MESH_0], config[iZone], MPI_QUANTITIES::SOLUTION); } void CDiscAdjHeatIteration::RegisterOutput(CSolver***** solver, CGeometry**** geometry, CConfig** config, diff --git a/SU2_CFD/src/solvers/CAdjEulerSolver.cpp b/SU2_CFD/src/solvers/CAdjEulerSolver.cpp index e43bd91c871..17128c7fec8 100644 --- a/SU2_CFD/src/solvers/CAdjEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CAdjEulerSolver.cpp @@ -328,8 +328,8 @@ CAdjEulerSolver::CAdjEulerSolver(CGeometry *geometry, CConfig *config, unsigned /*--- MPI solution ---*/ - InitiateComms(geometry, config, SOLUTION); - CompleteComms(geometry, config, SOLUTION); + InitiateComms(geometry, config, MPI_QUANTITIES::SOLUTION); + CompleteComms(geometry, config, MPI_QUANTITIES::SOLUTION); SolverName = "ADJ.FLOW"; } @@ -888,8 +888,8 @@ void CAdjEulerSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solve for (auto iMesh = 1ul; iMesh <= config->GetnMGLevels(); iMesh++) { MultigridRestriction(*geometry[iMesh - 1], solver_container[iMesh - 1][ADJFLOW_SOL]->GetNodes()->GetSolution(), *geometry[iMesh], solver_container[iMesh][ADJFLOW_SOL]->GetNodes()->GetSolution()); - solver_container[iMesh][ADJFLOW_SOL]->InitiateComms(geometry[iMesh], config, SOLUTION); - solver_container[iMesh][ADJFLOW_SOL]->CompleteComms(geometry[iMesh], config, SOLUTION); + solver_container[iMesh][ADJFLOW_SOL]->InitiateComms(geometry[iMesh], config, MPI_QUANTITIES::SOLUTION); + solver_container[iMesh][ADJFLOW_SOL]->CompleteComms(geometry[iMesh], config, MPI_QUANTITIES::SOLUTION); } } @@ -1343,8 +1343,8 @@ void CAdjEulerSolver::SetCentered_Dissipation_Sensor(CGeometry *geometry, CConfi /*--- MPI parallelization ---*/ - InitiateComms(geometry, config, SENSOR); - CompleteComms(geometry, config, SENSOR); + InitiateComms(geometry, config, MPI_QUANTITIES::SENSOR); + CompleteComms(geometry, config, MPI_QUANTITIES::SENSOR); } @@ -1377,8 +1377,8 @@ void CAdjEulerSolver::ExplicitRK_Iteration(CGeometry *geometry, CSolver **solver /*--- MPI solution ---*/ - InitiateComms(geometry, config, SOLUTION); - CompleteComms(geometry, config, SOLUTION); + InitiateComms(geometry, config, MPI_QUANTITIES::SOLUTION); + CompleteComms(geometry, config, MPI_QUANTITIES::SOLUTION); /*--- Compute the root mean square residual ---*/ SetResidual_RMS(geometry, config); @@ -1411,8 +1411,8 @@ void CAdjEulerSolver::ExplicitEuler_Iteration(CGeometry *geometry, CSolver **sol /*--- MPI solution ---*/ - InitiateComms(geometry, config, SOLUTION); - CompleteComms(geometry, config, SOLUTION); + InitiateComms(geometry, config, MPI_QUANTITIES::SOLUTION); + CompleteComms(geometry, config, MPI_QUANTITIES::SOLUTION); /*--- Compute the root mean square residual ---*/ SetResidual_RMS(geometry, config); @@ -1491,8 +1491,8 @@ void CAdjEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **sol /*--- MPI solution ---*/ - InitiateComms(geometry, config, SOLUTION); - CompleteComms(geometry, config, SOLUTION); + InitiateComms(geometry, config, MPI_QUANTITIES::SOLUTION); + CompleteComms(geometry, config, MPI_QUANTITIES::SOLUTION); /*--- Compute the root mean square residual ---*/ @@ -3880,8 +3880,8 @@ void CAdjEulerSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConf it down to the coarse levels. We also call the preprocessing routine on the fine level in order to have all necessary quantities updated. ---*/ - solver[MESH_0][ADJFLOW_SOL]->InitiateComms(geometry[MESH_0], config, SOLUTION); - solver[MESH_0][ADJFLOW_SOL]->CompleteComms(geometry[MESH_0], config, SOLUTION); + solver[MESH_0][ADJFLOW_SOL]->InitiateComms(geometry[MESH_0], config, MPI_QUANTITIES::SOLUTION); + solver[MESH_0][ADJFLOW_SOL]->CompleteComms(geometry[MESH_0], config, MPI_QUANTITIES::SOLUTION); solver[MESH_0][ADJFLOW_SOL]->Preprocessing(geometry[MESH_0], solver[MESH_0], config, MESH_0, NO_RK_ITER, RUNTIME_FLOW_SYS, false); /*--- Interpolate the solution down to the coarse multigrid levels ---*/ @@ -3889,8 +3889,8 @@ void CAdjEulerSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConf for (iMesh = 1; iMesh <= config->GetnMGLevels(); iMesh++) { MultigridRestriction(*geometry[iMesh - 1], solver[iMesh - 1][ADJFLOW_SOL]->GetNodes()->GetSolution(), *geometry[iMesh], solver[iMesh][ADJFLOW_SOL]->GetNodes()->GetSolution()); - solver[iMesh][ADJFLOW_SOL]->InitiateComms(geometry[iMesh], config, SOLUTION); - solver[iMesh][ADJFLOW_SOL]->CompleteComms(geometry[iMesh], config, SOLUTION); + solver[iMesh][ADJFLOW_SOL]->InitiateComms(geometry[iMesh], config, MPI_QUANTITIES::SOLUTION); + solver[iMesh][ADJFLOW_SOL]->CompleteComms(geometry[iMesh], config, MPI_QUANTITIES::SOLUTION); solver[iMesh][ADJFLOW_SOL]->Preprocessing(geometry[iMesh], solver[iMesh], config, iMesh, NO_RK_ITER, RUNTIME_FLOW_SYS, false); } diff --git a/SU2_CFD/src/solvers/CAdjNSSolver.cpp b/SU2_CFD/src/solvers/CAdjNSSolver.cpp index b9da5ad2b63..c07425a2bdc 100644 --- a/SU2_CFD/src/solvers/CAdjNSSolver.cpp +++ b/SU2_CFD/src/solvers/CAdjNSSolver.cpp @@ -281,8 +281,8 @@ CAdjNSSolver::CAdjNSSolver(CGeometry *geometry, CConfig *config, unsigned short /*--- MPI solution ---*/ - InitiateComms(geometry, config, SOLUTION); - CompleteComms(geometry, config, SOLUTION); + InitiateComms(geometry, config, MPI_QUANTITIES::SOLUTION); + CompleteComms(geometry, config, MPI_QUANTITIES::SOLUTION); } diff --git a/SU2_CFD/src/solvers/CAdjTurbSolver.cpp b/SU2_CFD/src/solvers/CAdjTurbSolver.cpp index 58403f541a4..3d5b6eb7024 100644 --- a/SU2_CFD/src/solvers/CAdjTurbSolver.cpp +++ b/SU2_CFD/src/solvers/CAdjTurbSolver.cpp @@ -158,8 +158,8 @@ CAdjTurbSolver::CAdjTurbSolver(CGeometry *geometry, CConfig *config, unsigned sh /*--- MPI solution ---*/ - InitiateComms(geometry, config, SOLUTION); - CompleteComms(geometry, config, SOLUTION); + InitiateComms(geometry, config, MPI_QUANTITIES::SOLUTION); + CompleteComms(geometry, config, MPI_QUANTITIES::SOLUTION); } @@ -511,8 +511,8 @@ void CAdjTurbSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solv /*--- MPI solution ---*/ - InitiateComms(geometry, config, SOLUTION); - CompleteComms(geometry, config, SOLUTION); + InitiateComms(geometry, config, MPI_QUANTITIES::SOLUTION); + CompleteComms(geometry, config, MPI_QUANTITIES::SOLUTION); /*--- Compute the root mean square residual ---*/ diff --git a/SU2_CFD/src/solvers/CBaselineSolver.cpp b/SU2_CFD/src/solvers/CBaselineSolver.cpp index bc8b9c1ebc5..411cce58397 100644 --- a/SU2_CFD/src/solvers/CBaselineSolver.cpp +++ b/SU2_CFD/src/solvers/CBaselineSolver.cpp @@ -459,8 +459,8 @@ void CBaselineSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConf /*--- MPI solution ---*/ - InitiateComms(geometry[iInst], config, SOLUTION); - CompleteComms(geometry[iInst], config, SOLUTION); + InitiateComms(geometry[iInst], config, MPI_QUANTITIES::SOLUTION); + CompleteComms(geometry[iInst], config, MPI_QUANTITIES::SOLUTION); /*--- Update the geometry for flows on dynamic meshes ---*/ @@ -468,11 +468,11 @@ void CBaselineSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConf /*--- Communicate the new coordinates and grid velocities at the halos ---*/ - geometry[iInst]->InitiateComms(geometry[iInst], config, COORDINATES); - geometry[iInst]->CompleteComms(geometry[iInst], config, COORDINATES); + geometry[iInst]->InitiateComms(geometry[iInst], config, MPI_QUANTITIES::COORDINATES); + geometry[iInst]->CompleteComms(geometry[iInst], config, MPI_QUANTITIES::COORDINATES); - geometry[iInst]->InitiateComms(geometry[iInst], config, GRID_VELOCITY); - geometry[iInst]->CompleteComms(geometry[iInst], config, GRID_VELOCITY); + geometry[iInst]->InitiateComms(geometry[iInst], config, MPI_QUANTITIES::GRID_VELOCITY); + geometry[iInst]->CompleteComms(geometry[iInst], config, MPI_QUANTITIES::GRID_VELOCITY); } diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 16cdfe59a4b..bdc4db5a473 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -2351,8 +2351,8 @@ void CEulerSolver::SetUndivided_Laplacian(CGeometry *geometry, const CConfig *co /*--- MPI parallelization ---*/ - InitiateComms(geometry, config, UNDIVIDED_LAPLACIAN); - CompleteComms(geometry, config, UNDIVIDED_LAPLACIAN); + InitiateComms(geometry, config, MPI_QUANTITIES::UNDIVIDED_LAPLACIAN); + CompleteComms(geometry, config, MPI_QUANTITIES::UNDIVIDED_LAPLACIAN); } @@ -2415,8 +2415,8 @@ void CEulerSolver::SetUpwind_Ducros_Sensor(CGeometry *geometry, CConfig *config) } END_SU2_OMP_FOR - InitiateComms(geometry, config, SENSOR); - CompleteComms(geometry, config, SENSOR); + InitiateComms(geometry, config, MPI_QUANTITIES::SENSOR); + CompleteComms(geometry, config, MPI_QUANTITIES::SENSOR); } @@ -5067,8 +5067,8 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container, su2double Velocity_i[MAXNDIM]={0}; for (auto iDim=0u; iDim < nDim; iDim++) Velocity_i[iDim] = nodes->GetVelocity(iPoint,iDim); - - const auto Velocity2_i = GeometryToolbox::SquaredNorm(nDim, Velocity_i); + + const auto Velocity2_i = GeometryToolbox::SquaredNorm(nDim, Velocity_i); const auto Density_i = nodes->GetDensity(iPoint); @@ -5090,7 +5090,7 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container, T_Total{0}, P_Total{0}, Density_e{0}, StaticEnthalpy_e{0}, StaticEnergy_e{0}; su2double Velocity2_e{0}, NormalVelocity{0}, TangVelocity{0}, VelMag_e{0}; - su2double Velocity_e[MAXNDIM] = {0}; + su2double Velocity_e[MAXNDIM] = {0}; const su2double * Flow_Dir, * Mach; switch(config->GetKind_Data_Riemann(Marker_Tag)) { @@ -5146,10 +5146,10 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container, GetFluidModel()->SetTDState_PT(P_static, T_static); /* --- Compute the boundary state u_e --- */ - for (auto iDim = 0u; iDim < nDim; iDim++) + for (auto iDim = 0u; iDim < nDim; iDim++) Velocity_e[iDim] = Mach[iDim]*GetFluidModel()->GetSoundSpeed(); - Velocity2_e = GeometryToolbox::SquaredNorm(nDim, Velocity_e); + Velocity2_e = GeometryToolbox::SquaredNorm(nDim, Velocity_e); Density_e = GetFluidModel()->GetDensity(); StaticEnergy_e = GetFluidModel()->GetStaticEnergy(); Energy_e = StaticEnergy_e + 0.5 * Velocity2_e; @@ -5176,7 +5176,7 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container, for (auto iDim = 0u; iDim < nDim; iDim++) Velocity_e[iDim] = Mach[iDim]*GetFluidModel()->GetSoundSpeed(); - Velocity2_e = GeometryToolbox::SquaredNorm(nDim, Velocity_e); + Velocity2_e = GeometryToolbox::SquaredNorm(nDim, Velocity_e); Density_e = GetFluidModel()->GetDensity(); StaticEnergy_e = GetFluidModel()->GetStaticEnergy(); Energy_e = StaticEnergy_e + 0.5 * Velocity2_e; @@ -5208,10 +5208,10 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container, /* --- Compute the boundary state u_e --- */ GetFluidModel()->SetTDState_Prho(Pressure_e, Density_e); - for (auto iDim = 0u; iDim < nDim; iDim++) + for (auto iDim = 0u; iDim < nDim; iDim++) Velocity_e[iDim] = Velocity_i[iDim]; - Velocity2_e = GeometryToolbox::SquaredNorm(nDim, Velocity_e); + Velocity2_e = GeometryToolbox::SquaredNorm(nDim, Velocity_e); Energy_e = GetFluidModel()->GetStaticEnergy() + 0.5*Velocity2_e; break; @@ -5235,7 +5235,7 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container, } /*--- Flow eigenvalues, boundary state u_e and u_i ---*/ - su2double Lambda_i[MAXNVAR] = {0}, u_e[MAXNVAR] = {0}, u_i[MAXNVAR]={0}, u_b[MAXNVAR]={0}, + su2double Lambda_i[MAXNVAR] = {0}, u_e[MAXNVAR] = {0}, u_i[MAXNVAR]={0}, u_b[MAXNVAR]={0}, dw[MAXNVAR]={0}; u_e[0] = Density_e; u_i[0] = Density_i; @@ -5302,7 +5302,7 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container, LinSysRes.AddBlock(iPoint, Residual); if (implicit) { - su2double **Jacobian_b = new su2double*[nVar], + su2double **Jacobian_b = new su2double*[nVar], **Jacobian_i = new su2double*[nVar]; su2double **DubDu = new su2double*[nVar]; for (auto iVar = 0u; iVar < nVar; iVar++){ @@ -5333,7 +5333,7 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container, if (dynamic_grid){ const auto gridVel = geometry->nodes->GetGridVel(iPoint); const auto projVelocity = GeometryToolbox::DotProduct(nDim, gridVel, Normal); - for (auto iVar = 0u; iVar < nVar; iVar++) + for (auto iVar = 0u; iVar < nVar; iVar++) Jacobian_b[iVar][iVar] -= projVelocity; } @@ -5394,7 +5394,7 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container, visc_numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), nodes->GetGradient_Primitive(iPoint)); /*--- Secondary variables ---*/ - + auto S_domain = nodes->GetSecondary(iPoint); /*--- Compute secondary thermodynamic properties (partial derivatives...) ---*/ @@ -8795,9 +8795,9 @@ void CEulerSolver::PreprocessAverage(CSolver **solver, CGeometry *geometry, CCon const auto nSpanWiseSections = config->GetnSpanWiseSections(); const auto iZone = config->GetiZone(); - + for (auto iSpan= 0u; iSpan < nSpanWiseSections; iSpan++){ - su2double TotalAreaVelocity[MAXNDIM]={0.0}, + su2double TotalAreaVelocity[MAXNDIM]={0.0}, TotalAreaPressure{0}, TotalAreaDensity{0}; for (auto iMarker = 0u; iMarker < config->GetnMarker_All(); iMarker++){ @@ -8987,7 +8987,7 @@ void CEulerSolver::TurboAverageProcess(CSolver **solver, CGeometry *geometry, CC TotalAreaVelocity[iDim] += Area*Velocity[iDim]; TotalMassVelocity[iDim] += Area*(Density*TurboVelocity[0] )*Velocity[iDim]; } - + TotalFluxes[0] += Area*(Density*TurboVelocity[0]); TotalFluxes[1] += Area*(Density*TurboVelocity[0]*TurboVelocity[0] + Pressure); for (auto iDim = 2; iDim < nDim+1; iDim++) @@ -9036,7 +9036,7 @@ void CEulerSolver::TurboAverageProcess(CSolver **solver, CGeometry *geometry, CC UpdateTotalQuantities(iMarker, jSpan, iVertex); } } - } + } } // marker_flag match } // iMarkerTP match @@ -9251,7 +9251,7 @@ void CEulerSolver::TurboAverageProcess(CSolver **solver, CGeometry *geometry, CC OmegaOut[iMarkerTP - 1][iSpan] = AverageOmega[iMarker][iSpan]; NuOut[iMarkerTP - 1][iSpan] = AverageNu[iMarker][iSpan]; } - + auto TurboVel = (marker_flag == INFLOW) ? TurboVelocityIn[iMarkerTP - 1][iSpan] : TurboVelocityOut[iMarkerTP - 1][iSpan]; if (performance_average_process == MIXEDOUT) { @@ -9281,7 +9281,7 @@ void CEulerSolver::TurboAverageProcess(CSolver **solver, CGeometry *geometry, CC if(config->GetKind_Data_Giles(Marker_Tag) == RADIAL_EQUILIBRIUM){ RadialEquilibriumPressure[iMarker][nSpanWiseSections/2] = config->GetGiles_Var1(Marker_Tag)/config->GetPressure_Ref(); } - } + } for (auto iSpan= nSpanWiseSections/2; iSpan < nSpanWiseSections-1; iSpan++){ const auto Radius2 = geometry->GetTurboRadius(iMarker,iSpan+1); const auto Radius1 = geometry->GetTurboRadius(iMarker,iSpan); @@ -9325,9 +9325,9 @@ void CEulerSolver::MixedOut_Average(CConfig *config, su2double val_init_pressure su2double vel[MAXNDIM] = {0}; vel[0] = (val_Averaged_Flux[1] - pressure_mix) / val_Averaged_Flux[0]; - for (auto iDim = 1u; iDim < nDim; iDim++) + for (auto iDim = 1u; iDim < nDim; iDim++) vel[iDim] = val_Averaged_Flux[iDim+1] / val_Averaged_Flux[0]; - + const su2double velsq = GeometryToolbox::DotProduct(nDim, vel, vel); diff --git a/SU2_CFD/src/solvers/CFEASolver.cpp b/SU2_CFD/src/solvers/CFEASolver.cpp index f67a0199d01..fd142988bce 100644 --- a/SU2_CFD/src/solvers/CFEASolver.cpp +++ b/SU2_CFD/src/solvers/CFEASolver.cpp @@ -3116,8 +3116,8 @@ void CFEASolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig *c /*--- MPI. If dynamic, we also need to communicate the old solution. ---*/ - InitiateComms(geometry[MESH_0], config, SOLUTION_FEA); - CompleteComms(geometry[MESH_0], config, SOLUTION_FEA); + InitiateComms(geometry[MESH_0], config, MPI_QUANTITIES::SOLUTION_FEA); + CompleteComms(geometry[MESH_0], config, MPI_QUANTITIES::SOLUTION_FEA); /*--- It's important to not push back the solution when this function is used to load solutions for * unsteady discrete adjoints, otherwise we overwrite one of the two solutions needed. ---*/ diff --git a/SU2_CFD/src/solvers/CGradientSmoothingSolver.cpp b/SU2_CFD/src/solvers/CGradientSmoothingSolver.cpp index 1f3a425aae6..47a624faada 100644 --- a/SU2_CFD/src/solvers/CGradientSmoothingSolver.cpp +++ b/SU2_CFD/src/solvers/CGradientSmoothingSolver.cpp @@ -287,8 +287,8 @@ void CGradientSmoothingSolver::ApplyGradientSmoothingDV(CGeometry* geometry, CNu /*--- Matrix vector product with the Laplace-Beltrami stiffness matrix. ---*/ if (config->GetSmoothOnSurface()) { - CSysMatrixComms::Initiate(helperVecIn, geometry, config, SOLUTION_MATRIX); - CSysMatrixComms::Complete(helperVecIn, geometry, config, SOLUTION_MATRIX); + CSysMatrixComms::Initiate(helperVecIn, geometry, config, MPI_QUANTITIES::SOLUTION_MATRIX); + CSysMatrixComms::Complete(helperVecIn, geometry, config, MPI_QUANTITIES::SOLUTION_MATRIX); mat_vec(helperVecIn, helperVecAux); @@ -306,8 +306,8 @@ void CGradientSmoothingSolver::ApplyGradientSmoothingDV(CGeometry* geometry, CNu grid_movement->SetVolume_Deformation(geometry, config, false, true, true); CGradientSmoothingSolverDetails::ReadVectorToGeometry(geometry, helperVecIn); - CSysMatrixComms::Initiate(helperVecIn, geometry, config, SOLUTION_MATRIX); - CSysMatrixComms::Complete(helperVecIn, geometry, config, SOLUTION_MATRIX); + CSysMatrixComms::Initiate(helperVecIn, geometry, config, MPI_QUANTITIES::SOLUTION_MATRIX); + CSysMatrixComms::Complete(helperVecIn, geometry, config, MPI_QUANTITIES::SOLUTION_MATRIX); mat_vec(helperVecIn, helperVecAux); diff --git a/SU2_CFD/src/solvers/CHeatSolver.cpp b/SU2_CFD/src/solvers/CHeatSolver.cpp index b01870e29bb..64ddb898e74 100644 --- a/SU2_CFD/src/solvers/CHeatSolver.cpp +++ b/SU2_CFD/src/solvers/CHeatSolver.cpp @@ -152,8 +152,8 @@ CHeatSolver::CHeatSolver(CGeometry *geometry, CConfig *config, unsigned short iM /*--- MPI solution ---*/ - InitiateComms(geometry, config, SOLUTION); - CompleteComms(geometry, config, SOLUTION); + InitiateComms(geometry, config, MPI_QUANTITIES::SOLUTION); + CompleteComms(geometry, config, MPI_QUANTITIES::SOLUTION); /*--- Store the initial CFL number for all grid points. ---*/ @@ -246,8 +246,8 @@ void CHeatSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig * on the fine level in order to have all necessary quantities updated, especially if this is a turbulent simulation (eddy viscosity). ---*/ - solver[MESH_0][HEAT_SOL]->InitiateComms(geometry[MESH_0], config, SOLUTION); - solver[MESH_0][HEAT_SOL]->CompleteComms(geometry[MESH_0], config, SOLUTION); + solver[MESH_0][HEAT_SOL]->InitiateComms(geometry[MESH_0], config, MPI_QUANTITIES::SOLUTION); + solver[MESH_0][HEAT_SOL]->CompleteComms(geometry[MESH_0], config, MPI_QUANTITIES::SOLUTION); solver[MESH_0][HEAT_SOL]->Preprocessing(geometry[MESH_0], solver[MESH_0], config, MESH_0, NO_RK_ITER, RUNTIME_HEAT_SYS, false); @@ -256,8 +256,8 @@ void CHeatSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig * for (auto iMesh = 1u; iMesh <= config->GetnMGLevels(); iMesh++) { MultigridRestriction(*geometry[iMesh - 1], solver[iMesh - 1][HEAT_SOL]->GetNodes()->GetSolution(), *geometry[iMesh], solver[iMesh][HEAT_SOL]->GetNodes()->GetSolution()); - solver[iMesh][HEAT_SOL]->InitiateComms(geometry[iMesh], config, SOLUTION); - solver[iMesh][HEAT_SOL]->CompleteComms(geometry[iMesh], config, SOLUTION); + solver[iMesh][HEAT_SOL]->InitiateComms(geometry[iMesh], config, MPI_QUANTITIES::SOLUTION); + solver[iMesh][HEAT_SOL]->CompleteComms(geometry[iMesh], config, MPI_QUANTITIES::SOLUTION); solver[iMesh][HEAT_SOL]->Preprocessing(geometry[iMesh], solver[iMesh], config, iMesh, NO_RK_ITER, RUNTIME_HEAT_SYS, false); } @@ -934,8 +934,8 @@ void CHeatSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solver_co for (auto iMesh = 1u; iMesh <= config->GetnMGLevels(); iMesh++) { MultigridRestriction(*geometry[iMesh - 1], solver_container[iMesh - 1][HEAT_SOL]->GetNodes()->GetSolution(), *geometry[iMesh], solver_container[iMesh][HEAT_SOL]->GetNodes()->GetSolution()); - solver_container[iMesh][HEAT_SOL]->InitiateComms(geometry[iMesh], config, SOLUTION); - solver_container[iMesh][HEAT_SOL]->CompleteComms(geometry[iMesh], config, SOLUTION); + solver_container[iMesh][HEAT_SOL]->InitiateComms(geometry[iMesh], config, MPI_QUANTITIES::SOLUTION); + solver_container[iMesh][HEAT_SOL]->CompleteComms(geometry[iMesh], config, MPI_QUANTITIES::SOLUTION); } } diff --git a/SU2_CFD/src/solvers/CMeshSolver.cpp b/SU2_CFD/src/solvers/CMeshSolver.cpp index 39e17b322c8..e875dcab694 100644 --- a/SU2_CFD/src/solvers/CMeshSolver.cpp +++ b/SU2_CFD/src/solvers/CMeshSolver.cpp @@ -479,14 +479,14 @@ void CMeshSolver::DeformMesh(CGeometry **geometry, CNumerics **numerics, CConfig if (multizone) nodes->Set_BGSSolution_k(); /*--- Capture a few MPI dependencies for AD. ---*/ - geometry[MESH_0]->InitiateComms(geometry[MESH_0], config, COORDINATES); - geometry[MESH_0]->CompleteComms(geometry[MESH_0], config, COORDINATES); + geometry[MESH_0]->InitiateComms(geometry[MESH_0], config, MPI_QUANTITIES::COORDINATES); + geometry[MESH_0]->CompleteComms(geometry[MESH_0], config, MPI_QUANTITIES::COORDINATES); - InitiateComms(geometry[MESH_0], config, SOLUTION); - CompleteComms(geometry[MESH_0], config, SOLUTION); + InitiateComms(geometry[MESH_0], config, MPI_QUANTITIES::SOLUTION); + CompleteComms(geometry[MESH_0], config, MPI_QUANTITIES::SOLUTION); - InitiateComms(geometry[MESH_0], config, MESH_DISPLACEMENTS); - CompleteComms(geometry[MESH_0], config, MESH_DISPLACEMENTS); + InitiateComms(geometry[MESH_0], config, MPI_QUANTITIES::MESH_DISPLACEMENTS); + CompleteComms(geometry[MESH_0], config, MPI_QUANTITIES::MESH_DISPLACEMENTS); /*--- Compute the stiffness matrix, no point recording because we clear the residual. ---*/ @@ -562,8 +562,8 @@ void CMeshSolver::UpdateGridCoord(CGeometry *geometry, const CConfig *config){ END_SU2_OMP_FOR /*--- Communicate the updated displacements and mesh coordinates. ---*/ - geometry->InitiateComms(geometry, config, COORDINATES); - geometry->CompleteComms(geometry, config, COORDINATES); + geometry->InitiateComms(geometry, config, MPI_QUANTITIES::COORDINATES); + geometry->CompleteComms(geometry, config, MPI_QUANTITIES::COORDINATES); } @@ -818,8 +818,8 @@ void CMeshSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig * } /*--- Communicate the loaded displacements. ---*/ - solver[MESH_0][MESH_SOL]->InitiateComms(geometry[MESH_0], config, SOLUTION); - solver[MESH_0][MESH_SOL]->CompleteComms(geometry[MESH_0], config, SOLUTION); + solver[MESH_0][MESH_SOL]->InitiateComms(geometry[MESH_0], config, MPI_QUANTITIES::SOLUTION); + solver[MESH_0][MESH_SOL]->CompleteComms(geometry[MESH_0], config, MPI_QUANTITIES::SOLUTION); /*--- Init the linear system solution. ---*/ for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { @@ -880,7 +880,7 @@ void CMeshSolver::RestartOldGeometry(CGeometry *geometry, const CConfig *config) for(unsigned short iStep = 1; iStep <= nSteps; ++iStep) { - unsigned short CommType = (iStep == 1) ? SOLUTION_TIME_N : SOLUTION_TIME_N1; + MPI_QUANTITIES CommType = (iStep == 1) ? MPI_QUANTITIES::SOLUTION_TIME_N : MPI_QUANTITIES::SOLUTION_TIME_N1; /*--- Modify file name for an unsteady restart ---*/ int Unst_RestartIter; diff --git a/SU2_CFD/src/solvers/CNEMOEulerSolver.cpp b/SU2_CFD/src/solvers/CNEMOEulerSolver.cpp index 0905ddeda32..3519d6d912d 100644 --- a/SU2_CFD/src/solvers/CNEMOEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CNEMOEulerSolver.cpp @@ -2354,7 +2354,7 @@ void CNEMOEulerSolver::SetPressureDiffusionSensor(CGeometry *geometry, CConfig * /*--- MPI parallelization ---*/ - InitiateComms(geometry, config, SENSOR); - CompleteComms(geometry, config, SENSOR); + InitiateComms(geometry, config, MPI_QUANTITIES::SENSOR); + CompleteComms(geometry, config, MPI_QUANTITIES::SENSOR); } diff --git a/SU2_CFD/src/solvers/CNEMONSSolver.cpp b/SU2_CFD/src/solvers/CNEMONSSolver.cpp index b6642b5cf8d..b30b99edebe 100644 --- a/SU2_CFD/src/solvers/CNEMONSSolver.cpp +++ b/SU2_CFD/src/solvers/CNEMONSSolver.cpp @@ -146,7 +146,7 @@ unsigned long CNEMONSSolver::SetPrimitive_Variables(CSolver **solver_container,C void CNEMONSSolver::SetPrimitive_Gradient_GG(CGeometry *geometry, const CConfig *config, bool reconstruction) { auto& gradient = reconstruction ? nodes->GetGradient_Reconstruction() : nodes->GetGradient_Primitive(); - const auto comm = reconstruction? PRIMITIVE_GRAD_REC : PRIMITIVE_GRADIENT; + const auto comm = reconstruction? MPI_QUANTITIES::PRIMITIVE_GRAD_REC : MPI_QUANTITIES::PRIMITIVE_GRADIENT; const auto commPer = reconstruction? PERIODIC_PRIM_GG_R : PERIODIC_PRIM_GG; /*--- Get indices of species & mixture density ---*/ diff --git a/SU2_CFD/src/solvers/CRadP1Solver.cpp b/SU2_CFD/src/solvers/CRadP1Solver.cpp index af40b22f2bc..d102e3b1d9a 100644 --- a/SU2_CFD/src/solvers/CRadP1Solver.cpp +++ b/SU2_CFD/src/solvers/CRadP1Solver.cpp @@ -553,8 +553,8 @@ void CRadP1Solver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver /*--- MPI solution ---*/ - InitiateComms(geometry, config, SOLUTION); - CompleteComms(geometry, config, SOLUTION); + InitiateComms(geometry, config, MPI_QUANTITIES::SOLUTION); + CompleteComms(geometry, config, MPI_QUANTITIES::SOLUTION); /*--- Compute the root mean square residual ---*/ diff --git a/SU2_CFD/src/solvers/CRadSolver.cpp b/SU2_CFD/src/solvers/CRadSolver.cpp index ca5becad7af..735983fa586 100644 --- a/SU2_CFD/src/solvers/CRadSolver.cpp +++ b/SU2_CFD/src/solvers/CRadSolver.cpp @@ -149,8 +149,8 @@ void CRadSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig *c } /*--- MPI communication ---*/ - solver[MESH_0][RAD_SOL]->InitiateComms(geometry[MESH_0], config, SOLUTION); - solver[MESH_0][RAD_SOL]->CompleteComms(geometry[MESH_0], config, SOLUTION); + solver[MESH_0][RAD_SOL]->InitiateComms(geometry[MESH_0], config, MPI_QUANTITIES::SOLUTION); + solver[MESH_0][RAD_SOL]->CompleteComms(geometry[MESH_0], config, MPI_QUANTITIES::SOLUTION); /*--- Preprocess the fluid solver to compute the primitive variables ---*/ solver[MESH_0][FLOW_SOL]->Preprocessing(geometry[MESH_0], solver[MESH_0], config, MESH_0, NO_RK_ITER, RUNTIME_FLOW_SYS, false); diff --git a/SU2_CFD/src/solvers/CSolver.cpp b/SU2_CFD/src/solvers/CSolver.cpp index 03c79b46fc3..f7af2746cfe 100644 --- a/SU2_CFD/src/solvers/CSolver.cpp +++ b/SU2_CFD/src/solvers/CSolver.cpp @@ -1322,60 +1322,60 @@ void CSolver::CompletePeriodicComms(CGeometry *geometry, } void CSolver::GetCommCountAndType(const CConfig* config, - unsigned short commType, + MPI_QUANTITIES commType, unsigned short &COUNT_PER_POINT, unsigned short &MPI_TYPE) const { switch (commType) { - case SOLUTION: - case SOLUTION_OLD: - case UNDIVIDED_LAPLACIAN: - case SOLUTION_LIMITER: + case MPI_QUANTITIES::SOLUTION: + case MPI_QUANTITIES::SOLUTION_OLD: + case MPI_QUANTITIES::UNDIVIDED_LAPLACIAN: + case MPI_QUANTITIES::SOLUTION_LIMITER: COUNT_PER_POINT = nVar; MPI_TYPE = COMM_TYPE_DOUBLE; break; - case MAX_EIGENVALUE: - case SENSOR: + case MPI_QUANTITIES::MAX_EIGENVALUE: + case MPI_QUANTITIES::SENSOR: COUNT_PER_POINT = 1; MPI_TYPE = COMM_TYPE_DOUBLE; break; - case SOLUTION_GRADIENT: - case SOLUTION_GRAD_REC: + case MPI_QUANTITIES::SOLUTION_GRADIENT: + case MPI_QUANTITIES::SOLUTION_GRAD_REC: COUNT_PER_POINT = nVar*nDim; MPI_TYPE = COMM_TYPE_DOUBLE; break; - case PRIMITIVE_GRADIENT: - case PRIMITIVE_GRAD_REC: + case MPI_QUANTITIES::PRIMITIVE_GRADIENT: + case MPI_QUANTITIES::PRIMITIVE_GRAD_REC: COUNT_PER_POINT = nPrimVarGrad*nDim; MPI_TYPE = COMM_TYPE_DOUBLE; break; - case PRIMITIVE_LIMITER: + case MPI_QUANTITIES::PRIMITIVE_LIMITER: COUNT_PER_POINT = nPrimVarGrad; MPI_TYPE = COMM_TYPE_DOUBLE; break; - case SOLUTION_EDDY: + case MPI_QUANTITIES::SOLUTION_EDDY: COUNT_PER_POINT = nVar+1; MPI_TYPE = COMM_TYPE_DOUBLE; break; - case SOLUTION_FEA: + case MPI_QUANTITIES::SOLUTION_FEA: if (config->GetTime_Domain()) COUNT_PER_POINT = nVar*3; else COUNT_PER_POINT = nVar; MPI_TYPE = COMM_TYPE_DOUBLE; break; - case AUXVAR_GRADIENT: + case MPI_QUANTITIES::AUXVAR_GRADIENT: COUNT_PER_POINT = nDim*base_nodes->GetnAuxVar(); MPI_TYPE = COMM_TYPE_DOUBLE; break; - case MESH_DISPLACEMENTS: + case MPI_QUANTITIES::MESH_DISPLACEMENTS: COUNT_PER_POINT = nDim; MPI_TYPE = COMM_TYPE_DOUBLE; break; - case SOLUTION_TIME_N: + case MPI_QUANTITIES::SOLUTION_TIME_N: COUNT_PER_POINT = nVar; MPI_TYPE = COMM_TYPE_DOUBLE; break; - case SOLUTION_TIME_N1: + case MPI_QUANTITIES::SOLUTION_TIME_N1: COUNT_PER_POINT = nVar; MPI_TYPE = COMM_TYPE_DOUBLE; break; @@ -1387,25 +1387,25 @@ void CSolver::GetCommCountAndType(const CConfig* config, } namespace CommHelpers { - CVectorOfMatrix& selectGradient(CVariable* nodes, unsigned short commType) { + CVectorOfMatrix& selectGradient(CVariable* nodes, MPI_QUANTITIES commType) { switch(commType) { - case SOLUTION_GRAD_REC: return nodes->GetGradient_Reconstruction(); - case PRIMITIVE_GRADIENT: return nodes->GetGradient_Primitive(); - case PRIMITIVE_GRAD_REC: return nodes->GetGradient_Reconstruction(); - case AUXVAR_GRADIENT: return nodes->GetAuxVarGradient(); + case MPI_QUANTITIES::SOLUTION_GRAD_REC: return nodes->GetGradient_Reconstruction(); + case MPI_QUANTITIES::PRIMITIVE_GRADIENT: return nodes->GetGradient_Primitive(); + case MPI_QUANTITIES::PRIMITIVE_GRAD_REC: return nodes->GetGradient_Reconstruction(); + case MPI_QUANTITIES::AUXVAR_GRADIENT: return nodes->GetAuxVarGradient(); default: return nodes->GetGradient(); } } - su2activematrix& selectLimiter(CVariable* nodes, unsigned short commType) { - if (commType == PRIMITIVE_LIMITER) return nodes->GetLimiter_Primitive(); + su2activematrix& selectLimiter(CVariable* nodes, MPI_QUANTITIES commType) { + if (commType == MPI_QUANTITIES::PRIMITIVE_LIMITER) return nodes->GetLimiter_Primitive(); return nodes->GetLimiter(); } } void CSolver::InitiateComms(CGeometry *geometry, const CConfig *config, - unsigned short commType) { + MPI_QUANTITIES commType) { /*--- Local variables ---*/ @@ -1470,44 +1470,44 @@ void CSolver::InitiateComms(CGeometry *geometry, buf_offset = (msg_offset + iSend)*COUNT_PER_POINT; switch (commType) { - case SOLUTION: + case MPI_QUANTITIES::SOLUTION: for (iVar = 0; iVar < nVar; iVar++) bufDSend[buf_offset+iVar] = base_nodes->GetSolution(iPoint, iVar); break; - case SOLUTION_OLD: + case MPI_QUANTITIES::SOLUTION_OLD: for (iVar = 0; iVar < nVar; iVar++) bufDSend[buf_offset+iVar] = base_nodes->GetSolution_Old(iPoint, iVar); break; - case SOLUTION_EDDY: + case MPI_QUANTITIES::SOLUTION_EDDY: for (iVar = 0; iVar < nVar; iVar++) bufDSend[buf_offset+iVar] = base_nodes->GetSolution(iPoint, iVar); bufDSend[buf_offset+nVar] = base_nodes->GetmuT(iPoint); break; - case UNDIVIDED_LAPLACIAN: + case MPI_QUANTITIES::UNDIVIDED_LAPLACIAN: for (iVar = 0; iVar < nVar; iVar++) bufDSend[buf_offset+iVar] = base_nodes->GetUndivided_Laplacian(iPoint, iVar); break; - case SOLUTION_LIMITER: - case PRIMITIVE_LIMITER: + case MPI_QUANTITIES::SOLUTION_LIMITER: + case MPI_QUANTITIES::PRIMITIVE_LIMITER: for (iVar = 0; iVar < COUNT_PER_POINT; iVar++) bufDSend[buf_offset+iVar] = limiter(iPoint, iVar); break; - case MAX_EIGENVALUE: + case MPI_QUANTITIES::MAX_EIGENVALUE: bufDSend[buf_offset] = base_nodes->GetLambda(iPoint); break; - case SENSOR: + case MPI_QUANTITIES::SENSOR: bufDSend[buf_offset] = base_nodes->GetSensor(iPoint); break; - case SOLUTION_GRADIENT: - case PRIMITIVE_GRADIENT: - case SOLUTION_GRAD_REC: - case PRIMITIVE_GRAD_REC: - case AUXVAR_GRADIENT: + case MPI_QUANTITIES::SOLUTION_GRADIENT: + case MPI_QUANTITIES::PRIMITIVE_GRADIENT: + case MPI_QUANTITIES::SOLUTION_GRAD_REC: + case MPI_QUANTITIES::PRIMITIVE_GRAD_REC: + case MPI_QUANTITIES::AUXVAR_GRADIENT: for (iVar = 0; iVar < nVarGrad; iVar++) for (iDim = 0; iDim < nDim; iDim++) bufDSend[buf_offset+iVar*nDim+iDim] = gradient(iPoint, iVar, iDim); break; - case SOLUTION_FEA: + case MPI_QUANTITIES::SOLUTION_FEA: for (iVar = 0; iVar < nVar; iVar++) { bufDSend[buf_offset+iVar] = base_nodes->GetSolution(iPoint, iVar); if (config->GetTime_Domain()) { @@ -1516,15 +1516,15 @@ void CSolver::InitiateComms(CGeometry *geometry, } } break; - case MESH_DISPLACEMENTS: + case MPI_QUANTITIES::MESH_DISPLACEMENTS: for (iDim = 0; iDim < nDim; iDim++) bufDSend[buf_offset+iDim] = base_nodes->GetBound_Disp(iPoint, iDim); break; - case SOLUTION_TIME_N: + case MPI_QUANTITIES::SOLUTION_TIME_N: for (iVar = 0; iVar < nVar; iVar++) bufDSend[buf_offset+iVar] = base_nodes->GetSolution_time_n(iPoint, iVar); break; - case SOLUTION_TIME_N1: + case MPI_QUANTITIES::SOLUTION_TIME_N1: for (iVar = 0; iVar < nVar; iVar++) bufDSend[buf_offset+iVar] = base_nodes->GetSolution_time_n1(iPoint, iVar); break; @@ -1547,7 +1547,7 @@ void CSolver::InitiateComms(CGeometry *geometry, void CSolver::CompleteComms(CGeometry *geometry, const CConfig *config, - unsigned short commType) { + MPI_QUANTITIES commType) { /*--- Local variables ---*/ @@ -1618,44 +1618,44 @@ void CSolver::CompleteComms(CGeometry *geometry, /*--- Store the data correctly depending on the quantity. ---*/ switch (commType) { - case SOLUTION: + case MPI_QUANTITIES::SOLUTION: for (iVar = 0; iVar < nVar; iVar++) base_nodes->SetSolution(iPoint, iVar, bufDRecv[buf_offset+iVar]); break; - case SOLUTION_OLD: + case MPI_QUANTITIES::SOLUTION_OLD: for (iVar = 0; iVar < nVar; iVar++) base_nodes->SetSolution_Old(iPoint, iVar, bufDRecv[buf_offset+iVar]); break; - case SOLUTION_EDDY: + case MPI_QUANTITIES::SOLUTION_EDDY: for (iVar = 0; iVar < nVar; iVar++) base_nodes->SetSolution(iPoint, iVar, bufDRecv[buf_offset+iVar]); base_nodes->SetmuT(iPoint,bufDRecv[buf_offset+nVar]); break; - case UNDIVIDED_LAPLACIAN: + case MPI_QUANTITIES::UNDIVIDED_LAPLACIAN: for (iVar = 0; iVar < nVar; iVar++) base_nodes->SetUnd_Lapl(iPoint, iVar, bufDRecv[buf_offset+iVar]); break; - case SOLUTION_LIMITER: - case PRIMITIVE_LIMITER: + case MPI_QUANTITIES::SOLUTION_LIMITER: + case MPI_QUANTITIES::PRIMITIVE_LIMITER: for (iVar = 0; iVar < COUNT_PER_POINT; iVar++) limiter(iPoint,iVar) = bufDRecv[buf_offset+iVar]; break; - case MAX_EIGENVALUE: + case MPI_QUANTITIES::MAX_EIGENVALUE: base_nodes->SetLambda(iPoint,bufDRecv[buf_offset]); break; - case SENSOR: + case MPI_QUANTITIES::SENSOR: base_nodes->SetSensor(iPoint,bufDRecv[buf_offset]); break; - case SOLUTION_GRADIENT: - case PRIMITIVE_GRADIENT: - case SOLUTION_GRAD_REC: - case PRIMITIVE_GRAD_REC: - case AUXVAR_GRADIENT: + case MPI_QUANTITIES::SOLUTION_GRADIENT: + case MPI_QUANTITIES::PRIMITIVE_GRADIENT: + case MPI_QUANTITIES::SOLUTION_GRAD_REC: + case MPI_QUANTITIES::PRIMITIVE_GRAD_REC: + case MPI_QUANTITIES::AUXVAR_GRADIENT: for (iVar = 0; iVar < nVarGrad; iVar++) for (iDim = 0; iDim < nDim; iDim++) gradient(iPoint,iVar,iDim) = bufDRecv[buf_offset+iVar*nDim+iDim]; break; - case SOLUTION_FEA: + case MPI_QUANTITIES::SOLUTION_FEA: for (iVar = 0; iVar < nVar; iVar++) { base_nodes->SetSolution(iPoint, iVar, bufDRecv[buf_offset+iVar]); if (config->GetTime_Domain()) { @@ -1664,15 +1664,15 @@ void CSolver::CompleteComms(CGeometry *geometry, } } break; - case MESH_DISPLACEMENTS: + case MPI_QUANTITIES::MESH_DISPLACEMENTS: for (iDim = 0; iDim < nDim; iDim++) base_nodes->SetBound_Disp(iPoint, iDim, bufDRecv[buf_offset+iDim]); break; - case SOLUTION_TIME_N: + case MPI_QUANTITIES::SOLUTION_TIME_N: for (iVar = 0; iVar < nVar; iVar++) base_nodes->Set_Solution_time_n(iPoint, iVar, bufDRecv[buf_offset+iVar]); break; - case SOLUTION_TIME_N1: + case MPI_QUANTITIES::SOLUTION_TIME_N1: for (iVar = 0; iVar < nVar; iVar++) base_nodes->Set_Solution_time_n1(iPoint, iVar, bufDRecv[buf_offset+iVar]); break; @@ -2095,7 +2095,7 @@ void CSolver::SetAuxVar_Gradient_GG(CGeometry *geometry, const CConfig *config) const auto& solution = base_nodes->GetAuxVar(); auto& gradient = base_nodes->GetAuxVarGradient(); - computeGradientsGreenGauss(this, AUXVAR_GRADIENT, PERIODIC_NONE, *geometry, + computeGradientsGreenGauss(this, MPI_QUANTITIES::AUXVAR_GRADIENT, PERIODIC_NONE, *geometry, *config, solution, 0, base_nodes->GetnAuxVar(), gradient); } @@ -2106,7 +2106,7 @@ void CSolver::SetAuxVar_Gradient_LS(CGeometry *geometry, const CConfig *config) auto& gradient = base_nodes->GetAuxVarGradient(); auto& rmatrix = base_nodes->GetRmatrix(); - computeGradientsLeastSquares(this, AUXVAR_GRADIENT, PERIODIC_NONE, *geometry, *config, + computeGradientsLeastSquares(this, MPI_QUANTITIES::AUXVAR_GRADIENT, PERIODIC_NONE, *geometry, *config, weighted, solution, 0, base_nodes->GetnAuxVar(), gradient, rmatrix); } @@ -2114,7 +2114,7 @@ void CSolver::SetSolution_Gradient_GG(CGeometry *geometry, const CConfig *config const auto& solution = base_nodes->GetSolution(); auto& gradient = reconstruction? base_nodes->GetGradient_Reconstruction() : base_nodes->GetGradient(); - const auto comm = reconstruction? SOLUTION_GRAD_REC : SOLUTION_GRADIENT; + const auto comm = reconstruction? MPI_QUANTITIES::SOLUTION_GRAD_REC : MPI_QUANTITIES::SOLUTION_GRADIENT; const auto commPer = reconstruction? PERIODIC_SOL_GG_R : PERIODIC_SOL_GG; computeGradientsGreenGauss(this, comm, commPer, *geometry, *config, solution, 0, nVar, gradient); @@ -2138,7 +2138,7 @@ void CSolver::SetSolution_Gradient_LS(CGeometry *geometry, const CConfig *config const auto& solution = base_nodes->GetSolution(); auto& rmatrix = base_nodes->GetRmatrix(); auto& gradient = reconstruction? base_nodes->GetGradient_Reconstruction() : base_nodes->GetGradient(); - const auto comm = reconstruction? SOLUTION_GRAD_REC : SOLUTION_GRADIENT; + const auto comm = reconstruction? MPI_QUANTITIES::SOLUTION_GRAD_REC : MPI_QUANTITIES::SOLUTION_GRADIENT; computeGradientsLeastSquares(this, comm, commPer, *geometry, *config, weighted, solution, 0, nVar, gradient, rmatrix); } @@ -2183,8 +2183,8 @@ void CSolver::SetUndivided_Laplacian(CGeometry *geometry, const CConfig *config) /*--- MPI parallelization ---*/ - InitiateComms(geometry, config, UNDIVIDED_LAPLACIAN); - CompleteComms(geometry, config, UNDIVIDED_LAPLACIAN); + InitiateComms(geometry, config, MPI_QUANTITIES::UNDIVIDED_LAPLACIAN); + CompleteComms(geometry, config, MPI_QUANTITIES::UNDIVIDED_LAPLACIAN); } @@ -2238,7 +2238,7 @@ void CSolver::SetGridVel_Gradient(CGeometry *geometry, const CConfig *config) co auto& gridVelGrad = geometry->nodes->GetGridVel_Grad(); auto rmatrix = CVectorOfMatrix(nPoint,nDim,nDim); - computeGradientsLeastSquares(nullptr, GRID_VELOCITY, PERIODIC_NONE, *geometry, *config, + computeGradientsLeastSquares(nullptr, MPI_QUANTITIES::GRID_VELOCITY, PERIODIC_NONE, *geometry, *config, true, gridVel, 0, nDim, gridVelGrad, rmatrix); } @@ -2251,7 +2251,7 @@ void CSolver::SetSolution_Limiter(CGeometry *geometry, const CConfig *config) { auto& solMax = base_nodes->GetSolution_Max(); auto& limiter = base_nodes->GetLimiter(); - computeLimiters(kindLimiter, this, SOLUTION_LIMITER, PERIODIC_LIM_SOL_1, PERIODIC_LIM_SOL_2, + computeLimiters(kindLimiter, this, MPI_QUANTITIES::SOLUTION_LIMITER, PERIODIC_LIM_SOL_1, PERIODIC_LIM_SOL_2, *geometry, *config, 0, nVar, solution, gradient, solMin, solMax, limiter); } @@ -2723,8 +2723,8 @@ void CSolver::Restart_OldGeometry(CGeometry *geometry, CConfig *config) const { /*--- It's necessary to communicate this information ---*/ - geometry->InitiateComms(geometry, config, COORDINATES_OLD); - geometry->CompleteComms(geometry, config, COORDINATES_OLD); + geometry->InitiateComms(geometry, config, MPI_QUANTITIES::COORDINATES_OLD); + geometry->CompleteComms(geometry, config, MPI_QUANTITIES::COORDINATES_OLD); } diff --git a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp index 661c9543024..2484084e46f 100644 --- a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp @@ -265,11 +265,11 @@ void CSpeciesFlameletSolver::SetInitialCondition(CGeometry** geometry, CSolver** solver_container[i_mesh][SPECIES_SOL]->GetNodes()->SetSolution(i_point, scalar_init); } - solver_container[i_mesh][SPECIES_SOL]->InitiateComms(geometry[i_mesh], config, SOLUTION); - solver_container[i_mesh][SPECIES_SOL]->CompleteComms(geometry[i_mesh], config, SOLUTION); + solver_container[i_mesh][SPECIES_SOL]->InitiateComms(geometry[i_mesh], config, MPI_QUANTITIES::SOLUTION); + solver_container[i_mesh][SPECIES_SOL]->CompleteComms(geometry[i_mesh], config, MPI_QUANTITIES::SOLUTION); - solver_container[i_mesh][FLOW_SOL]->InitiateComms(geometry[i_mesh], config, SOLUTION); - solver_container[i_mesh][FLOW_SOL]->CompleteComms(geometry[i_mesh], config, SOLUTION); + solver_container[i_mesh][FLOW_SOL]->InitiateComms(geometry[i_mesh], config, MPI_QUANTITIES::SOLUTION); + solver_container[i_mesh][FLOW_SOL]->CompleteComms(geometry[i_mesh], config, MPI_QUANTITIES::SOLUTION); solver_container[i_mesh][FLOW_SOL]->Preprocessing(geometry[i_mesh], solver_container[i_mesh], config, i_mesh, NO_RK_ITER, RUNTIME_FLOW_SYS, false); @@ -543,7 +543,7 @@ unsigned long CSpeciesFlameletSolver::SetScalarLookUps(const CConfig* config, CF nodes->SetLookupScalar(iPoint, lookup_scalar[i_lookup], i_lookup); } } - + return misses; } diff --git a/SU2_CFD/src/solvers/CSpeciesSolver.cpp b/SU2_CFD/src/solvers/CSpeciesSolver.cpp index 05d43f13ff8..3c7ac895708 100644 --- a/SU2_CFD/src/solvers/CSpeciesSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesSolver.cpp @@ -60,8 +60,8 @@ CSpeciesSolver::CSpeciesSolver(CGeometry* geometry, CConfig* config, unsigned sh /*--- MPI solution ---*/ - InitiateComms(geometry, config, SOLUTION); - CompleteComms(geometry, config, SOLUTION); + InitiateComms(geometry, config, MPI_QUANTITIES::SOLUTION); + CompleteComms(geometry, config, MPI_QUANTITIES::SOLUTION); SlidingState.resize(nMarker); SlidingStateNodes.resize(nMarker); @@ -248,8 +248,8 @@ void CSpeciesSolver::LoadRestart(CGeometry** geometry, CSolver*** solver, CConfi /*--- MPI solution and compute the eddy viscosity ---*/ - solver[MESH_0][SPECIES_SOL]->InitiateComms(geometry[MESH_0], config, SOLUTION); - solver[MESH_0][SPECIES_SOL]->CompleteComms(geometry[MESH_0], config, SOLUTION); + solver[MESH_0][SPECIES_SOL]->InitiateComms(geometry[MESH_0], config, MPI_QUANTITIES::SOLUTION); + solver[MESH_0][SPECIES_SOL]->CompleteComms(geometry[MESH_0], config, MPI_QUANTITIES::SOLUTION); // Flow-Pre computes/sets mixture properties solver[MESH_0][FLOW_SOL]->Preprocessing(geometry[MESH_0], solver[MESH_0], config, MESH_0, NO_RK_ITER, @@ -267,8 +267,8 @@ void CSpeciesSolver::LoadRestart(CGeometry** geometry, CSolver*** solver, CConfi for (auto iMesh = 1u; iMesh <= config->GetnMGLevels(); iMesh++) { MultigridRestriction(*geometry[iMesh - 1], solver[iMesh - 1][SPECIES_SOL]->GetNodes()->GetSolution(), *geometry[iMesh], solver[iMesh][SPECIES_SOL]->GetNodes()->GetSolution()); - solver[iMesh][SPECIES_SOL]->InitiateComms(geometry[iMesh], config, SOLUTION); - solver[iMesh][SPECIES_SOL]->CompleteComms(geometry[iMesh], config, SOLUTION); + solver[iMesh][SPECIES_SOL]->InitiateComms(geometry[iMesh], config, MPI_QUANTITIES::SOLUTION); + solver[iMesh][SPECIES_SOL]->CompleteComms(geometry[iMesh], config, MPI_QUANTITIES::SOLUTION); solver[iMesh][FLOW_SOL]->Preprocessing(geometry[iMesh], solver[iMesh], config, iMesh, NO_RK_ITER, RUNTIME_FLOW_SYS, false); @@ -345,7 +345,7 @@ void CSpeciesSolver::BC_Inlet(CGeometry* geometry, CSolver** solver_container, C /*--- Identify the boundary by string name ---*/ string Marker_Tag = config->GetMarker_All_TagBound(val_marker); - + if (config->GetMarker_StrongBC(Marker_Tag)==true) { nodes->SetSolution_Old(iPoint, Inlet_SpeciesVars[val_marker][iVertex]); diff --git a/SU2_CFD/src/solvers/CTransLMSolver.cpp b/SU2_CFD/src/solvers/CTransLMSolver.cpp index af89924ea2e..1fdf2a47de1 100644 --- a/SU2_CFD/src/solvers/CTransLMSolver.cpp +++ b/SU2_CFD/src/solvers/CTransLMSolver.cpp @@ -132,8 +132,8 @@ CTransLMSolver::CTransLMSolver(CGeometry *geometry, CConfig *config, unsigned sh /*--- MPI solution ---*/ - InitiateComms(geometry, config, SOLUTION); - CompleteComms(geometry, config, SOLUTION); + InitiateComms(geometry, config, MPI_QUANTITIES::SOLUTION); + CompleteComms(geometry, config, MPI_QUANTITIES::SOLUTION); /*--- Initializate quantities for SlidingMesh Interface ---*/ @@ -561,8 +561,8 @@ void CTransLMSolver::LoadRestart(CGeometry** geometry, CSolver*** solver, CConfi /*--- MPI solution and compute the eddy viscosity ---*/ - solver[MESH_0][TRANS_SOL]->InitiateComms(geometry[MESH_0], config, SOLUTION); - solver[MESH_0][TRANS_SOL]->CompleteComms(geometry[MESH_0], config, SOLUTION); + solver[MESH_0][TRANS_SOL]->InitiateComms(geometry[MESH_0], config, MPI_QUANTITIES::SOLUTION); + solver[MESH_0][TRANS_SOL]->CompleteComms(geometry[MESH_0], config, MPI_QUANTITIES::SOLUTION); /*--- For turbulent+species simulations the solver Pre-/Postprocessing is done by the species solver. ---*/ if (config->GetKind_Species_Model() == SPECIES_MODEL::NONE) { @@ -578,8 +578,8 @@ void CTransLMSolver::LoadRestart(CGeometry** geometry, CSolver*** solver, CConfi MultigridRestriction(*geometry[iMesh - 1], solver[iMesh - 1][TRANS_SOL]->GetNodes()->GetSolution(), *geometry[iMesh], solver[iMesh][TRANS_SOL]->GetNodes()->GetSolution()); - solver[iMesh][TRANS_SOL]->InitiateComms(geometry[iMesh], config, SOLUTION); - solver[iMesh][TRANS_SOL]->CompleteComms(geometry[iMesh], config, SOLUTION); + solver[iMesh][TRANS_SOL]->InitiateComms(geometry[iMesh], config, MPI_QUANTITIES::SOLUTION); + solver[iMesh][TRANS_SOL]->CompleteComms(geometry[iMesh], config, MPI_QUANTITIES::SOLUTION); if (config->GetKind_Species_Model() == SPECIES_MODEL::NONE) { solver[iMesh][FLOW_SOL]->Preprocessing(geometry[iMesh], solver[iMesh], config, iMesh, NO_RK_ITER, RUNTIME_FLOW_SYS, diff --git a/SU2_CFD/src/solvers/CTurbSASolver.cpp b/SU2_CFD/src/solvers/CTurbSASolver.cpp index d84b56e1dc6..f53596e9901 100644 --- a/SU2_CFD/src/solvers/CTurbSASolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSASolver.cpp @@ -134,8 +134,8 @@ CTurbSASolver::CTurbSASolver(CGeometry *geometry, CConfig *config, unsigned shor /*--- MPI solution ---*/ - InitiateComms(geometry, config, SOLUTION_EDDY); - CompleteComms(geometry, config, SOLUTION_EDDY); + InitiateComms(geometry, config, MPI_QUANTITIES::SOLUTION_EDDY); + CompleteComms(geometry, config, MPI_QUANTITIES::SOLUTION_EDDY); /*--- Initializate quantities for SlidingMesh Interface ---*/ diff --git a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp index ea316e9a0cd..555f8e77155 100644 --- a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp @@ -142,8 +142,8 @@ CTurbSSTSolver::CTurbSSTSolver(CGeometry *geometry, CConfig *config, unsigned sh /*--- MPI solution ---*/ - InitiateComms(geometry, config, SOLUTION_EDDY); - CompleteComms(geometry, config, SOLUTION_EDDY); + InitiateComms(geometry, config, MPI_QUANTITIES::SOLUTION_EDDY); + CompleteComms(geometry, config, MPI_QUANTITIES::SOLUTION_EDDY); /*--- Initialize quantities for SlidingMesh Interface ---*/ diff --git a/SU2_CFD/src/solvers/CTurbSolver.cpp b/SU2_CFD/src/solvers/CTurbSolver.cpp index c4b5a0b2e2b..d0744a7e223 100644 --- a/SU2_CFD/src/solvers/CTurbSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSolver.cpp @@ -167,8 +167,8 @@ void CTurbSolver::LoadRestart(CGeometry** geometry, CSolver*** solver, CConfig* /*--- MPI solution and compute the eddy viscosity ---*/ - solver[MESH_0][TURB_SOL]->InitiateComms(geometry[MESH_0], config, SOLUTION); - solver[MESH_0][TURB_SOL]->CompleteComms(geometry[MESH_0], config, SOLUTION); + solver[MESH_0][TURB_SOL]->InitiateComms(geometry[MESH_0], config, MPI_QUANTITIES::SOLUTION); + solver[MESH_0][TURB_SOL]->CompleteComms(geometry[MESH_0], config, MPI_QUANTITIES::SOLUTION); /*--- For turbulent+species simulations the solver Pre-/Postprocessing is done by the species solver. ---*/ if (config->GetKind_Species_Model() == SPECIES_MODEL::NONE && config->GetKind_Trans_Model() == TURB_TRANS_MODEL::NONE) { @@ -182,8 +182,8 @@ void CTurbSolver::LoadRestart(CGeometry** geometry, CSolver*** solver, CConfig* for (auto iMesh = 1u; iMesh <= config->GetnMGLevels(); iMesh++) { MultigridRestriction(*geometry[iMesh - 1], solver[iMesh - 1][TURB_SOL]->GetNodes()->GetSolution(), *geometry[iMesh], solver[iMesh][TURB_SOL]->GetNodes()->GetSolution()); - solver[iMesh][TURB_SOL]->InitiateComms(geometry[iMesh], config, SOLUTION); - solver[iMesh][TURB_SOL]->CompleteComms(geometry[iMesh], config, SOLUTION); + solver[iMesh][TURB_SOL]->InitiateComms(geometry[iMesh], config, MPI_QUANTITIES::SOLUTION); + solver[iMesh][TURB_SOL]->CompleteComms(geometry[iMesh], config, MPI_QUANTITIES::SOLUTION); if (config->GetKind_Species_Model() == SPECIES_MODEL::NONE) { solver[iMesh][FLOW_SOL]->Preprocessing(geometry[iMesh], solver[iMesh], config, iMesh, NO_RK_ITER, RUNTIME_FLOW_SYS, diff --git a/UnitTests/SU2_CFD/gradients.cpp b/UnitTests/SU2_CFD/gradients.cpp index e0829ce1104..2f69d407d3a 100644 --- a/UnitTests/SU2_CFD/gradients.cpp +++ b/UnitTests/SU2_CFD/gradients.cpp @@ -132,8 +132,8 @@ void testGreenGauss() { TestField field; C3DDoubleMatrix gradient(field.geometry->GetnPoint(), field.nVar, field.geometry->GetnDim()); - computeGradientsGreenGauss(nullptr, SOLUTION, PERIODIC_NONE, *field.geometry.get(), *field.config.get(), field, 0, - field.nVar, gradient); + computeGradientsGreenGauss(nullptr, MPI_QUANTITIES::SOLUTION, PERIODIC_NONE, *field.geometry.get(), + *field.config.get(), field, 0, field.nVar, gradient); check(field, gradient); } @@ -144,8 +144,8 @@ void testLeastSquares(bool weighted) { C3DDoubleMatrix R(field.geometry->GetnPoint(), nDim, nDim); C3DDoubleMatrix gradient(field.geometry->GetnPoint(), field.nVar, nDim); - computeGradientsLeastSquares(nullptr, SOLUTION, PERIODIC_NONE, *field.geometry.get(), *field.config.get(), weighted, - field, 0, field.nVar, gradient, R); + computeGradientsLeastSquares(nullptr, MPI_QUANTITIES::SOLUTION, PERIODIC_NONE, *field.geometry.get(), + *field.config.get(), weighted, field, 0, field.nVar, gradient, R); check(field, gradient); } From 9828047a687a57bce6e9b2a24f2afc9582d57287 Mon Sep 17 00:00:00 2001 From: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> Date: Tue, 14 May 2024 06:46:01 -0700 Subject: [PATCH 59/60] =?UTF-8?q?Revert=20"Using=20free=20stream=20tremper?= =?UTF-8?q?ature=20for=20initialization=20of=20wall=20temperature=E2=80=A6?= =?UTF-8?q?"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit ca12a5cb5abc13861af626e3964c56be4cc12fbd. --- Common/src/CConfig.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index bf6d1e66b43..63810ab3e03 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -9234,8 +9234,7 @@ su2double CConfig::GetIsothermal_Temperature(const string& val_marker) const { if (Marker_Isothermal[iMarker_Isothermal] == val_marker) return Isothermal_Temperature[iMarker_Isothermal]; - // Return free-stream temperature for pure CHT cases. - return Temperature_FreeStream; + return Isothermal_Temperature[0]; } su2double CConfig::GetWall_HeatFlux(const string& val_marker) const { From c0324a453a2872f49e5d193b610ee52ff1a185cc Mon Sep 17 00:00:00 2001 From: Cristopher Morales <98025159+Cristopher-Morales@users.noreply.github.com> Date: Sat, 18 May 2024 09:33:14 +0200 Subject: [PATCH 60/60] Fix CHT boundary problem for flamelet computations (#2283) * changing CHT_WALL_INTERFACE --- SU2_CFD/src/integration/CIntegration.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/SU2_CFD/src/integration/CIntegration.cpp b/SU2_CFD/src/integration/CIntegration.cpp index 87e34cd1c8a..f53d50639cc 100644 --- a/SU2_CFD/src/integration/CIntegration.cpp +++ b/SU2_CFD/src/integration/CIntegration.cpp @@ -171,14 +171,13 @@ void CIntegration::Space_Integration(CGeometry *geometry, break; case CHT_WALL_INTERFACE: - if ( MainSolver == FLOW_SOL && (config->GetKind_FluidModel() == FLUID_FLAMELET) ){ - solver_container[MainSolver]->BC_Isothermal_Wall(geometry, solver_container, conv_bound_numerics, visc_bound_numerics, config, iMarker); - break; - } - if ((MainSolver == SPECIES_SOL) || (MainSolver == HEAT_SOL) || ((MainSolver == FLOW_SOL) && ((config->GetKind_Regime() == ENUM_REGIME::COMPRESSIBLE) || config->GetEnergy_Equation()))) { - solver_container[MainSolver]->BC_ConjugateHeat_Interface(geometry, solver_container, conv_bound_numerics, config, iMarker); - } - else { + if ((MainSolver == FLOW_SOL && (config->GetKind_FluidModel() == FLUID_FLAMELET)) || + (MainSolver == SPECIES_SOL) || (MainSolver == HEAT_SOL) || + ((MainSolver == FLOW_SOL) && + ((config->GetKind_Regime() == ENUM_REGIME::COMPRESSIBLE) || config->GetEnergy_Equation()))) { + solver_container[MainSolver]->BC_ConjugateHeat_Interface(geometry, solver_container, conv_bound_numerics, + config, iMarker); + } else { solver_container[MainSolver]->BC_HeatFlux_Wall(geometry, solver_container, conv_bound_numerics, visc_bound_numerics, config, iMarker); } break;