From 0abc3f9f68aaf79cb404b42f8c73e7774f554dd5 Mon Sep 17 00:00:00 2001 From: Christoph Lehmann Date: Thu, 2 Feb 2023 13:49:09 +0100 Subject: [PATCH 01/11] [PL/TRM] Removed unnecessary includes --- .../ThermoRichardsMechanicsFEM-impl.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ProcessLib/ThermoRichardsMechanics/ThermoRichardsMechanicsFEM-impl.h b/ProcessLib/ThermoRichardsMechanics/ThermoRichardsMechanicsFEM-impl.h index 6a4b784b066..7dfd91feb58 100644 --- a/ProcessLib/ThermoRichardsMechanics/ThermoRichardsMechanicsFEM-impl.h +++ b/ProcessLib/ThermoRichardsMechanics/ThermoRichardsMechanicsFEM-impl.h @@ -17,17 +17,12 @@ #include #include "MaterialLib/MPL/Medium.h" -#include "MaterialLib/MPL/Utils/FormEigenTensor.h" -#include "MaterialLib/MPL/Utils/GetLiquidThermalExpansivity.h" -#include "MaterialLib/PhysicalConstant.h" #include "MathLib/KelvinVector.h" #include "NumLib/Fem/Interpolation.h" #include "ProcessLib/Deformation/LinearBMatrix.h" #include "ProcessLib/Graph/Get.h" #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/LiquidDensity.h" #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/LiquidViscosity.h" -#include "ProcessLib/Utils/SetOrGetIntegrationPointData.h" -#include "ProcessLib/Utils/TransposeInPlace.h" #include "ThermoRichardsMechanicsFEM.h" namespace ProcessLib From ef32d3aa7034295805129800b069d203b4fa7df1 Mon Sep 17 00:00:00 2001 From: Christoph Lehmann Date: Mon, 13 Feb 2023 11:14:54 +0100 Subject: [PATCH 02/11] [PL/TRM] Using tuples for constitutive models --- .../ConstitutiveModels.h | 93 ++++++++++------ .../ConstitutiveSetting.cpp | 59 ++++++---- .../Traits.h | 11 ++ .../ConstitutiveModels.h | 104 +++++++++++------- .../ConstitutiveSetting.cpp | 77 ++++++++----- .../Traits.h | 10 ++ .../ThermoRichardsMechanicsFEM-impl.h | 22 ++-- 7 files changed, 239 insertions(+), 137 deletions(-) diff --git a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveModels.h b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveModels.h index 15c18004bc8..49c65fa0e4b 100644 --- a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveModels.h +++ b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveModels.h @@ -29,43 +29,64 @@ namespace ConstitutiveStressSaturation_StrainPressureTemperature { /// Constitutive models used for assembly. template -struct ConstitutiveModels +using ConstitutiveModels = std::tuple< + BiotModel, + SolidMechanicsModel, + SolidCompressibilityModel>, + BishopsModel, + BishopsPrevModel, + PorosityModel, + + LiquidDensityModel, + SolidDensityModel, + GravityModel, + LiquidViscosityModel, + TransportPorosityModel, + PermeabilityModel, + ThermoOsmosisModel, + DarcyLawModel, + TRMHeatStorageAndFluxModel, + TRMVaporDiffusionModel, + + SolidThermalExpansionModel, + FluidThermalExpansionModel, + TRMStorageModel, + EqPModel, + EqTModel>; + +template +ConstitutiveModels createConstitutiveModels( + TRMProcessData const& process_data, + SolidConstitutiveRelation const& solid_material) { - template - explicit ConstitutiveModels( - TRMProcessData const& process_data, - SolidConstitutiveRelation const& solid_material) - : solid_compressibility_model(solid_material), - s_mech_model(solid_material), - grav_model(process_data.specific_body_force), - darcy_model(process_data.specific_body_force), - eq_p_model(process_data.specific_body_force) - { - } + return { + {}, + SolidMechanicsModel{solid_material}, + SolidCompressibilityModel>{ + solid_material}, + {}, + {}, + {}, + + {}, + {}, + GravityModel{process_data.specific_body_force}, + {}, + {}, + {}, + {}, + DarcyLawModel{process_data.specific_body_force}, + {}, + {}, + + {}, + {}, + {}, + EqPModel{process_data.specific_body_force}, + {}}; +} - BiotModel biot_model; - SolidCompressibilityModel> - solid_compressibility_model; - BishopsModel bishops_model; - BishopsPrevModel bishops_prev_model; - PorosityModel poro_model; - TransportPorosityModel transport_poro_model; - SolidThermalExpansionModel s_therm_exp_model; - SolidMechanicsModel s_mech_model; - LiquidDensityModel rho_L_model; - SolidDensityModel rho_S_model; - GravityModel grav_model; - LiquidViscosityModel mu_L_model; - PermeabilityModel perm_model; - DarcyLawModel darcy_model; - TRMHeatStorageAndFluxModel heat_storage_and_flux_model; - TRMVaporDiffusionModel vapor_diffusion_model; - FluidThermalExpansionModel f_therm_exp_model; - TRMStorageModel storage_model; - EqPModel eq_p_model; - EqTModel eq_T_model; - ThermoOsmosisModel th_osmosis_model; -}; } // namespace ConstitutiveStressSaturation_StrainPressureTemperature } // namespace ProcessLib::ThermoRichardsMechanics diff --git a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveSetting.cpp b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveSetting.cpp index 825a519323b..0cde8d5a7ba 100644 --- a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveSetting.cpp +++ b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveSetting.cpp @@ -32,6 +32,7 @@ void ConstitutiveSetting::eval( ConstitutiveData& cd) const { namespace G = ProcessLib::Graph; + constexpr auto D = DisplacementDim; auto const aux_data = std::tuple{SpaceTimeData{x_position, t, dt}, MediaData{medium}, T_data, p_cap_data}; @@ -40,19 +41,23 @@ void ConstitutiveSetting::eval( // TODO will eps lag one iteration behind? (since it's not updated after // solving the global equation system) - std::get>(state).eps.noalias() = eps_arg; + std::get>(state).eps.noalias() = eps_arg; - G::eval(models.biot_model, aux_data, tmp); + G::eval(std::get(models), aux_data, tmp); - G::eval(models.s_mech_model, aux_data, tmp, state, prev_state, - mat_state_tuple, cd); + G::eval(std::get>(models), aux_data, tmp, state, + prev_state, mat_state_tuple, cd); - G::eval(models.solid_compressibility_model, aux_data, tmp, cd); + G::eval( + std::get>>( + models), + aux_data, tmp, cd); - G::eval(models.bishops_model, aux_data, state, tmp); + G::eval(std::get(models), aux_data, state, tmp); // TODO why not ordinary state tracking? - G::eval(models.bishops_prev_model, aux_data, prev_state, tmp); - G::eval(models.poro_model, aux_data, tmp, state, prev_state); + G::eval(std::get(models), aux_data, prev_state, tmp); + G::eval(std::get>(models), aux_data, tmp, state, + prev_state); // TODO move to local assembler? { @@ -69,26 +74,32 @@ void ConstitutiveSetting::eval( } } - G::eval(models.rho_L_model, aux_data, out); - G::eval(models.rho_S_model, aux_data, state, out); - G::eval(models.grav_model, state, out, tmp, cd); - G::eval(models.mu_L_model, aux_data, out); - G::eval(models.transport_poro_model, aux_data, tmp, state, prev_state); - G::eval(models.perm_model, aux_data, state, out, cd, tmp); - G::eval(models.th_osmosis_model, aux_data, out, cd); - G::eval(models.darcy_model, aux_data, out, tmp, cd); - G::eval(models.heat_storage_and_flux_model, aux_data, out, state, tmp, cd); - G::eval(models.vapor_diffusion_model, aux_data, out, state, tmp, cd); + G::eval(std::get>(models), aux_data, out); + G::eval(std::get>(models), aux_data, state, out); + G::eval(std::get>(models), state, out, tmp, cd); + G::eval(std::get>(models), aux_data, out); + G::eval(std::get>(models), aux_data, tmp, state, + prev_state); + G::eval(std::get>(models), aux_data, state, out, cd, + tmp); + G::eval(std::get>(models), aux_data, out, cd); + G::eval(std::get>(models), aux_data, out, tmp, cd); + G::eval(std::get>(models), aux_data, out, + state, tmp, cd); + G::eval(std::get>(models), aux_data, out, state, + tmp, cd); // TODO Not needed for solid mechanics (solid thermal expansion is computed // by the solid material model), but for fluid expansion. This duplication // should be avoided in the future. - G::eval(models.s_therm_exp_model, aux_data, tmp); - - G::eval(models.f_therm_exp_model, aux_data, tmp, state, out); - G::eval(models.storage_model, aux_data, tmp, state, out, prev_state, cd); - G::eval(models.eq_p_model, aux_data, state, tmp, out, cd); - G::eval(models.eq_T_model, cd); + G::eval(std::get>(models), aux_data, tmp); + + G::eval(std::get>(models), aux_data, tmp, + state, out); + G::eval(std::get>(models), aux_data, tmp, state, out, + prev_state, cd); + G::eval(std::get>(models), aux_data, state, tmp, out, cd); + G::eval(std::get>(models), cd); } template struct ConstitutiveSetting<2>; diff --git a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/Traits.h b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/Traits.h index 9c998234460..7f6f000adf8 100644 --- a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/Traits.h +++ b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/Traits.h @@ -48,6 +48,17 @@ struct ConstitutiveTraits ConstitutiveStressSaturation_StrainPressureTemperature:: ConstitutiveModels; + template + static ConstitutiveModels createConstitutiveModels( + TRMProcessData const& process_data, + SolidConstitutiveRelation const& solid_material) + { + return ProcessLib::ThermoRichardsMechanics:: + ConstitutiveStressSaturation_StrainPressureTemperature:: + createConstitutiveModels(process_data, + solid_material); + } + using ConstitutiveSetting = ProcessLib::ThermoRichardsMechanics:: ConstitutiveStressSaturation_StrainPressureTemperature:: ConstitutiveSetting; diff --git a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveModels.h b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveModels.h index efe065b04f8..52e970cf195 100644 --- a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveModels.h +++ b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveModels.h @@ -31,48 +31,70 @@ namespace ConstitutiveStress_StrainTemperature { /// Constitutive models used for assembly. template -struct ConstitutiveModels +using ConstitutiveModels = std::tuple< + ElasticTangentStiffnessModel, + BiotModel, + SolidCompressibilityModel>, + SaturationModel, + BishopsModel, + BishopsPrevModel, + PorosityModel, + + SwellingModel, + SolidThermalExpansionModel, + SolidMechanicsModel, + LiquidDensityModel, + + SolidDensityModel, + GravityModel, + LiquidViscosityModel, + TransportPorosityModel, + PermeabilityModel, + ThermoOsmosisModel, + DarcyLawModel, + TRMHeatStorageAndFluxModel, + TRMVaporDiffusionModel, + FluidThermalExpansionModel, + TRMStorageModel, + EqPModel, + EqTModel>; + +template +ConstitutiveModels createConstitutiveModels( + TRMProcessData const& process_data, + SolidConstitutiveRelation const& solid_material) { - template - explicit ConstitutiveModels( - TRMProcessData const& process_data, - SolidConstitutiveRelation const& solid_material) - : elastic_tangent_stiffness_model(solid_material), - solid_compressibility_model(solid_material), - s_mech_model(solid_material), - grav_model(process_data.specific_body_force), - darcy_model(process_data.specific_body_force), - eq_p_model(process_data.specific_body_force) - { - } + return { + ElasticTangentStiffnessModel{solid_material}, + {} /* BiotModel */, + SolidCompressibilityModel>{ + solid_material}, + {} /* SaturationModel */, + {} /* BishopsModel */, + {} /* BishopsPrevModel */, + {} /* PorosityModel */, - ElasticTangentStiffnessModel - elastic_tangent_stiffness_model; - BiotModel biot_model; - SolidCompressibilityModel> - solid_compressibility_model; - SaturationModel S_L_model; - BishopsModel bishops_model; - BishopsPrevModel bishops_prev_model; - PorosityModel poro_model; - TransportPorosityModel transport_poro_model; - SwellingModel swelling_model; - SolidThermalExpansionModel s_therm_exp_model; - SolidMechanicsModel s_mech_model; - LiquidDensityModel rho_L_model; - SolidDensityModel rho_S_model; - GravityModel grav_model; - LiquidViscosityModel mu_L_model; - PermeabilityModel perm_model; - DarcyLawModel darcy_model; - TRMHeatStorageAndFluxModel heat_storage_and_flux_model; - TRMVaporDiffusionModel vapor_diffusion_model; - FluidThermalExpansionModel f_therm_exp_model; - TRMStorageModel storage_model; - EqPModel eq_p_model; - EqTModel eq_T_model; - ThermoOsmosisModel th_osmosis_model; -}; + {} /* SwellingModel */, + {} /* SolidThermalExpansionModel */, + SolidMechanicsModel{solid_material}, + {} /* LiquidDensityModel */, + + {} /* SolidDensityModel */, + GravityModel{process_data.specific_body_force}, + {} /* LiquidViscosityModel */, + {} /* TransportPorosityModel */, + {} /* PermeabilityModel */, + {} /* ThermoOsmosisModel */, + DarcyLawModel{process_data.specific_body_force}, + {} /* TRMHeatStorageAndFluxModel */, + {} /* TRMVaporDiffusionModel */, + {} /* FluidThermalExpansionModel */, + {} /* TRMStorageModel */, + EqPModel{process_data.specific_body_force}, + {} /* EqTModel */ + }; +} } // namespace ConstitutiveStress_StrainTemperature } // namespace ProcessLib::ThermoRichardsMechanics diff --git a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveSetting.cpp b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveSetting.cpp index 1468704f950..5dd4952ca65 100644 --- a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveSetting.cpp +++ b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveSetting.cpp @@ -31,7 +31,8 @@ void ConstitutiveSetting::init( // restart. SpaceTimeData const x_t{x_position, t, dt}; ElasticTangentStiffnessData C_el_data; - models.elastic_tangent_stiffness_model.eval(x_t, T_data, C_el_data); + std::get>(models).eval( + x_t, T_data, C_el_data); auto const& eps = std::get>(state).eps; auto const& sigma_sw = @@ -70,15 +71,22 @@ void ConstitutiveSetting::eval( // solving the global equation system) std::get>(state).eps.noalias() = eps_arg; - G::eval(models.elastic_tangent_stiffness_model, aux_data, tmp); - G::eval(models.biot_model, aux_data, tmp); - G::eval(models.solid_compressibility_model, aux_data, tmp); - G::eval(models.S_L_model, aux_data, state, tmp); - - G::eval(models.bishops_model, aux_data, state, tmp); + G::eval(std::get>(models), + aux_data, tmp); + G::eval(std::get(models), aux_data, tmp); + // TODO check if model eval order is still correct under all circumstances! + G::eval(std::get>>( + models), + aux_data, tmp, cd); + G::eval(std::get>(models), aux_data, state, + tmp); + + G::eval(std::get(models), aux_data, state, tmp); // TODO why not ordinary state tracking? - G::eval(models.bishops_prev_model, aux_data, prev_state, tmp); - G::eval(models.poro_model, aux_data, tmp, state, prev_state); + G::eval(std::get(models), aux_data, prev_state, tmp); + G::eval(std::get>(models), aux_data, tmp, + state, prev_state); { auto const& biot_data = std::get(tmp); @@ -94,12 +102,15 @@ void ConstitutiveSetting::eval( } } - G::eval(models.swelling_model, aux_data, state, prev_state, tmp); - G::eval(models.s_therm_exp_model, aux_data, tmp); - G::eval(models.s_mech_model, aux_data, tmp, state, prev_state, - mat_state_tuple, cd); + G::eval(std::get>(models), aux_data, state, + prev_state, tmp); + G::eval(std::get>(models), + aux_data, tmp); + G::eval(std::get>(models), aux_data, + tmp, state, prev_state, mat_state_tuple, cd); - G::eval(models.rho_L_model, aux_data, out); + G::eval(std::get>(models), aux_data, + out); /* { double const p_FR = -bishops_data.chi_S_L * p_cap_data.p_cap; @@ -111,19 +122,31 @@ void ConstitutiveSetting::eval( - phi)); } */ - G::eval(models.rho_S_model, aux_data, state, out); - G::eval(models.grav_model, state, out, tmp, cd); - G::eval(models.mu_L_model, aux_data, out); - G::eval(models.transport_poro_model, aux_data, tmp, state, prev_state); - G::eval(models.perm_model, aux_data, state, out, cd, tmp); - G::eval(models.th_osmosis_model, aux_data, out, cd); - G::eval(models.darcy_model, aux_data, out, tmp, cd); - G::eval(models.heat_storage_and_flux_model, aux_data, out, state, tmp, cd); - G::eval(models.vapor_diffusion_model, aux_data, out, state, tmp, cd); - G::eval(models.f_therm_exp_model, aux_data, tmp, state, out); - G::eval(models.storage_model, aux_data, tmp, state, out, prev_state, cd); - G::eval(models.eq_p_model, aux_data, state, tmp, out, cd); - G::eval(models.eq_T_model, cd); + G::eval(std::get>(models), aux_data, + state, out); + G::eval(std::get>(models), state, out, tmp, + cd); + G::eval(std::get>(models), aux_data, + out); + G::eval(std::get>(models), aux_data, + tmp, state, prev_state); + G::eval(std::get>(models), aux_data, + state, out, cd, tmp); + G::eval(std::get>(models), aux_data, + out, cd); + G::eval(std::get>(models), aux_data, out, + tmp, cd); + G::eval(std::get>(models), + aux_data, out, state, tmp, cd); + G::eval(std::get>(models), aux_data, + out, state, tmp, cd); + G::eval(std::get>(models), + aux_data, tmp, state, out); + G::eval(std::get>(models), aux_data, tmp, + state, out, prev_state, cd); + G::eval(std::get>(models), aux_data, state, tmp, + out, cd); + G::eval(std::get>(models), cd); } template struct ConstitutiveSetting<2>; diff --git a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/Traits.h b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/Traits.h index cabd13eeed6..df46ae7d63e 100644 --- a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/Traits.h +++ b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/Traits.h @@ -44,6 +44,16 @@ struct ConstitutiveTraits ConstitutiveStress_StrainTemperature::ConstitutiveModels< DisplacementDim>; + template + static ConstitutiveModels createConstitutiveModels( + TRMProcessData const& process_data, + SolidConstitutiveRelation const& solid_material) + { + return ProcessLib::ThermoRichardsMechanics:: + ConstitutiveStress_StrainTemperature::createConstitutiveModels< + DisplacementDim>(process_data, solid_material); + } + using ConstitutiveSetting = ProcessLib::ThermoRichardsMechanics:: ConstitutiveStress_StrainTemperature::ConstitutiveSetting< DisplacementDim>; diff --git a/ProcessLib/ThermoRichardsMechanics/ThermoRichardsMechanicsFEM-impl.h b/ProcessLib/ThermoRichardsMechanics/ThermoRichardsMechanicsFEM-impl.h index 7dfd91feb58..f76508b2bc1 100644 --- a/ProcessLib/ThermoRichardsMechanics/ThermoRichardsMechanicsFEM-impl.h +++ b/ProcessLib/ThermoRichardsMechanics/ThermoRichardsMechanicsFEM-impl.h @@ -21,8 +21,12 @@ #include "NumLib/Fem/Interpolation.h" #include "ProcessLib/Deformation/LinearBMatrix.h" #include "ProcessLib/Graph/Get.h" +#include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/EqP.h" +#include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/EqT.h" +#include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/Gravity.h" #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/LiquidDensity.h" #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/LiquidViscosity.h" +#include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/TotalStressData.h" #include "ThermoRichardsMechanicsFEM.h" namespace ProcessLib @@ -99,7 +103,7 @@ void ThermoRichardsMechanicsLocalAssembler< MediaData const media_data{medium}; typename ConstitutiveTraits::ConstitutiveSetting const constitutive_setting; - typename ConstitutiveTraits::ConstitutiveModels models( + auto models = ConstitutiveTraits::createConstitutiveModels( this->process_data_, this->solid_material_); unsigned const n_integration_points = @@ -357,19 +361,19 @@ void ThermoRichardsMechanicsLocalAssembleris_axially_symmetric_); + typename ConstitutiveTraits::ConstitutiveData CD; + auto const [T, p_L, u] = localDOF(local_x); auto const [T_prev, p_L_prev, u_prev] = localDOF(local_x_prev); - GlobalDimVectorType const grad_T_ip = dNdx * T; - - typename ConstitutiveTraits::ConstitutiveModels models( - this->process_data_, this->solid_material_); - typename ConstitutiveTraits::ConstitutiveTempData tmp; - typename ConstitutiveTraits::ConstitutiveData CD; - { + auto models = ConstitutiveTraits::createConstitutiveModels( + this->process_data_, this->solid_material_); + typename ConstitutiveTraits::ConstitutiveTempData tmp; + double const T_ip = N * T; double const T_prev_ip = N * T_prev; + GlobalDimVectorType const grad_T_ip = dNdx * T; double const p_cap_ip = -N * p_L; double const p_cap_prev_ip = -N * p_L_prev; @@ -547,7 +551,7 @@ void ThermoRichardsMechanicsLocalAssemblersolid_material_); typename ConstitutiveTraits::ConstitutiveTempData tmp; typename ConstitutiveTraits::ConstitutiveData CD; From 3bfc6de9cec61c0db808d3794be3865d47fe7b05 Mon Sep 17 00:00:00 2001 From: Christoph Lehmann Date: Tue, 14 May 2024 12:10:15 +0200 Subject: [PATCH 03/11] [PL/G] Extracted metaprogramming functionality --- ProcessLib/Graph/Apply.h | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/ProcessLib/Graph/Apply.h b/ProcessLib/Graph/Apply.h index fb0c1df32f3..af26734a30b 100644 --- a/ProcessLib/Graph/Apply.h +++ b/ProcessLib/Graph/Apply.h @@ -16,34 +16,41 @@ namespace ProcessLib::Graph namespace detail { template -struct GetFunctionArgumentTypesPlain // plain, i.e., without cvref +struct GetFunctionArgumentTypes /** \cond */ - : GetFunctionArgumentTypesPlain + : GetFunctionArgumentTypes /** \endcond */ { }; // member function template -struct GetFunctionArgumentTypesPlain +struct GetFunctionArgumentTypes { - using type = boost::mp11::mp_list...>; + using type = boost::mp11::mp_list; }; // const member function template -struct GetFunctionArgumentTypesPlain +struct GetFunctionArgumentTypes { - using type = boost::mp11::mp_list...>; + using type = boost::mp11::mp_list; }; // standalone function template -struct GetFunctionArgumentTypesPlain +struct GetFunctionArgumentTypes { - using type = boost::mp11::mp_list...>; + using type = boost::mp11::mp_list; }; +// plain, i.e., without cvref +template +using GetFunctionArgumentTypesPlain = + std::type_identity::type>>; + template struct GetFunctionReturnType /** \cond */ From 55399d30a8ad9fc12f3ce5285444d785f2f9a9b4 Mon Sep 17 00:00:00 2001 From: Christoph Lehmann Date: Thu, 16 Feb 2023 22:42:35 +0100 Subject: [PATCH 04/11] [PL/G] Added functionality checking model evaluation order at runtime --- ProcessLib/Graph/CheckEvalOrderRT.h | 136 ++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 ProcessLib/Graph/CheckEvalOrderRT.h diff --git a/ProcessLib/Graph/CheckEvalOrderRT.h b/ProcessLib/Graph/CheckEvalOrderRT.h new file mode 100644 index 00000000000..d34c9cd3340 --- /dev/null +++ b/ProcessLib/Graph/CheckEvalOrderRT.h @@ -0,0 +1,136 @@ +/** + * \file + * \copyright + * Copyright (c) 2012-2024, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#pragma once + +#include +#include +#include + +#include "Apply.h" +#include "BaseLib/Logging.h" + +namespace ProcessLib::Graph +{ +namespace detail +{ +template +struct IsInputArgument + : boost::mp11::mp_bool && + std::is_const_v>> +{ + static_assert(std::is_lvalue_reference_v, + "The current implementation only deals with l-value " + "references as function arguments. If you want to extend it, " + "test thoroughly in order to not introduce bugs."); +}; + +template +struct IsOutputArgument : boost::mp11::mp_bool::value> +{ + static_assert(std::is_lvalue_reference_v, + "The current implementation only deals with l-value " + "references as function arguments. If you want to extend it, " + "test thoroughly in order to not introduce bugs."); +}; + +template +bool isEvalOrderCorrectRT(std::unordered_set& computed_data) +{ + using namespace boost::mp11; + + using ModelArgs = + typename GetFunctionArgumentTypes::type; + using ModelInputs = mp_filter; + using ModelOutputs = mp_filter; + + using ModelInputsWrapped = mp_transform; + + // Check that all inputs have already been computed before. + bool all_inputs_computed = true; + mp_for_each( + [&computed_data, + &all_inputs_computed](mp_identity) + { + if (!computed_data.contains(std::type_index{typeid(Input)})) + { + ERR("Input {} of model {} has not been computed/set before the " + "model evaluation.", + typeid(Input).name(), typeid(Model).name()); + all_inputs_computed = false; + } + }); + if (!all_inputs_computed) + { + return false; + } + + using ModelOutputsWrapped = mp_transform; + + // All outputs are "computed data", now. + bool no_output_precomputed = true; + mp_for_each( + [&computed_data, + &no_output_precomputed](mp_identity) + { + auto const [it, emplaced] = computed_data.emplace(typeid(Output)); + + if (!emplaced) + { + ERR("Output {} of model {} is computed more than once.", + typeid(Output).name(), + typeid(Model).name()); + no_output_precomputed = false; + } + }); + + return no_output_precomputed; +} + +template +bool isEvalOrderCorrectRT(boost::mp11::mp_list, + std::unordered_set&& computed_data) +{ + return (isEvalOrderCorrectRT(computed_data) && ...); +} +} // namespace detail + +/// Checks at runtime if the given \c Models are evaluated in the right order if +/// evaluated in the order in which they appear in the list of \c Models. +/// +/// I.e., all input data of a model must have been computed before that model +/// will be evaluated and no two models must compute the same data. +/// +/// The passed \c Inputs are data that already have been computed before the +/// first model is evaluated. +template +bool isEvalOrderCorrectRT() // RT for runtime +{ + using namespace boost::mp11; + + static_assert(mp_is_list::value); + static_assert(mp_is_list::value); + + // Wrap inputs. The elements of InputsWrapped are default constructible. + using InputsWrapped = mp_transform; + + // "Holds" all data that has been computed successively by the invoked + // models. + std::unordered_set computed_data; + + // All inputs are considered "computed data". + mp_for_each( + [&computed_data](mp_identity) + { computed_data.emplace(typeid(Input)); }); + + return detail::isEvalOrderCorrectRT(mp_rename{}, + std::move(computed_data)); +} +} // namespace ProcessLib::Graph From 3889a8c44c71cd1c7911d8479e4b7b3b6f990af8 Mon Sep 17 00:00:00 2001 From: Christoph Lehmann Date: Tue, 14 May 2024 14:23:10 +0200 Subject: [PATCH 05/11] [T] Added unit tests for model eval oder check --- Tests/CMakeLists.txt | 1 + .../ProcessLib/Graph/TestCheckEvalOrderRT.cpp | 164 ++++++++++++++++++ 2 files changed, 165 insertions(+) create mode 100644 Tests/ProcessLib/Graph/TestCheckEvalOrderRT.cpp diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index cfa57f3705d..bb27b9e14a4 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -88,6 +88,7 @@ ogs_add_executable(testrunner ${TEST_SOURCES}) target_sources( testrunner PRIVATE ProcessLib/Graph/TestGet.cpp ProcessLib/Graph/TestApply.cpp + ProcessLib/Graph/TestCheckEvalOrderRT.cpp ) target_link_libraries( diff --git a/Tests/ProcessLib/Graph/TestCheckEvalOrderRT.cpp b/Tests/ProcessLib/Graph/TestCheckEvalOrderRT.cpp new file mode 100644 index 00000000000..f4262c3ac86 --- /dev/null +++ b/Tests/ProcessLib/Graph/TestCheckEvalOrderRT.cpp @@ -0,0 +1,164 @@ +/** + * \file + * \copyright + * Copyright (c) 2012-2024, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#include + +#include "ProcessLib/Graph/CheckEvalOrderRT.h" + +namespace TestCheckEvalOrderRT +{ +struct NoOp +{ + void eval(); +}; + +struct OutD +{ + void eval(double&) {} +}; + +struct InD +{ + void eval(double const&) {} +}; + +struct InSOutD +{ + void eval(double&, std::string const&) {} +}; + +struct OutCD +{ + void eval(double&, char&) {} +}; + +struct InCSOutIU +{ + void eval(char const&, unsigned&, std::string const&, int&); +}; + +struct InIU +{ + void eval(unsigned const&, int const&); +}; +} // namespace TestCheckEvalOrderRT + +TEST(ProcessLib_Graph_CheckEvalOrderRT, Success) +{ + using namespace TestCheckEvalOrderRT; + + { + using Models = std::tuple; + using Inputs = std::tuple<>; + + ASSERT_TRUE( + (ProcessLib::Graph::isEvalOrderCorrectRT())); + } + + { + using Models = std::tuple; + using Inputs = std::tuple<>; + + ASSERT_TRUE( + (ProcessLib::Graph::isEvalOrderCorrectRT())); + } + + { + using Models = std::tuple; + using Inputs = std::tuple; + + ASSERT_TRUE( + (ProcessLib::Graph::isEvalOrderCorrectRT())); + } + + { + using Models = std::tuple; + using Inputs = std::tuple<>; + + ASSERT_TRUE( + (ProcessLib::Graph::isEvalOrderCorrectRT())); + } + + { + using Models = std::tuple; + using Inputs = std::tuple; + + ASSERT_TRUE( + (ProcessLib::Graph::isEvalOrderCorrectRT())); + } + + { + using Models = std::tuple; + using Inputs = std::tuple; + + ASSERT_TRUE( + (ProcessLib::Graph::isEvalOrderCorrectRT())); + } + + { + using Models = std::tuple; + using Inputs = std::tuple; + + ASSERT_TRUE( + (ProcessLib::Graph::isEvalOrderCorrectRT())); + } +} + +TEST(ProcessLib_Graph_CheckEvalOrderRT, Fail) +{ + using namespace TestCheckEvalOrderRT; + + { + using Models = std::tuple; + using Inputs = std::tuple<>; + + ASSERT_FALSE( + (ProcessLib::Graph::isEvalOrderCorrectRT())) + << "Expected to fail since the required double value is not " + "provided as an input."; + } + + { + using Models = std::tuple; + using Inputs = std::tuple<>; + + ASSERT_FALSE( + (ProcessLib::Graph::isEvalOrderCorrectRT())) + << "Expected to fail: double value is consumed before being " + "computed."; + } + + { + using Models = std::tuple; + using Inputs = std::tuple; + + ASSERT_FALSE( + (ProcessLib::Graph::isEvalOrderCorrectRT())) + << "Expected to fail: double value has two producers."; + } + + { + using Models = std::tuple; + using Inputs = std::tuple; + + ASSERT_FALSE( + (ProcessLib::Graph::isEvalOrderCorrectRT())) + << "Expected to fail: wrong evaluation order."; + } + + { + using Models = std::tuple; + using Inputs = std::tuple; + + ASSERT_FALSE( + (ProcessLib::Graph::isEvalOrderCorrectRT())) + << "Expected to fail: double value has two producers."; + } +} From 5d3f5e27856a793e75d4acf93a40dc06a9f57008 Mon Sep 17 00:00:00 2001 From: Christoph Lehmann Date: Tue, 14 May 2024 11:14:50 +0200 Subject: [PATCH 06/11] [PL/TRM] Check model eval order at runtime --- .../ConstitutiveSetting.cpp | 45 +++++++++++++++++++ .../ConstitutiveSetting.h | 4 +- .../ConstitutiveSetting.cpp | 33 ++++++++++++++ 3 files changed, 79 insertions(+), 3 deletions(-) diff --git a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveSetting.cpp b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveSetting.cpp index 0cde8d5a7ba..89ffef0a7d3 100644 --- a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveSetting.cpp +++ b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveSetting.cpp @@ -11,11 +11,56 @@ #include "ConstitutiveSetting.h" #include "ProcessLib/Graph/Apply.h" +#include "ProcessLib/Graph/CheckEvalOrderRT.h" namespace ProcessLib::ThermoRichardsMechanics { namespace ConstitutiveStressSaturation_StrainPressureTemperature { + +template +static bool checkCorrectModelEvalOrder() +{ + INFO( + "Checking correct model evaluation order in the constitutive setting."); + + using namespace boost::mp11; + + constexpr auto D = DisplacementDim; + + using Inputs = + mp_list, + CapillaryPressureData, StrainData + //, MaterialStateData /*TODO material state data is a special + // case: it's both input and output data.*/ + >; + + using InputsAndPrevState = mp_append>; + + bool const is_correct = ProcessLib::Graph::isEvalOrderCorrectRT< + ConstitutiveModels, InputsAndPrevState>(); + + if (!is_correct) + { + OGS_FATAL("The constitutive setting has a wrong evaluation order."); + } + + INFO("Model evaluation order is correct."); + + return is_correct; +} + +template +void ConstitutiveSetting::init( + ConstitutiveModels&, double const /*t*/, + double const /*dt*/, ParameterLib::SpatialPosition const&, MediaData const&, + TemperatureData const&, StatefulData&, + StatefulDataPrev&) const +{ + [[maybe_unused]] static const bool model_order_correct = + checkCorrectModelEvalOrder(); +} + template void ConstitutiveSetting::eval( ConstitutiveModels& models, double const t, diff --git a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveSetting.h b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveSetting.h index b992057f511..88c6e9bfe8e 100644 --- a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveSetting.h +++ b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveSetting.h @@ -24,9 +24,7 @@ struct ConstitutiveSetting double const /*dt*/, ParameterLib::SpatialPosition const&, MediaData const&, TemperatureData const&, StatefulData&, - StatefulDataPrev&) const - { - } + StatefulDataPrev&) const; /// Evaluate the constitutive setting. void eval(ConstitutiveModels& models, double const t, diff --git a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveSetting.cpp b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveSetting.cpp index 5dd4952ca65..ea77471a7e5 100644 --- a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveSetting.cpp +++ b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveSetting.cpp @@ -14,11 +14,41 @@ #include "MaterialLib/MPL/PropertyType.h" #include "ProcessLib/Graph/Apply.h" +#include "ProcessLib/Graph/CheckEvalOrderRT.h" namespace ProcessLib::ThermoRichardsMechanics { namespace ConstitutiveStress_StrainTemperature { + +template +static bool checkCorrectModelEvalOrder() +{ + INFO( + "Checking correct model evaluation order in the constitutive setting."); + + using namespace boost::mp11; + + constexpr auto D = DisplacementDim; + + using Inputs = mp_list, + CapillaryPressureData, StrainData>; + + using InputsAndPrevState = mp_append>; + + bool const is_correct = ProcessLib::Graph::isEvalOrderCorrectRT< + ConstitutiveModels, InputsAndPrevState>(); + + if (!is_correct) + { + OGS_FATAL("The constitutive setting has a wrong evaluation order."); + } + + INFO("Model evaluation order is correct."); + + return is_correct; +} + template void ConstitutiveSetting::init( ConstitutiveModels& models, double const t, @@ -27,6 +57,9 @@ void ConstitutiveSetting::init( StatefulData& state, StatefulDataPrev& prev_state) const { + [[maybe_unused]] static const bool model_order_correct = + checkCorrectModelEvalOrder(); + // Set eps_m_prev from potentially non-zero eps and sigma_sw from // restart. SpaceTimeData const x_t{x_position, t, dt}; From 1c45560413876e67af47ea7f4b1c96d6c8b3f546 Mon Sep 17 00:00:00 2001 From: Christoph Lehmann Date: Mon, 20 Feb 2023 22:26:29 +0100 Subject: [PATCH 07/11] [PL] Automatic evaluation of constitutive models --- ProcessLib/Graph/Apply.h | 15 ++++ .../ConstitutiveSetting.cpp | 53 ++------------ .../ConstitutiveSetting.cpp | 69 ++----------------- 3 files changed, 26 insertions(+), 111 deletions(-) diff --git a/ProcessLib/Graph/Apply.h b/ProcessLib/Graph/Apply.h index af26734a30b..8f9562993af 100644 --- a/ProcessLib/Graph/Apply.h +++ b/ProcessLib/Graph/Apply.h @@ -280,4 +280,19 @@ auto eval(Function& f, Tuples&... ts) -> return detail::applyImpl(&Function::eval, f, ts...); } + +/** + * Invokes the eval() method of the passed objects \c fs with arguments taken + * from the passed tuples. + * + * \c fs must be a tuple of objects having an eval() method. The method + * invocation proceeds in the order of the objects in the tuple. + * + * \see eval() + */ +template +void evalAllInOrder(Functions& fs, Tuples&... ts) +{ + boost::mp11::tuple_for_each(fs, [&ts...](auto& f) { eval(f, ts...); }); +} } // namespace ProcessLib::Graph diff --git a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveSetting.cpp b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveSetting.cpp index 89ffef0a7d3..8b80974cc48 100644 --- a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveSetting.cpp +++ b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveSetting.cpp @@ -17,7 +17,6 @@ namespace ProcessLib::ThermoRichardsMechanics { namespace ConstitutiveStressSaturation_StrainPressureTemperature { - template static bool checkCorrectModelEvalOrder() { @@ -76,9 +75,6 @@ void ConstitutiveSetting::eval( OutputData& out, ConstitutiveData& cd) const { - namespace G = ProcessLib::Graph; - constexpr auto D = DisplacementDim; - auto const aux_data = std::tuple{SpaceTimeData{x_position, t, dt}, MediaData{medium}, T_data, p_cap_data}; @@ -86,25 +82,13 @@ void ConstitutiveSetting::eval( // TODO will eps lag one iteration behind? (since it's not updated after // solving the global equation system) - std::get>(state).eps.noalias() = eps_arg; - - G::eval(std::get(models), aux_data, tmp); - - G::eval(std::get>(models), aux_data, tmp, state, - prev_state, mat_state_tuple, cd); + std::get>(state).eps.noalias() = eps_arg; - G::eval( - std::get>>( - models), - aux_data, tmp, cd); + ProcessLib::Graph::evalAllInOrder(models, aux_data, cd, mat_state_tuple, + out, prev_state, state, tmp); - G::eval(std::get(models), aux_data, state, tmp); - // TODO why not ordinary state tracking? - G::eval(std::get(models), aux_data, prev_state, tmp); - G::eval(std::get>(models), aux_data, tmp, state, - prev_state); + // TODO why not ordinary state tracking for BishopsPrevModel? - // TODO move to local assembler? { auto const& biot_data = std::get(tmp); auto const& poro_data = std::get(state); @@ -119,32 +103,9 @@ void ConstitutiveSetting::eval( } } - G::eval(std::get>(models), aux_data, out); - G::eval(std::get>(models), aux_data, state, out); - G::eval(std::get>(models), state, out, tmp, cd); - G::eval(std::get>(models), aux_data, out); - G::eval(std::get>(models), aux_data, tmp, state, - prev_state); - G::eval(std::get>(models), aux_data, state, out, cd, - tmp); - G::eval(std::get>(models), aux_data, out, cd); - G::eval(std::get>(models), aux_data, out, tmp, cd); - G::eval(std::get>(models), aux_data, out, - state, tmp, cd); - G::eval(std::get>(models), aux_data, out, state, - tmp, cd); - - // TODO Not needed for solid mechanics (solid thermal expansion is computed - // by the solid material model), but for fluid expansion. This duplication - // should be avoided in the future. - G::eval(std::get>(models), aux_data, tmp); - - G::eval(std::get>(models), aux_data, tmp, - state, out); - G::eval(std::get>(models), aux_data, tmp, state, out, - prev_state, cd); - G::eval(std::get>(models), aux_data, state, tmp, out, cd); - G::eval(std::get>(models), cd); + // TODO Solid thermal expansion is not needed for solid mechanics (it is + // computed by the solid material model itself), but for fluid expansion. + // This duplication should be avoided in the future. } template struct ConstitutiveSetting<2>; diff --git a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveSetting.cpp b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveSetting.cpp index ea77471a7e5..c70df0f4760 100644 --- a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveSetting.cpp +++ b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveSetting.cpp @@ -20,7 +20,6 @@ namespace ProcessLib::ThermoRichardsMechanics { namespace ConstitutiveStress_StrainTemperature { - template static bool checkCorrectModelEvalOrder() { @@ -93,8 +92,6 @@ void ConstitutiveSetting::eval( OutputData& out, ConstitutiveData& cd) const { - namespace G = ProcessLib::Graph; - auto const aux_data = std::tuple{SpaceTimeData{x_position, t, dt}, MediaData{medium}, T_data, p_cap_data}; @@ -104,22 +101,10 @@ void ConstitutiveSetting::eval( // solving the global equation system) std::get>(state).eps.noalias() = eps_arg; - G::eval(std::get>(models), - aux_data, tmp); - G::eval(std::get(models), aux_data, tmp); - // TODO check if model eval order is still correct under all circumstances! - G::eval(std::get>>( - models), - aux_data, tmp, cd); - G::eval(std::get>(models), aux_data, state, - tmp); - - G::eval(std::get(models), aux_data, state, tmp); - // TODO why not ordinary state tracking? - G::eval(std::get(models), aux_data, prev_state, tmp); - G::eval(std::get>(models), aux_data, tmp, - state, prev_state); + ProcessLib::Graph::evalAllInOrder(models, aux_data, cd, mat_state_tuple, + out, prev_state, state, tmp); + + // TODO why not ordinary state tracking for BishopsPrevModel? { auto const& biot_data = std::get(tmp); @@ -134,52 +119,6 @@ void ConstitutiveSetting::eval( *x_position.getIntegrationPoint()); } } - - G::eval(std::get>(models), aux_data, state, - prev_state, tmp); - G::eval(std::get>(models), - aux_data, tmp); - G::eval(std::get>(models), aux_data, - tmp, state, prev_state, mat_state_tuple, cd); - - G::eval(std::get>(models), aux_data, - out); - - /* { - double const p_FR = -bishops_data.chi_S_L * p_cap_data.p_cap; - // p_SR - // TODO used by no MPL model - variables.solid_grain_pressure = - p_FR - - Invariants::trace(std::get(state).sigma_eff) / (3 * (1 - - phi)); - } */ - - G::eval(std::get>(models), aux_data, - state, out); - G::eval(std::get>(models), state, out, tmp, - cd); - G::eval(std::get>(models), aux_data, - out); - G::eval(std::get>(models), aux_data, - tmp, state, prev_state); - G::eval(std::get>(models), aux_data, - state, out, cd, tmp); - G::eval(std::get>(models), aux_data, - out, cd); - G::eval(std::get>(models), aux_data, out, - tmp, cd); - G::eval(std::get>(models), - aux_data, out, state, tmp, cd); - G::eval(std::get>(models), aux_data, - out, state, tmp, cd); - G::eval(std::get>(models), - aux_data, tmp, state, out); - G::eval(std::get>(models), aux_data, tmp, - state, out, prev_state, cd); - G::eval(std::get>(models), aux_data, state, tmp, - out, cd); - G::eval(std::get>(models), cd); } template struct ConstitutiveSetting<2>; From ac2a6f3605d6ec2b1f14254a5f3538fbb667e517 Mon Sep 17 00:00:00 2001 From: Christoph Lehmann Date: Thu, 23 Feb 2023 20:10:29 +0100 Subject: [PATCH 08/11] [PL/TRM] Removed obsolete type alias --- .../ConstitutiveStress_StrainTemperature/Traits.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/Traits.h b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/Traits.h index df46ae7d63e..80fd219a590 100644 --- a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/Traits.h +++ b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/Traits.h @@ -57,10 +57,6 @@ struct ConstitutiveTraits using ConstitutiveSetting = ProcessLib::ThermoRichardsMechanics:: ConstitutiveStress_StrainTemperature::ConstitutiveSetting< DisplacementDim>; - - using ElasticTangentStiffnessModel = ProcessLib::ThermoRichardsMechanics:: - ConstitutiveStress_StrainTemperature::ElasticTangentStiffnessModel< - DisplacementDim>; }; } // namespace ConstitutiveStress_StrainTemperature } // namespace ProcessLib::ThermoRichardsMechanics From fdf9b28838300ada63ae3fafb4a22cbde3202f54 Mon Sep 17 00:00:00 2001 From: Christoph Lehmann Date: Thu, 23 Feb 2023 22:12:05 +0100 Subject: [PATCH 09/11] [PL] Construct a tuple of models --- ProcessLib/Graph/ConstructModels.h | 75 ++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 ProcessLib/Graph/ConstructModels.h diff --git a/ProcessLib/Graph/ConstructModels.h b/ProcessLib/Graph/ConstructModels.h new file mode 100644 index 00000000000..7f5c01105af --- /dev/null +++ b/ProcessLib/Graph/ConstructModels.h @@ -0,0 +1,75 @@ +/** + * \file + * \copyright + * Copyright (c) 2012-2024, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#pragma once + +#include +#include + +#include "Apply.h" + +namespace ProcessLib::Graph +{ +namespace detail +{ +template +concept HasCreate = requires +{ + T::create; +}; + +template +Model constructModel(TupleOfArgs& args) +{ + if constexpr (HasCreate) + { + return applyImpl(&Model::create, args); + } + else if constexpr (std::is_default_constructible_v) + { + return Model{}; + } + else + { + static_assert(std::is_default_constructible_v< + Model> /* This is definitely false, here. */, + "The model to be constructed has neither a static " + "create() function nor is it default constructible."); + } +} +template