diff --git a/ProcessLib/ConstitutiveRelations/Base.h b/ProcessLib/ConstitutiveRelations/Base.h index 41a1c18c2de..0f3bec16446 100644 --- a/ProcessLib/ConstitutiveRelations/Base.h +++ b/ProcessLib/ConstitutiveRelations/Base.h @@ -9,6 +9,8 @@ #pragma once +#include + #include "ParameterLib/SpatialPosition.h" namespace ProcessLib::ConstitutiveRelations @@ -43,6 +45,30 @@ struct PrevState T t; }; +//! Applies PrevState to a tuple of constitutive data. +template +using PrevStateOf = boost::mp11::mp_transform; + +namespace detail +{ +template +void assign(std::tuple...>& prev_states, + std::tuple const& current_states, + std::index_sequence) +{ + ((std::get(prev_states) = std::get(current_states)), ...); +} +} // namespace detail + +//! Assigns a tuple of current states to a tuple of previous states. +template +void assign(std::tuple...>& prev_states, + std::tuple const& current_states) +{ + detail::assign(prev_states, current_states, + std::make_index_sequence{}); +} + struct SpaceTimeData { ParameterLib::SpatialPosition x; diff --git a/ProcessLib/Graph/Get.h b/ProcessLib/Graph/Get.h index 4cf5c0c5172..574ecf132c7 100644 --- a/ProcessLib/Graph/Get.h +++ b/ProcessLib/Graph/Get.h @@ -9,7 +9,7 @@ #pragma once -#include "boost/mp11.hpp" +#include namespace ProcessLib::Graph { diff --git a/ProcessLib/Reflection/ReflectionIPData.h b/ProcessLib/Reflection/ReflectionIPData.h index 610b679283e..3b73767d2a7 100644 --- a/ProcessLib/Reflection/ReflectionIPData.h +++ b/ProcessLib/Reflection/ReflectionIPData.h @@ -76,6 +76,9 @@ struct is_raw_data> { }; +template +constexpr bool is_raw_data_v = is_raw_data::value; + template struct NumberOfRows; diff --git a/ProcessLib/Reflection/ReflectionSetIPData.h b/ProcessLib/Reflection/ReflectionSetIPData.h index 27f72d47045..1e4712ffb69 100644 --- a/ProcessLib/Reflection/ReflectionSetIPData.h +++ b/ProcessLib/Reflection/ReflectionSetIPData.h @@ -28,7 +28,7 @@ void setIPData(double const* values, using AccessorResult = std::invoke_result_t; using AccessorResultStripped = std::remove_cvref_t; - static_assert(is_raw_data::value, + static_assert(is_raw_data_v, "This method only deals with raw data. The given " "AccessorResultStripped is not raw data."); @@ -112,7 +112,7 @@ bool setIPDataIfNameMatches(std::string_view const name, double const* values, } else { - static_assert(detail::is_raw_data::value, + static_assert(detail::is_raw_data_v, "The current member is not reflectable, so we " "expect it to be raw data."); diff --git a/ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/Bishops.cpp b/ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/Bishops.cpp index 69d495f3852..b416370aedd 100644 --- a/ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/Bishops.cpp +++ b/ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/Bishops.cpp @@ -12,8 +12,10 @@ namespace ProcessLib::ThermoRichardsMechanics { -void BishopsModel::eval(SpaceTimeData const& x_t, MediaData const& media_data, - SaturationData const& S_L_data, BishopsData& out) const +static void bishopsModelEvalImpl(SpaceTimeData const& x_t, + MediaData const& media_data, + SaturationData const& S_L_data, + BishopsData& out) { namespace MPL = MaterialPropertyLib; MPL::VariableArray variables; @@ -29,4 +31,18 @@ void BishopsModel::eval(SpaceTimeData const& x_t, MediaData const& media_data, variables, MPL::Variable::liquid_saturation, x_t.x, x_t.t, x_t.dt); } + +void BishopsModel::eval(SpaceTimeData const& x_t, MediaData const& media_data, + SaturationData const& S_L_data, BishopsData& out) const +{ + bishopsModelEvalImpl(x_t, media_data, S_L_data, out); +} + +void BishopsPrevModel::eval(SpaceTimeData const& x_t, + MediaData const& media_data, + PrevState const& S_L_data, + PrevState& out) const +{ + bishopsModelEvalImpl(x_t, media_data, *S_L_data, *out); +} } // namespace ProcessLib::ThermoRichardsMechanics diff --git a/ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/Bishops.h b/ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/Bishops.h index 103c3d94b48..7ec060f7b54 100644 --- a/ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/Bishops.h +++ b/ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/Bishops.h @@ -26,4 +26,11 @@ struct BishopsModel void eval(SpaceTimeData const& x_t, MediaData const& media_data, SaturationData const& S_L_data, BishopsData& out) const; }; + +struct BishopsPrevModel +{ + void eval(SpaceTimeData const& x_t, MediaData const& media_data, + PrevState const& S_L_data, + PrevState& out) const; +}; } // namespace ProcessLib::ThermoRichardsMechanics diff --git a/ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/Invoke.h b/ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/Invoke.h deleted file mode 100644 index ea8e0ae2180..00000000000 --- a/ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/Invoke.h +++ /dev/null @@ -1,55 +0,0 @@ -/** - * \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 - -namespace ProcessLib::ThermoRichardsMechanics -{ -namespace detail -{ -template -constexpr bool areEvalArgumentTypesUnique(Result (Class::*)(Args...)) -{ - using namespace boost::mp11; - return mp_is_set< - mp_transform>>::value; -} - -template -constexpr bool areEvalArgumentTypesUnique(Result (Class::*)(Args...) const) -{ - using namespace boost::mp11; - return mp_is_set< - mp_transform>>::value; -} -} // namespace detail - -/// Checks whether the argument types of the eval() method of the given type T -/// are unique. -/// -/// Argument types differing only in constness, reference or volatility are -/// considered equal. -template -constexpr bool areEvalArgumentTypesUnique() -{ - return detail::areEvalArgumentTypesUnique(&T::eval); -} - -/// Statically asserts that the argument types of the passed Model's eval() -/// method are unique. -template -constexpr void assertEvalArgsUnique(Model const&) -{ - static_assert(areEvalArgumentTypesUnique>()); -} - -} // namespace ProcessLib::ThermoRichardsMechanics diff --git a/ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/MechanicalStrainData.h b/ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/MechanicalStrainData.h new file mode 100644 index 00000000000..7cf605d9f3a --- /dev/null +++ b/ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/MechanicalStrainData.h @@ -0,0 +1,30 @@ +/** + * \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 "Base.h" + +namespace ProcessLib::ThermoRichardsMechanics +{ +template +struct MechanicalStrainData +{ + // TODO it seems fragile that some data have to be initialized that way. + KelvinVector eps_m = KV::KVzero(); + + static auto reflect() + { + using Self = MechanicalStrainData; + + return ProcessLib::Reflection::reflectWithName("eps_m", &Self::eps_m); + } +}; +} // namespace ProcessLib::ThermoRichardsMechanics diff --git a/ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/SolidMechanicsDataStateless.h b/ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/SolidMechanicsDataStateless.h new file mode 100644 index 00000000000..f1da747d3b2 --- /dev/null +++ b/ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/SolidMechanicsDataStateless.h @@ -0,0 +1,25 @@ +/** + * \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 "Base.h" + +namespace ProcessLib::ThermoRichardsMechanics +{ +template +struct SolidMechanicsDataStateless +{ + KelvinMatrix stiffness_tensor = + KV::KMnan(); + KelvinVector J_uT_BT_K_N = KV::KVnan(); + KelvinVector J_up_BT_K_N = KV::KVnan(); +}; +} // namespace ProcessLib::ThermoRichardsMechanics diff --git a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveData.h b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveData.h index d8260cf5be2..a5670500cc1 100644 --- a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveData.h +++ b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveData.h @@ -16,9 +16,11 @@ #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/EqT.h" #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/EquivalentPlasticStrainData.h" #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/Gravity.h" +#include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/MechanicalStrainData.h" #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/Porosity.h" #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/Saturation.h" #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/SolidDensity.h" +#include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/SolidMechanicsDataStateless.h" #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/Swelling.h" #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/TRMHeatStorageAndFlux.h" #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/TRMStorage.h" @@ -31,113 +33,50 @@ namespace ProcessLib::ThermoRichardsMechanics { namespace ConstitutiveStressSaturation_StrainPressureTemperature { +// TODO directly declare these type aliases in Traits.h /// Data whose state must be tracked by the TRM process. template -struct StatefulData -{ - SaturationData S_L_data; - PorosityData poro_data; - TransportPorosityData transport_poro_data; - StrainData eps_data; - // TODO swelling is not used in this constitutive setting, but the stateful - // data is set in setInitialConditionsConcrete() - // Once this has been refactored, the swelling code can be moved from the - // common to the original subdirectory for constitutive settings - SwellingDataStateful swelling_data; - SolidMechanicsDataStateful s_mech_data; - TotalStressData total_stress_data; - - static auto reflect() - { - using Self = StatefulData; - - return Reflection::reflectWithoutName(&Self::S_L_data, - &Self::poro_data, - &Self::transport_poro_data, - &Self::eps_data, - &Self::swelling_data, - &Self::total_stress_data); - } -}; +using StatefulData = + std::tuple, + // TODO swelling is not used in this constitutive setting, but + // the stateful data is set in setInitialConditionsConcrete() + // Once this has been refactored, the swelling code can be moved + // from the common to the original subdirectory for constitutive + // settings + SwellingDataStateful, + // TODO get rid of that + MechanicalStrainData, + TotalStressData>; -/// Data whose state must be tracked by the TRM process. template -struct StatefulDataPrev -{ - PrevState S_L_data; - PrevState poro_data; - PrevState transport_poro_data; - PrevState> eps_data; - PrevState> swelling_data; - PrevState> s_mech_data; - PrevState> total_stress_data; - - StatefulDataPrev& operator=( - StatefulData const& state) - { - S_L_data = state.S_L_data; - poro_data = state.poro_data; - transport_poro_data = state.transport_poro_data; - eps_data = state.eps_data; - swelling_data = state.swelling_data; - s_mech_data = state.s_mech_data; - total_stress_data = state.total_stress_data; - - return *this; - } -}; +using StatefulDataPrev = PrevStateOf>; /// Data that is needed for output purposes, but not directly for the assembly. template -struct OutputData -{ - DarcyLawData darcy_data; - LiquidDensityData rho_L_data; - LiquidViscosityData mu_L_data; - SolidDensityData rho_S_data; - PermeabilityData perm_data; - - static auto reflect() - { - using Self = OutputData; - - return Reflection::reflectWithoutName(&Self::darcy_data, - &Self::rho_L_data, - &Self::mu_L_data, - &Self::rho_S_data, - &Self::perm_data); - } -}; +using OutputData = std::tuple, LiquidDensityData, + LiquidViscosityData, SolidDensityData, + PermeabilityData>; /// Data that is needed for the equation system assembly. template -struct ConstitutiveData -{ - SolidMechanicsDataStateless s_mech_data; - GravityData grav_data; - TRMHeatStorageAndFluxData heat_data; - TRMVaporDiffusionData vap_data; - TRMStorageData storage_data; - EqPData eq_p_data; - EqTData eq_T_data; - ThermoOsmosisData th_osmosis_data; -}; +using ConstitutiveData = + std::tuple, + GravityData, + TRMHeatStorageAndFluxData, + TRMVaporDiffusionData, TRMStorageData, + EqPData, EqTData, + ThermoOsmosisData>; /// Data that stores intermediate values, which are not needed outside the /// constitutive setting. template -struct ConstitutiveTempData -{ - ElasticTangentStiffnessData C_el_data; - BiotData biot_data; - SolidCompressibilityData solid_compressibility_data; - SaturationDataDeriv dS_L_data; - BishopsData bishops_data; - // TODO why not usual state tracking for that? - PrevState bishops_data_prev; - SolidThermalExpansionData s_therm_exp_data; - FluidThermalExpansionData f_therm_exp_data; - EquivalentPlasticStrainData equiv_plast_strain_data; -}; +using ConstitutiveTempData = + std::tuple, BiotData, + SolidCompressibilityData, SaturationDataDeriv, BishopsData, + // TODO why not usual state tracking for that? + PrevState, + SolidThermalExpansionData, + FluidThermalExpansionData, EquivalentPlasticStrainData>; } // namespace ConstitutiveStressSaturation_StrainPressureTemperature } // namespace ProcessLib::ThermoRichardsMechanics diff --git a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveModels.h b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveModels.h index fbd4edbb7af..5e8065b6f44 100644 --- a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveModels.h +++ b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveModels.h @@ -50,6 +50,7 @@ struct ConstitutiveModels SolidConstitutiveRelation> solid_compressibility_model; BishopsModel bishops_model; + BishopsPrevModel bishops_prev_model; PorosityModel poro_model; TransportPorosityModel transport_poro_model; SwellingModel swelling_model; diff --git a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveSetting.cpp b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveSetting.cpp index dfa134a890c..e22dd05b2eb 100644 --- a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveSetting.cpp +++ b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveSetting.cpp @@ -10,7 +10,7 @@ #include "ConstitutiveSetting.h" -#include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/Invoke.h" +#include "ProcessLib/Graph/Apply.h" namespace ProcessLib::ThermoRichardsMechanics { @@ -31,146 +31,64 @@ void ConstitutiveSetting::eval( OutputData& out, ConstitutiveData& cd) const { - namespace MPL = MaterialPropertyLib; + namespace G = ProcessLib::Graph; - auto& C_el_data = tmp.C_el_data; - auto& biot_data = tmp.biot_data; - auto& solid_compressibility_data = tmp.solid_compressibility_data; - auto& dS_L_data = tmp.dS_L_data; - auto& bishops_data = tmp.bishops_data; - auto& bishops_data_prev = tmp.bishops_data_prev; - auto& s_therm_exp_data = tmp.s_therm_exp_data; - auto& rho_L_data = out.rho_L_data; - auto& rho_S_data = out.rho_S_data; - auto& mu_L_data = out.mu_L_data; - auto& perm_data = out.perm_data; - auto& darcy_data = out.darcy_data; - auto& f_therm_exp_data = tmp.f_therm_exp_data; + auto const aux_data = std::tuple{SpaceTimeData{x_position, t, dt}, + MediaData{medium}, T_data, p_cap_data}; - auto& s_mech_data = cd.s_mech_data; - auto& grav_data = cd.grav_data; - auto& heat_data = cd.heat_data; - auto& vap_data = cd.vap_data; - auto& storage_data = cd.storage_data; - - auto& poro_data = state.poro_data; - auto& S_L_data = state.S_L_data; - - SpaceTimeData const x_t{x_position, t, dt}; - MediaData const media_data{medium}; + auto const mat_state_tuple = std::tie(mat_state); // TODO will eps lag one iteration behind? (since it's not updated after // solving the global equation system) - state.eps_data.eps.noalias() = eps_arg; - - assertEvalArgsUnique(models.elastic_tangent_stiffness_model); - models.elastic_tangent_stiffness_model.eval(x_t, T_data, C_el_data); - - assertEvalArgsUnique(models.biot_model); - models.biot_model.eval(x_t, media_data, biot_data); - - assertEvalArgsUnique(models.solid_compressibility_model); - models.solid_compressibility_model.eval(x_t, biot_data, C_el_data, - solid_compressibility_data); + std::get>(state).eps.noalias() = eps_arg; - assertEvalArgsUnique(models.s_mech_model); - models.s_mech_model.eval( - x_t, T_data, p_cap_data, state.eps_data, - prev_state.eps_data /* TODO why is eps stateful? */, mat_state, - prev_state.s_mech_data, state.s_mech_data, prev_state.total_stress_data, - state.total_stress_data, tmp.equiv_plast_strain_data, s_mech_data, - prev_state.S_L_data, state.S_L_data, dS_L_data); + 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); - assertEvalArgsUnique(models.bishops_model); - models.bishops_model.eval(x_t, media_data, S_L_data, bishops_data); + G::eval(models.s_mech_model, aux_data, tmp, state, prev_state, + mat_state_tuple, cd); - assertEvalArgsUnique(models.bishops_model); + G::eval(models.bishops_model, aux_data, state, tmp); // TODO why not ordinary state tracking? - models.bishops_model.eval(x_t, media_data, *prev_state.S_L_data, - *bishops_data_prev); + G::eval(models.bishops_prev_model, aux_data, prev_state, tmp); + G::eval(models.poro_model, aux_data, tmp, state, prev_state); - assertEvalArgsUnique(models.poro_model); - models.poro_model.eval( - x_t, media_data, solid_compressibility_data, S_L_data, - prev_state.S_L_data, bishops_data, bishops_data_prev, p_cap_data, - state.eps_data, prev_state.eps_data, prev_state.poro_data, poro_data); - - if (biot_data() < poro_data.phi) + // TODO move to local assembler? { - OGS_FATAL( - "ThermoRichardsMechanics: Biot-coefficient {} is smaller than " - "porosity {} in element/integration point {}/{}.", - biot_data(), poro_data.phi, *x_position.getElementID(), - *x_position.getIntegrationPoint()); + auto const& biot_data = std::get(tmp); + auto const& poro_data = std::get(state); + + if (biot_data() < poro_data.phi) + { + OGS_FATAL( + "ThermoRichardsMechanics: Biot-coefficient {} is smaller than " + "porosity {} in element/integration point {}/{}.", + biot_data(), poro_data.phi, *x_position.getElementID(), + *x_position.getIntegrationPoint()); + } } - assertEvalArgsUnique(models.rho_L_model); - models.rho_L_model.eval(x_t, media_data, p_cap_data, T_data, rho_L_data); - - assertEvalArgsUnique(models.rho_S_model); - models.rho_S_model.eval(x_t, media_data, poro_data, T_data, rho_S_data); - - assertEvalArgsUnique(models.grav_model); - models.grav_model.eval(poro_data, rho_S_data, rho_L_data, S_L_data, - dS_L_data, grav_data); - - assertEvalArgsUnique(models.mu_L_model); - models.mu_L_model.eval(x_t, media_data, rho_L_data, T_data, mu_L_data); + 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); - assertEvalArgsUnique(models.transport_poro_model); - models.transport_poro_model.eval( - x_t, media_data, solid_compressibility_data, bishops_data, - bishops_data_prev, p_cap_data, poro_data, state.eps_data, - prev_state.eps_data, prev_state.transport_poro_data, - state.transport_poro_data); - - assertEvalArgsUnique(models.perm_model); - models.perm_model.eval(x_t, media_data, S_L_data, p_cap_data, T_data, - state.transport_poro_data, state.total_stress_data, - state.eps_data, tmp.equiv_plast_strain_data, - perm_data); - - assertEvalArgsUnique(models.th_osmosis_model); - models.th_osmosis_model.eval(x_t, media_data, T_data, rho_L_data, - cd.th_osmosis_data); - - assertEvalArgsUnique(models.darcy_model); - models.darcy_model.eval(p_cap_data, rho_L_data, mu_L_data, perm_data, - cd.th_osmosis_data, darcy_data); - - assertEvalArgsUnique(models.heat_storage_and_flux_model); - models.heat_storage_and_flux_model.eval( - x_t, media_data, rho_L_data, rho_S_data, S_L_data, dS_L_data, poro_data, - mu_L_data, perm_data, T_data, darcy_data, heat_data); - - assertEvalArgsUnique(models.vapor_diffusion_model); - models.vapor_diffusion_model.eval(x_t, media_data, rho_L_data, S_L_data, - dS_L_data, poro_data, p_cap_data, T_data, - vap_data); - - assertEvalArgsUnique(models.s_therm_exp_model); // 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. - models.s_therm_exp_model.eval(x_t, media_data, s_therm_exp_data); - - assertEvalArgsUnique(models.f_therm_exp_model); - models.f_therm_exp_model.eval(x_t, media_data, p_cap_data, T_data, - s_therm_exp_data, poro_data, rho_L_data, - biot_data, f_therm_exp_data); - - assertEvalArgsUnique(models.storage_model); - models.storage_model.eval(x_t, biot_data, poro_data, rho_L_data, S_L_data, - dS_L_data, prev_state.S_L_data, p_cap_data, - solid_compressibility_data, storage_data); - - assertEvalArgsUnique(models.eq_p_model); - models.eq_p_model.eval(p_cap_data, T_data, S_L_data, dS_L_data, biot_data, - rho_L_data, mu_L_data, perm_data, f_therm_exp_data, - vap_data, storage_data, cd.eq_p_data); + G::eval(models.s_therm_exp_model, aux_data, tmp); - assertEvalArgsUnique(models.eq_T_model); - models.eq_T_model.eval(heat_data, vap_data, cd.eq_T_data); + 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); } template struct ConstitutiveSetting<2>; diff --git a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveSetting.h b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveSetting.h index d0c5c9d5f13..bb3db67656c 100644 --- a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveSetting.h +++ b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/ConstitutiveSetting.h @@ -34,28 +34,15 @@ struct ConstitutiveSetting OutputData& out, ConstitutiveData& cd) const; - static KelvinVector const& totalStress( - ConstitutiveData const& /*cd*/, - StatefulData const& state) - { - return state.total_stress_data.sigma_total; - } - static KelvinVector& totalStress( - ConstitutiveData& /*cd*/, - StatefulData& state) - { - return state.total_stress_data.sigma_total; - } - static KelvinVector const& statefulStress( StatefulData const& state) { - return state.total_stress_data.sigma_total; + return std::get>(state).sigma_total; } static KelvinVector& statefulStress( StatefulData& state) { - return state.total_stress_data.sigma_total; + return std::get>(state).sigma_total; } }; diff --git a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/SolidMechanics.cpp b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/SolidMechanics.cpp index 76b4165894a..0c43565bce2 100644 --- a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/SolidMechanics.cpp +++ b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/SolidMechanics.cpp @@ -21,9 +21,7 @@ void SolidMechanicsModel::eval( StrainData const& eps_data, PrevState> const& eps_prev_data, MaterialStateData& mat_state, - PrevState< - SolidMechanicsDataStateful> const& /*prev_state*/, - SolidMechanicsDataStateful& current_state, + MechanicalStrainData& eps_m_data, PrevState> const& total_stress_data_prev, TotalStressData& total_stress_data, EquivalentPlasticStrainData& equiv_plast_strain_data, @@ -38,7 +36,7 @@ void SolidMechanicsModel::eval( // This constitutive setting does not need eps_m. But eps_m is there, // because it is set in setInitialConditionsConcrete() // We set it to NaN for now. - current_state.eps_m.noalias() = KV::KVnan(); + eps_m_data.eps_m.noalias() = KV::KVnan(); auto const& eps_total = eps_data.eps; auto const& eps_total_prev = eps_prev_data->eps; diff --git a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/SolidMechanics.h b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/SolidMechanics.h index ad9261e4c8c..73938fc9453 100644 --- a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/SolidMechanics.h +++ b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStressSaturation_StrainPressureTemperature/SolidMechanics.h @@ -13,7 +13,9 @@ #include "ProcessLib/ConstitutiveRelations/StrainData.h" #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/EquivalentPlasticStrainData.h" #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/MaterialState.h" +#include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/MechanicalStrainData.h" #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/Saturation.h" +#include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/SolidMechanicsDataStateless.h" #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/TotalStressData.h" #include "TraitsBase.h" @@ -21,22 +23,6 @@ namespace ProcessLib::ThermoRichardsMechanics { namespace ConstitutiveStressSaturation_StrainPressureTemperature { -template -struct SolidMechanicsDataStateful -{ - // TODO get rid of that - KelvinVector eps_m = KV::KVnan(); -}; - -template -struct SolidMechanicsDataStateless -{ - KelvinMatrix stiffness_tensor = - KV::KMnan(); - KelvinVector J_uT_BT_K_N = KV::KVnan(); - KelvinVector J_up_BT_K_N = KV::KVnan(); -}; - template struct SolidMechanicsModel { @@ -48,23 +34,20 @@ struct SolidMechanicsModel { } - void eval( - const SpaceTimeData& x_t, - TemperatureData const& T_data, - CapillaryPressureData const& p_cap_data, - StrainData const& eps_data, - PrevState> const& eps_prev_data, - MaterialStateData& mat_state, - PrevState< - SolidMechanicsDataStateful> const& /*prev_state*/, - SolidMechanicsDataStateful& current_state, - PrevState> const& - total_stress_data_prev, - TotalStressData& total_stress_data, - EquivalentPlasticStrainData& equiv_plast_strain_data, - SolidMechanicsDataStateless& current_stateless, - PrevState const& S_L_prev_data, - SaturationData& S_L_data, SaturationDataDeriv& dS_L_data) const; + void eval(const SpaceTimeData& x_t, + TemperatureData const& T_data, + CapillaryPressureData const& p_cap_data, + StrainData const& eps_data, + PrevState> const& eps_prev_data, + MaterialStateData& mat_state, + MechanicalStrainData& eps_m_data, + PrevState> const& + total_stress_data_prev, + TotalStressData& total_stress_data, + EquivalentPlasticStrainData& equiv_plast_strain_data, + SolidMechanicsDataStateless& current_stateless, + PrevState const& S_L_prev_data, + SaturationData& S_L_data, SaturationDataDeriv& dS_L_data) const; private: SolidConstitutiveRelation const& solid_material_; diff --git a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveData.h b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveData.h index bf5485816f2..cd41d825e15 100644 --- a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveData.h +++ b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveData.h @@ -10,12 +10,12 @@ #pragma once -#include "ProcessLib/Reflection/ReflectionData.h" #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/DarcyLaw.h" #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/EqP.h" #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/EqT.h" #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/EquivalentPlasticStrainData.h" #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/Gravity.h" +#include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/MechanicalStrainData.h" #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/Porosity.h" #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/Saturation.h" #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/SolidDensity.h" @@ -33,105 +33,42 @@ namespace ConstitutiveStress_StrainTemperature { /// Data whose state must be tracked by the TRM process. template -struct StatefulData -{ - SaturationData S_L_data; - PorosityData poro_data; - TransportPorosityData transport_poro_data; - StrainData eps_data; - SwellingDataStateful swelling_data; - SolidMechanicsDataStateful s_mech_data; - - static auto reflect() - { - using Self = StatefulData; - - return Reflection::reflectWithoutName(&Self::S_L_data, - &Self::poro_data, - &Self::transport_poro_data, - &Self::eps_data, - &Self::swelling_data, - &Self::s_mech_data); - } -}; +using StatefulData = + std::tuple, + SwellingDataStateful, + MechanicalStrainData, + EffectiveStressData>; template -struct StatefulDataPrev -{ - PrevState S_L_data; - PrevState poro_data; - PrevState transport_poro_data; - PrevState> eps_data; - PrevState> swelling_data; - PrevState> s_mech_data; - - StatefulDataPrev& operator=( - StatefulData const& state) - { - S_L_data = state.S_L_data; - poro_data = state.poro_data; - transport_poro_data = state.transport_poro_data; - eps_data = state.eps_data; - swelling_data = state.swelling_data; - s_mech_data = state.s_mech_data; - - return *this; - } -}; +using StatefulDataPrev = PrevStateOf>; /// Data that is needed for output purposes, but not directly for the assembly. template -struct OutputData -{ - DarcyLawData darcy_data; - LiquidDensityData rho_L_data; - LiquidViscosityData mu_L_data; - SolidDensityData rho_S_data; - PermeabilityData perm_data; - - static auto reflect() - { - using Self = OutputData; - - return Reflection::reflectWithoutName(&Self::darcy_data, - &Self::rho_L_data, - &Self::mu_L_data, - &Self::rho_S_data, - &Self::perm_data); - } -}; +using OutputData = std::tuple, LiquidDensityData, + LiquidViscosityData, SolidDensityData, + PermeabilityData>; /// Data that is needed for the equation system assembly. template -struct ConstitutiveData -{ - SolidMechanicsDataStateless s_mech_data; - TotalStressData total_stress_data; - GravityData grav_data; - TRMHeatStorageAndFluxData heat_data; - TRMVaporDiffusionData vap_data; - TRMStorageData storage_data; - EqPData eq_p_data; - EqTData eq_T_data; - ThermoOsmosisData th_osmosis_data; -}; +using ConstitutiveData = + std::tuple, + TotalStressData, GravityData, + TRMHeatStorageAndFluxData, + TRMVaporDiffusionData, TRMStorageData, + EqPData, EqTData, + ThermoOsmosisData>; /// Data that stores intermediate values, which are not needed outside the /// constitutive setting. template -struct ConstitutiveTempData -{ - SwellingDataStateless swelling_data; - ElasticTangentStiffnessData C_el_data; - BiotData biot_data; - SolidCompressibilityData solid_compressibility_data; - SaturationDataDeriv dS_L_data; - BishopsData bishops_data; - // TODO why not usual state tracking for that? - PrevState bishops_data_prev; - SolidThermalExpansionData s_therm_exp_data; - FluidThermalExpansionData f_therm_exp_data; - EquivalentPlasticStrainData equiv_plast_strain_data; -}; +using ConstitutiveTempData = + std::tuple, + ElasticTangentStiffnessData, BiotData, + SolidCompressibilityData, SaturationDataDeriv, BishopsData, + // TODO why not usual state tracking for that? + PrevState, + SolidThermalExpansionData, + FluidThermalExpansionData, EquivalentPlasticStrainData>; } // namespace ConstitutiveStress_StrainTemperature } // namespace ProcessLib::ThermoRichardsMechanics diff --git a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveModels.h b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveModels.h index f4e7b015bb5..513ae4485de 100644 --- a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveModels.h +++ b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveModels.h @@ -53,6 +53,7 @@ struct ConstitutiveModels solid_compressibility_model; SaturationModel S_L_model; BishopsModel bishops_model; + BishopsPrevModel bishops_prev_model; PorosityModel poro_model; TransportPorosityModel transport_poro_model; SwellingModel swelling_model; diff --git a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveSetting.cpp b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveSetting.cpp index ca99347b666..69777a24098 100644 --- a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveSetting.cpp +++ b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveSetting.cpp @@ -10,7 +10,7 @@ #include "ConstitutiveSetting.h" -#include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/Invoke.h" +#include "ProcessLib/Graph/Apply.h" namespace ProcessLib::ThermoRichardsMechanics { @@ -31,94 +31,47 @@ void ConstitutiveSetting::eval( OutputData& out, ConstitutiveData& cd) const { - namespace MPL = MaterialPropertyLib; - - auto& C_el_data = tmp.C_el_data; - auto& biot_data = tmp.biot_data; - auto& solid_compressibility_data = tmp.solid_compressibility_data; - auto& dS_L_data = tmp.dS_L_data; - auto& bishops_data = tmp.bishops_data; - auto& bishops_data_prev = tmp.bishops_data_prev; - auto& s_therm_exp_data = tmp.s_therm_exp_data; - auto& rho_L_data = out.rho_L_data; - auto& rho_S_data = out.rho_S_data; - auto& mu_L_data = out.mu_L_data; - auto& perm_data = out.perm_data; - auto& darcy_data = out.darcy_data; - auto& f_therm_exp_data = tmp.f_therm_exp_data; - - auto& swelling_data = tmp.swelling_data; - auto& s_mech_data = cd.s_mech_data; - auto& grav_data = cd.grav_data; - auto& heat_data = cd.heat_data; - auto& vap_data = cd.vap_data; - auto& storage_data = cd.storage_data; - - auto& poro_data = state.poro_data; - auto& S_L_data = state.S_L_data; - - SpaceTimeData const x_t{x_position, t, dt}; - MediaData const media_data{medium}; + namespace G = ProcessLib::Graph; - // TODO will eps lag one iteration behind? (since it's not updated after - // solving the global equation system) - state.eps_data.eps.noalias() = eps_arg; - - assertEvalArgsUnique(models.elastic_tangent_stiffness_model); - models.elastic_tangent_stiffness_model.eval(x_t, T_data, C_el_data); + auto const aux_data = std::tuple{SpaceTimeData{x_position, t, dt}, + MediaData{medium}, T_data, p_cap_data}; - assertEvalArgsUnique(models.biot_model); - models.biot_model.eval(x_t, media_data, biot_data); + auto const mat_state_tuple = std::tie(mat_state); - assertEvalArgsUnique(models.solid_compressibility_model); - models.solid_compressibility_model.eval(x_t, biot_data, C_el_data, - solid_compressibility_data); - - assertEvalArgsUnique(models.S_L_model); - models.S_L_model.eval(x_t, media_data, p_cap_data, S_L_data, dS_L_data); + // 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; - assertEvalArgsUnique(models.bishops_model); - models.bishops_model.eval(x_t, media_data, S_L_data, bishops_data); + 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); - assertEvalArgsUnique(models.bishops_model); + G::eval(models.bishops_model, aux_data, state, tmp); // TODO why not ordinary state tracking? - models.bishops_model.eval(x_t, media_data, *prev_state.S_L_data, - *bishops_data_prev); - - assertEvalArgsUnique(models.poro_model); - models.poro_model.eval( - x_t, media_data, solid_compressibility_data, S_L_data, - prev_state.S_L_data, bishops_data, bishops_data_prev, p_cap_data, - state.eps_data, prev_state.eps_data, prev_state.poro_data, poro_data); + G::eval(models.bishops_prev_model, aux_data, prev_state, tmp); + G::eval(models.poro_model, aux_data, tmp, state, prev_state); - if (biot_data() < poro_data.phi) { - OGS_FATAL( - "ThermoRichardsMechanics: Biot-coefficient {} is smaller than " - "porosity {} in element/integration point {}/{}.", - biot_data(), poro_data.phi, *x_position.getElementID(), - *x_position.getIntegrationPoint()); + auto const& biot_data = std::get(tmp); + auto const& poro_data = std::get(state); + + if (biot_data() < poro_data.phi) + { + OGS_FATAL( + "ThermoRichardsMechanics: Biot-coefficient {} is smaller than " + "porosity {} in element/integration point {}/{}.", + biot_data(), poro_data.phi, *x_position.getElementID(), + *x_position.getIntegrationPoint()); + } } - assertEvalArgsUnique(models.swelling_model); - models.swelling_model.eval(x_t, media_data, C_el_data, state.eps_data, - prev_state.eps_data, S_L_data, dS_L_data, - prev_state.S_L_data, prev_state.swelling_data, - state.swelling_data, swelling_data); - - assertEvalArgsUnique(models.s_therm_exp_model); - models.s_therm_exp_model.eval(x_t, media_data, s_therm_exp_data); - - assertEvalArgsUnique(models.s_mech_model); - models.s_mech_model.eval( - x_t, s_therm_exp_data, swelling_data, T_data, p_cap_data, biot_data, - bishops_data, dS_L_data, state.eps_data, - prev_state.eps_data /* TODO why is eps stateful? */, mat_state, - prev_state.s_mech_data, state.s_mech_data, cd.total_stress_data, - tmp.equiv_plast_strain_data, s_mech_data); + 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); - assertEvalArgsUnique(models.rho_L_model); - models.rho_L_model.eval(x_t, media_data, p_cap_data, T_data, rho_L_data); + G::eval(models.rho_L_model, aux_data, out); /* { double const p_FR = -bishops_data.chi_S_L * p_cap_data.p_cap; @@ -126,67 +79,23 @@ void ConstitutiveSetting::eval( // TODO used by no MPL model variables.solid_grain_pressure = p_FR - - Invariants::trace(state.s_mech_data.sigma_eff) / (3 * (1 - phi)); + Invariants::trace(std::get(state).sigma_eff) / (3 * (1 + - phi)); } */ - assertEvalArgsUnique(models.rho_S_model); - models.rho_S_model.eval(x_t, media_data, poro_data, T_data, rho_S_data); - - assertEvalArgsUnique(models.grav_model); - models.grav_model.eval(poro_data, rho_S_data, rho_L_data, S_L_data, - dS_L_data, grav_data); - - assertEvalArgsUnique(models.mu_L_model); - models.mu_L_model.eval(x_t, media_data, rho_L_data, T_data, mu_L_data); - - assertEvalArgsUnique(models.transport_poro_model); - models.transport_poro_model.eval( - x_t, media_data, solid_compressibility_data, bishops_data, - bishops_data_prev, p_cap_data, poro_data, state.eps_data, - prev_state.eps_data, prev_state.transport_poro_data, - state.transport_poro_data); - - assertEvalArgsUnique(models.perm_model); - models.perm_model.eval(x_t, media_data, S_L_data, p_cap_data, T_data, - state.transport_poro_data, cd.total_stress_data, - state.eps_data, tmp.equiv_plast_strain_data, - perm_data); - - assertEvalArgsUnique(models.th_osmosis_model); - models.th_osmosis_model.eval(x_t, media_data, T_data, rho_L_data, - cd.th_osmosis_data); - - assertEvalArgsUnique(models.darcy_model); - models.darcy_model.eval(p_cap_data, rho_L_data, mu_L_data, perm_data, - cd.th_osmosis_data, darcy_data); - - assertEvalArgsUnique(models.heat_storage_and_flux_model); - models.heat_storage_and_flux_model.eval( - x_t, media_data, rho_L_data, rho_S_data, S_L_data, dS_L_data, poro_data, - mu_L_data, perm_data, T_data, darcy_data, heat_data); - - assertEvalArgsUnique(models.vapor_diffusion_model); - models.vapor_diffusion_model.eval(x_t, media_data, rho_L_data, S_L_data, - dS_L_data, poro_data, p_cap_data, T_data, - vap_data); - - assertEvalArgsUnique(models.f_therm_exp_model); - models.f_therm_exp_model.eval(x_t, media_data, p_cap_data, T_data, - s_therm_exp_data, poro_data, rho_L_data, - biot_data, f_therm_exp_data); - - assertEvalArgsUnique(models.storage_model); - models.storage_model.eval(x_t, biot_data, poro_data, rho_L_data, S_L_data, - dS_L_data, prev_state.S_L_data, p_cap_data, - solid_compressibility_data, storage_data); - - assertEvalArgsUnique(models.eq_p_model); - models.eq_p_model.eval(p_cap_data, T_data, S_L_data, dS_L_data, biot_data, - rho_L_data, mu_L_data, perm_data, f_therm_exp_data, - vap_data, storage_data, cd.eq_p_data); - - assertEvalArgsUnique(models.eq_T_model); - models.eq_T_model.eval(heat_data, vap_data, cd.eq_T_data); + 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); } template struct ConstitutiveSetting<2>; diff --git a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveSetting.h b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveSetting.h index a64f72d2a28..b215875cc93 100644 --- a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveSetting.h +++ b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/ConstitutiveSetting.h @@ -34,28 +34,15 @@ struct ConstitutiveSetting OutputData& out, ConstitutiveData& cd) const; - static KelvinVector const& totalStress( - ConstitutiveData const& cd, - StatefulData const& /*state*/) - { - return cd.total_stress_data.sigma_total; - } - static KelvinVector& totalStress( - ConstitutiveData& cd, - StatefulData& /*state*/) - { - return cd.total_stress_data.sigma_total; - } - static KelvinVector const& statefulStress( StatefulData const& state) { - return state.s_mech_data.sigma_eff; + return std::get>(state).sigma_eff; } static KelvinVector& statefulStress( StatefulData& state) { - return state.s_mech_data.sigma_eff; + return std::get>(state).sigma_eff; } }; diff --git a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/SolidMechanics.cpp b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/SolidMechanics.cpp index 1f31da4b399..0f4a15aad4f 100644 --- a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/SolidMechanics.cpp +++ b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/SolidMechanics.cpp @@ -27,8 +27,10 @@ void SolidMechanicsModel::eval( StrainData const& eps_data, PrevState> const& eps_prev_data, MaterialStateData& mat_state, - PrevState> const& prev_state, - SolidMechanicsDataStateful& current_state, + PrevState> const& sigma_eff_prev_data, + EffectiveStressData& sigma_eff_data, + PrevState> const& eps_m_prev_data, + MechanicalStrainData& eps_m_data, TotalStressData& total_stress_data, EquivalentPlasticStrainData& equiv_plast_strain_data, SolidMechanicsDataStateless& out) const @@ -39,20 +41,20 @@ void SolidMechanicsModel::eval( double const T_prev = T_data.T_prev; double const dT = T_data.T - T_prev; - current_state.eps_m.noalias() = - prev_state->eps_m + eps_data.eps - eps_prev_data->eps - + eps_m_data.eps_m.noalias() = + eps_m_prev_data->eps_m + eps_data.eps - eps_prev_data->eps - s_therm_exp_data.solid_linear_thermal_expansivity_vector * dT + swelling_data.eps_m; variables.mechanical_strain.emplace>( - current_state.eps_m); + eps_m_data.eps_m); variables.temperature = T_data.T; MPL::VariableArray variables_prev; variables_prev.stress.emplace>( - prev_state->sigma_eff); + sigma_eff_prev_data->sigma_eff); variables_prev.mechanical_strain.emplace>( - prev_state->eps_m); + eps_m_prev_data->eps_m); variables_prev.temperature = T_prev; auto solution = solid_material_.integrateStress( @@ -64,14 +66,14 @@ void SolidMechanicsModel::eval( OGS_FATAL("Computation of local constitutive relation failed."); } - std::tie(current_state.sigma_eff, mat_state.material_state_variables, + std::tie(sigma_eff_data.sigma_eff, mat_state.material_state_variables, out.stiffness_tensor) = std::move(*solution); auto const& identity2 = MathLib::KelvinVector::Invariants< MathLib::KelvinVector::kelvin_vector_dimensions( DisplacementDim)>::identity2; total_stress_data.sigma_total.noalias() = - current_state.sigma_eff + + sigma_eff_data.sigma_eff + biot_data() * bishops_data.chi_S_L * p_cap_data.p_cap * identity2; out.J_uT_BT_K_N.noalias() = // TODO is this thermal stress? diff --git a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/SolidMechanics.h b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/SolidMechanics.h index a3e409246b0..4c3c67f7147 100644 --- a/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/SolidMechanics.h +++ b/ProcessLib/ThermoRichardsMechanics/ConstitutiveStress_StrainTemperature/SolidMechanics.h @@ -15,6 +15,8 @@ #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/Bishops.h" #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/EquivalentPlasticStrainData.h" #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/MaterialState.h" +#include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/MechanicalStrainData.h" +#include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/SolidMechanicsDataStateless.h" #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/SolidThermalExpansion.h" #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/Swelling.h" #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/TotalStressData.h" @@ -25,31 +27,20 @@ namespace ProcessLib::ThermoRichardsMechanics namespace ConstitutiveStress_StrainTemperature { template -struct SolidMechanicsDataStateful +struct EffectiveStressData { // TODO it seems fragile that some data have to be initialized that way. KelvinVector sigma_eff = KV::KVzero(); - KelvinVector eps_m = KV::KVzero(); static auto reflect() { - using Self = SolidMechanicsDataStateful; + using Self = EffectiveStressData; - // TODO add eps_m? return ProcessLib::Reflection::reflectWithName("sigma", &Self::sigma_eff); } }; -template -struct SolidMechanicsDataStateless -{ - KelvinMatrix stiffness_tensor = - KV::KMnan(); - KelvinVector J_uT_BT_K_N = KV::KVnan(); - KelvinVector J_up_BT_K_N = KV::KVnan(); -}; - template struct SolidMechanicsModel { @@ -71,9 +62,11 @@ struct SolidMechanicsModel StrainData const& eps_data, PrevState> const& eps_prev_data, MaterialStateData& mat_state, - PrevState> const& - prev_state, - SolidMechanicsDataStateful& current_state, + PrevState> const& + sigma_eff_prev_data, + EffectiveStressData& sigma_eff_data, + PrevState> const& eps_m_prev_data, + MechanicalStrainData& eps_m_data, TotalStressData& total_stress_data, EquivalentPlasticStrainData& equiv_plast_strain_data, SolidMechanicsDataStateless& out) const; diff --git a/ProcessLib/ThermoRichardsMechanics/LocalAssemblerInterface.h b/ProcessLib/ThermoRichardsMechanics/LocalAssemblerInterface.h index c75c4d3c68b..3d7f6ccb063 100644 --- a/ProcessLib/ThermoRichardsMechanics/LocalAssemblerInterface.h +++ b/ProcessLib/ThermoRichardsMechanics/LocalAssemblerInterface.h @@ -13,8 +13,10 @@ #include "MaterialLib/SolidModels/SelectSolidConstitutiveRelation.h" #include "NumLib/Extrapolation/ExtrapolatableElement.h" #include "NumLib/Fem/Integration/GenericIntegrationMethod.h" +#include "ProcessLib/ConstitutiveRelations/StrainData.h" #include "ProcessLib/LocalAssemblerInterface.h" #include "ProcessLib/Reflection/ReflectionSetIPData.h" +#include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/Base.h" #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/MaterialState.h" #include "ProcessLib/ThermoRichardsMechanics/ThermoRichardsMechanicsProcessData.h" #include "ProcessLib/Utils/SetOrGetIntegrationPointData.h" @@ -53,7 +55,7 @@ struct LocalAssemblerInterface : public ProcessLib::LocalAssemblerInterface, solid_material_.createMaterialStateVariables()); // Set initial strain field to zero. - current_states_[ip].eps_data.eps = + std::get>(current_states_[ip]).eps = KelvinVector::Zero(); } } diff --git a/ProcessLib/ThermoRichardsMechanics/ThermoRichardsMechanicsFEM-impl.h b/ProcessLib/ThermoRichardsMechanics/ThermoRichardsMechanicsFEM-impl.h index 8ca16159770..03fd4441e71 100644 --- a/ProcessLib/ThermoRichardsMechanics/ThermoRichardsMechanicsFEM-impl.h +++ b/ProcessLib/ThermoRichardsMechanics/ThermoRichardsMechanicsFEM-impl.h @@ -23,6 +23,9 @@ #include "MathLib/KelvinVector.h" #include "NumLib/Function/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" @@ -132,7 +135,7 @@ void ThermoRichardsMechanicsLocalAssemblerprev_states_[ip].S_L_data->S_L = + std::get>(this->prev_states_[ip])->S_L = medium->property(MPL::PropertyType::saturation) .template value(variables, x_position, t, dt); @@ -145,10 +148,16 @@ void ThermoRichardsMechanicsLocalAssemblersolid_material_} .eval(x_t, {T_ip, 0, {}}, C_el_data); - auto const& eps = this->current_states_[ip].eps_data.eps; + auto const& eps = + std::get>(this->current_states_[ip]) + .eps; auto const& sigma_sw = - this->current_states_[ip].swelling_data.sigma_sw; - this->prev_states_[ip].s_mech_data->eps_m.noalias() = + std::get>( + this->current_states_[ip]) + .sigma_sw; + std::get>>( + this->prev_states_[ip]) + ->eps_m.noalias() = solid_phase.hasProperty(MPL::PropertyType::swelling_stress_rate) ? eps + C_el_data.C_el.inverse() * sigma_sw : eps; @@ -316,15 +325,12 @@ void ThermoRichardsMechanicsLocalAssembler( - this->element_, N_u); auto const B = LinearBMatrix::computeBMatrix( - dNdx_u, N_u, x_coord, this->is_axially_symmetric_); + dNdx_u, N_u, (*x_position.getCoordinates())[0], + this->is_axially_symmetric_); auto const [T, p_L, u] = localDOF(local_x); auto const [T_prev, p_L_prev, u_prev] = localDOF(local_x_prev); @@ -385,62 +391,100 @@ void ThermoRichardsMechanicsLocalAssembler>(CD).rhs_p_dNT_V; block_u(out.res).noalias() = - B.transpose() * sigma_total - + B.transpose() * + ProcessLib::Graph::get>( + CD, current_state) + .sigma_total - static_cast(this->process_data_.apply_body_force_for_deformation) * - N_u_op(N_u).transpose() * CD.grav_data.volumetric_body_force; + N_u_op(N_u).transpose() * + std::get>(CD).volumetric_body_force; // Storage matrices - out.storage_p_a_p.noalias() = CD.eq_p_data.storage_p_a_p_X_NTN * NTN; - out.storage_p_a_S.noalias() = CD.storage_data.storage_p_a_S_X_NTN * NTN; + out.storage_p_a_p.noalias() = + std::get>(CD).storage_p_a_p_X_NTN * NTN; + out.storage_p_a_S.noalias() = + std::get(CD).storage_p_a_S_X_NTN * NTN; out.storage_p_a_S_Jpp.noalias() = - CD.storage_data.storage_p_a_S_Jpp_X_NTN * NTN; + std::get(CD).storage_p_a_S_Jpp_X_NTN * NTN; // M matrices, order T, p, u - out.M_TT.noalias() = CD.eq_T_data.M_TT_X_NTN * NTN; - out.M_Tp.noalias() = CD.vap_data.M_Tp_X_NTN * NTN; + out.M_TT.noalias() = + std::get>(CD).M_TT_X_NTN * NTN; + out.M_Tp.noalias() = + std::get>(CD).M_Tp_X_NTN * NTN; - out.M_pT.noalias() = CD.eq_p_data.M_pT_X_NTN * NTN; - out.M_pu.noalias() = CD.eq_p_data.M_pu_X_BTI2N * BTI2N.transpose(); + out.M_pT.noalias() = + std::get>(CD).M_pT_X_NTN * NTN; + out.M_pu.noalias() = + std::get>(CD).M_pu_X_BTI2N * BTI2N.transpose(); // K matrices, order T, p, u out.K_TT.noalias() = - dNdx.transpose() * CD.heat_data.K_TT_Laplace * dNdx + - N.transpose() * (CD.eq_T_data.K_TT_NT_V_dN.transpose() * dNdx) + - CD.vap_data.K_TT_X_dNTdN * dNTdN; + dNdx.transpose() * + std::get>(CD) + .K_TT_Laplace * + dNdx + + N.transpose() * + (std::get>(CD).K_TT_NT_V_dN.transpose() * + dNdx) + + std::get>(CD).K_TT_X_dNTdN * + dNTdN; out.dK_TT_dp.noalias() = - N.transpose() * (CD.heat_data.K_Tp_NT_V_dN.transpose() * dNdx) + - CD.heat_data.K_Tp_X_NTN * NTN; + N.transpose() * + (std::get>(CD) + .K_Tp_NT_V_dN.transpose() * + dNdx) + + std::get>(CD).K_Tp_X_NTN * + NTN; out.K_Tp.noalias() = - dNdx.transpose() * CD.th_osmosis_data.K_Tp_Laplace * dNdx + - CD.vap_data.K_Tp_X_dNTdN * dNTdN; - - out.K_pp.noalias() = dNdx.transpose() * CD.eq_p_data.K_pp_Laplace * dNdx + - CD.vap_data.K_pp_X_dNTdN * dNTdN; + dNdx.transpose() * + std::get>(CD).K_Tp_Laplace * + dNdx + + std::get>(CD).K_Tp_X_dNTdN * + dNTdN; + + out.K_pp.noalias() = + dNdx.transpose() * std::get>(CD).K_pp_Laplace * + dNdx + + std::get>(CD).K_pp_X_dNTdN * + dNTdN; out.K_pT.noalias() = - dNdx.transpose() * CD.th_osmosis_data.K_pT_Laplace * dNdx; + dNdx.transpose() * + std::get>(CD).K_pT_Laplace * dNdx; // direct Jacobian contributions, order T, p, u - block_pT(out.Jac).noalias() = CD.vap_data.J_pT_X_dNTdN * dNTdN; + block_pT(out.Jac).noalias() = + std::get>(CD).J_pT_X_dNTdN * + dNTdN; block_pp(out.Jac).noalias() = - CD.storage_data.J_pp_X_NTN * NTN + - CD.eq_p_data.J_pp_X_BTI2NT_u_dot_N * BTI2N.transpose() * (u - u_prev) / - dt * N // TODO something with volumetric strain rate? - + dNdx.transpose() * CD.eq_p_data.J_pp_dNT_V_N * N; + std::get(CD).J_pp_X_NTN * NTN + + std::get>(CD).J_pp_X_BTI2NT_u_dot_N * + BTI2N.transpose() * (u - u_prev) / dt * + N // TODO something with volumetric strain rate? + + dNdx.transpose() * + std::get>(CD).J_pp_dNT_V_N * N; block_uT(out.Jac).noalias() = - B.transpose() * CD.s_mech_data.J_uT_BT_K_N * N; + B.transpose() * + std::get>(CD).J_uT_BT_K_N * + N; block_up(out.Jac).noalias() = - B.transpose() * CD.s_mech_data.J_up_BT_K_N * N + - N_u_op(N_u).transpose() * CD.grav_data.J_up_HT_V_N * N; + B.transpose() * + std::get>(CD) + .J_up_BT_K_N * + N + + N_u_op(N_u).transpose() * + std::get>(CD).J_up_HT_V_N * N; block_uu(out.Jac).noalias() = - B.transpose() * CD.s_mech_data.stiffness_tensor * B; + B.transpose() * + std::get>(CD) + .stiffness_tensor * + B; out *= ip_data.integration_weight; } @@ -531,11 +575,11 @@ void ThermoRichardsMechanicsLocalAssemblermaterial_states_[ip], tmp, output_data, CD); - saturation_avg += current_state.S_L_data.S_L; - porosity_avg += current_state.poro_data.phi; + saturation_avg += std::get(current_state).S_L; + porosity_avg += std::get(current_state).phi; - liquid_density_avg += output_data.rho_L_data.rho_LR; - viscosity_avg += output_data.mu_L_data.viscosity; + liquid_density_avg += std::get(output_data).rho_LR; + viscosity_avg += std::get(output_data).viscosity; sigma_avg += ConstitutiveTraits::ConstitutiveSetting::statefulStress( current_state); } diff --git a/ProcessLib/ThermoRichardsMechanics/ThermoRichardsMechanicsFEM.h b/ProcessLib/ThermoRichardsMechanics/ThermoRichardsMechanicsFEM.h index 51fa592a83a..c20e44d517a 100644 --- a/ProcessLib/ThermoRichardsMechanics/ThermoRichardsMechanicsFEM.h +++ b/ProcessLib/ThermoRichardsMechanics/ThermoRichardsMechanicsFEM.h @@ -22,6 +22,8 @@ #include "NumLib/Fem/Integration/GenericIntegrationMethod.h" #include "NumLib/Fem/ShapeMatrixPolicy.h" #include "ProcessLib/Deformation/BMatrixPolicy.h" +#include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/Porosity.h" +#include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/TransportPorosity.h" #include "ThermoRichardsMechanicsProcessData.h" namespace ProcessLib @@ -303,22 +305,22 @@ class ThermoRichardsMechanicsLocalAssembler { // Initial porosity. Could be read from integration point data // or mesh. - current_state.poro_data.phi = + std::get(current_state).phi = medium.property(MPL::porosity) .template initialValue(x_position, time_independent); if (medium.hasProperty(MPL::PropertyType::transport_porosity)) { - current_state.transport_poro_data.phi = + std::get(current_state).phi = medium.property(MPL::transport_porosity) .template initialValue(x_position, time_independent); } else { - current_state.transport_poro_data.phi = - current_state.poro_data.phi; + std::get(current_state).phi = + std::get(current_state).phi; } } diff --git a/Tests/ProcessLib/TestConstitutiveSettingPrevState.cpp b/Tests/ProcessLib/TestConstitutiveSettingPrevState.cpp new file mode 100644 index 00000000000..b9afd594151 --- /dev/null +++ b/Tests/ProcessLib/TestConstitutiveSettingPrevState.cpp @@ -0,0 +1,168 @@ +/** + * \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/ConstitutiveRelations/Base.h" + +template +struct ProcessLib_ConstitutiveSettingPrevState_Typed : ::testing::Test +{ +}; + +using ProcessLib_ConstitutiveSettingPrevState_TypedTestCases = + ::testing::Types; + +TYPED_TEST_SUITE(ProcessLib_ConstitutiveSettingPrevState_Typed, + ProcessLib_ConstitutiveSettingPrevState_TypedTestCases); + +TYPED_TEST(ProcessLib_ConstitutiveSettingPrevState_Typed, StaticAssertions_Ctor) +{ + using namespace ProcessLib::ConstitutiveRelations; + using T = TypeParam; + + // copy, move, default + static_assert(std::is_default_constructible_v>); + static_assert(std::is_copy_constructible_v>); + static_assert(std::is_move_constructible_v>); + + // from value type + static_assert(std::is_constructible_v, T>); + static_assert(std::is_constructible_v, T&>); + static_assert(std::is_constructible_v, T const&>); + static_assert(std::is_constructible_v, T&&>); +} + +TYPED_TEST(ProcessLib_ConstitutiveSettingPrevState_Typed, + StaticAssertions_Assignment) +{ + using namespace ProcessLib::ConstitutiveRelations; + using T = TypeParam; + + // copy, move + static_assert(std::is_copy_assignable_v>); + static_assert(std::is_move_assignable_v>); + + // value type + static_assert(std::is_assignable_v, T>); + static_assert(std::is_assignable_v, T&>); + static_assert(std::is_assignable_v, T const&>); + static_assert(std::is_assignable_v, T&&>); + + // overwriting value type with prev state not possible + static_assert(!std::is_assignable_v>); + static_assert(!std::is_assignable_v&>); + static_assert(!std::is_assignable_v const&>); + static_assert(!std::is_assignable_v&&>); +} + +TEST(ProcessLib_ConstitutiveSettingPrevState, Tests1) +{ + using P = ProcessLib::ConstitutiveRelations::PrevState; + + P p; // default constructed + + ASSERT_TRUE(p->empty()); // member function access via -> + ASSERT_EQ("", *p); // value access via operator* + + *p = "some string"; // assignment to underlying value + ASSERT_EQ("some string", *p); + + p = "something else"; // direct assignment + ASSERT_EQ("something else", *p); +} + +TEST(ProcessLib_ConstitutiveSettingPrevState, Tests2) +{ + using P = ProcessLib::ConstitutiveRelations::PrevState; + + P p{"msg"}; + + ASSERT_EQ(3, p->length()); + ASSERT_EQ("msg", *p); + + std::string s = "some string"; + p = s; + ASSERT_EQ("some string", *p); + + s = "something else"; + p = std::move(s); + ASSERT_EQ("something else", *p); +} + +TEST(ProcessLib_ConstitutiveSettingPrevState, PrevStateOf) +{ + using namespace ProcessLib::ConstitutiveRelations; + + // empty tuple + { + using Tuple = std::tuple<>; + static_assert(std::is_same_v>); + } + + // one entry + { + using Tuple = std::tuple; + using TuplePrev = std::tuple>; + static_assert(std::is_same_v>); + } + + // multiple entries + { + using Tuple = std::tuple; + using TuplePrev = std:: + tuple, PrevState, PrevState>; + static_assert(std::is_same_v>); + } +} + +TEST(ProcessLib_ConstitutiveSettingPrevState, PrevStateOfAssign) +{ + using namespace ProcessLib::ConstitutiveRelations; + + // empty tuple + { + using Tuple = std::tuple<>; + + Tuple const t; + PrevStateOf tp; + + assign(tp, t); // only needs to compile + } + + // one entry + { + using Tuple = std::tuple; + using TuplePrev = std::tuple>; + + Tuple const t{5}; + TuplePrev tp{6}; + + assign(tp, t); + + EXPECT_EQ(5, *std::get<0>(tp)); + } + + // multiple entries + { + using Tuple = std::tuple; + using TuplePrev = std:: + tuple, PrevState, PrevState>; + + Tuple const t{5, 7.5, "hello"}; + TuplePrev tp{6, 8.25, "bye"}; + + assign(tp, t); + + EXPECT_EQ(5, *std::get<0>(tp)); + EXPECT_EQ(7.5, *std::get<1>(tp)); + EXPECT_EQ("hello", *std::get<2>(tp)); + } +} diff --git a/Tests/ProcessLib/TestTRMConstitutiveSettingPrevState.cpp b/Tests/ProcessLib/TestTRMConstitutiveSettingPrevState.cpp deleted file mode 100644 index ae55b0b89e3..00000000000 --- a/Tests/ProcessLib/TestTRMConstitutiveSettingPrevState.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/** - * \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/ThermoRichardsMechanics/ConstitutiveCommon/Base.h" - -template -struct ProcessLib_TRMConstitutiveSettingPrevState_Typed : ::testing::Test -{ -}; - -using ProcessLib_TRMConstitutiveSettingPrevState_TypedTestCases = - ::testing::Types; - -TYPED_TEST_SUITE(ProcessLib_TRMConstitutiveSettingPrevState_Typed, - ProcessLib_TRMConstitutiveSettingPrevState_TypedTestCases); - -TYPED_TEST(ProcessLib_TRMConstitutiveSettingPrevState_Typed, - StaticAssertions_Ctor) -{ - using namespace ProcessLib::ThermoRichardsMechanics; - using T = TypeParam; - - // copy, move, default - static_assert(std::is_default_constructible_v>); - static_assert(std::is_copy_constructible_v>); - static_assert(std::is_move_constructible_v>); - - // from value type - static_assert(std::is_constructible_v, T>); - static_assert(std::is_constructible_v, T&>); - static_assert(std::is_constructible_v, T const&>); - static_assert(std::is_constructible_v, T&&>); -} - -TYPED_TEST(ProcessLib_TRMConstitutiveSettingPrevState_Typed, - StaticAssertions_Assignment) -{ - using namespace ProcessLib::ThermoRichardsMechanics; - using T = TypeParam; - - // copy, move - static_assert(std::is_copy_assignable_v>); - static_assert(std::is_move_assignable_v>); - - // value type - static_assert(std::is_assignable_v, T>); - static_assert(std::is_assignable_v, T&>); - static_assert(std::is_assignable_v, T const&>); - static_assert(std::is_assignable_v, T&&>); - - // overwriting value type with prev state not possible - static_assert(!std::is_assignable_v>); - static_assert(!std::is_assignable_v&>); - static_assert(!std::is_assignable_v const&>); - static_assert(!std::is_assignable_v&&>); -} - -TEST(ProcessLib_TRMConstitutiveSettingPrevState, Tests1) -{ - using P = ProcessLib::ThermoRichardsMechanics::PrevState; - - P p; // default constructed - - ASSERT_TRUE(p->empty()); // member function access via -> - ASSERT_EQ("", *p); // value access via operator* - - *p = "some string"; // assignment to underlying value - ASSERT_EQ("some string", *p); - - p = "something else"; // direct assignment - ASSERT_EQ("something else", *p); -} - -TEST(ProcessLib_TRMConstitutiveSettingPrevState, Tests2) -{ - using P = ProcessLib::ThermoRichardsMechanics::PrevState; - - P p{"msg"}; - - ASSERT_EQ(3, p->length()); - ASSERT_EQ("msg", *p); - - std::string s = "some string"; - p = s; - ASSERT_EQ("some string", *p); - - s = "something else"; - p = std::move(s); - ASSERT_EQ("something else", *p); -} diff --git a/Tests/ProcessLib/TestUniqueFunctionArgumentTypes.cpp b/Tests/ProcessLib/TestUniqueFunctionArgumentTypes.cpp deleted file mode 100644 index 189d9ea935c..00000000000 --- a/Tests/ProcessLib/TestUniqueFunctionArgumentTypes.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/** - * \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/ThermoRichardsMechanics/ConstitutiveCommon/Invoke.h" - -TEST(ProcessLib_UniqueFunctionArgumentTypes, Unique) -{ - struct S - { - void no_args() {} // support for zero argument methods - void no_args_2() const {} // support for const methods - int no_args_3() { return 1; } // support for arbitrary return types - int& no_args_4() const - { - static int i; - return i; - } - - void one_arg(int) {} // support for one argument methods - double* one_arg_2(double& d) const - { - return &d; - } // argument type does not matter - void one_arg_3(std::string const&) const {} // classes work, too - - double two_args(int, double) { return 1.5; } - int two_args_2(double*, int) const { return 1; } - int two_args_3(int*, int) const - { - return 1; - } // difference in pointer/non-pointer is considered unique - - int three_args(std::string, int, char) const { return 1; } - std::string four_args(unsigned, std::string&, double, char) - { - return ""; - } - - // To check the convenience function and macro - void eval(unsigned, std::string const&, double*, char) {} - }; - - namespace D = ProcessLib::ThermoRichardsMechanics::detail; - - static_assert(D::areEvalArgumentTypesUnique(&S::no_args)); - static_assert(D::areEvalArgumentTypesUnique(&S::no_args_2)); - static_assert(D::areEvalArgumentTypesUnique(&S::no_args_3)); - static_assert(D::areEvalArgumentTypesUnique(&S::no_args_4)); - - static_assert(D::areEvalArgumentTypesUnique(&S::one_arg)); - static_assert(D::areEvalArgumentTypesUnique(&S::one_arg_2)); - static_assert(D::areEvalArgumentTypesUnique(&S::one_arg_3)); - - static_assert(D::areEvalArgumentTypesUnique(&S::two_args)); - static_assert(D::areEvalArgumentTypesUnique(&S::two_args_2)); - static_assert(D::areEvalArgumentTypesUnique(&S::two_args_3)); - - static_assert(D::areEvalArgumentTypesUnique(&S::three_args)); - static_assert(D::areEvalArgumentTypesUnique(&S::four_args)); - - static_assert( - ProcessLib::ThermoRichardsMechanics::areEvalArgumentTypesUnique()); - - S const s; - ProcessLib::ThermoRichardsMechanics::assertEvalArgsUnique(s); -} - -TEST(ProcessLib_UniqueFunctionArgumentTypes, NonUnique) -{ - struct S - { - void same_type(int, int) {} - - void diff_in_const(double, const double) const {} - void diff_in_ref(std::string, std::string&) const {} - void diff_in_rvalue_ref(std::string, std::string&&) {} - void diff_in_rvalue_ref_2(std::string const&, std::string&&) const {} - void diff_in_const_ref(char, const char&) {} - - // same with other arguments interspersed - void v2_same_type(char, int*, int*) {} - - void v2_diff_in_const(double*, int, double* const) const {} - void v2_diff_in_ref(char, unsigned, std::string, std::string&) {} - void v2_diff_in_rvalue_ref(std::string, std::string&&, double) const {} - void v2_diff_in_rvalue_ref_2(long, std::string const&, std::string&&, - double) const - { - } - void v2_diff_in_const_ref(std::string&, char, int*, const char&, - unsigned) - { - } - - // To check the convenience function - void eval(unsigned, std::string const&, double*, char, std::string) {} - }; - - namespace D = ProcessLib::ThermoRichardsMechanics::detail; - - static_assert(!D::areEvalArgumentTypesUnique(&S::same_type)); - static_assert(!D::areEvalArgumentTypesUnique(&S::diff_in_const)); - static_assert(!D::areEvalArgumentTypesUnique(&S::diff_in_ref)); - static_assert(!D::areEvalArgumentTypesUnique(&S::diff_in_rvalue_ref)); - static_assert(!D::areEvalArgumentTypesUnique(&S::diff_in_rvalue_ref_2)); - static_assert(!D::areEvalArgumentTypesUnique(&S::diff_in_const_ref)); - - static_assert(!D::areEvalArgumentTypesUnique(&S::v2_same_type)); - static_assert(!D::areEvalArgumentTypesUnique(&S::v2_diff_in_const)); - static_assert(!D::areEvalArgumentTypesUnique(&S::v2_diff_in_ref)); - static_assert(!D::areEvalArgumentTypesUnique(&S::v2_diff_in_rvalue_ref)); - static_assert(!D::areEvalArgumentTypesUnique(&S::v2_diff_in_rvalue_ref_2)); - static_assert(!D::areEvalArgumentTypesUnique(&S::v2_diff_in_const_ref)); - - static_assert( - !ProcessLib::ThermoRichardsMechanics::areEvalArgumentTypesUnique()); -}