diff --git a/MaterialLib/SolidModels/MFront/MFront.cpp b/MaterialLib/SolidModels/MFront/MFront.cpp index 2616e25fb068ba1a0aac5c313ce0c26951670bea..530a00140714b427b772cc9d799a725b466b915c 100644 --- a/MaterialLib/SolidModels/MFront/MFront.cpp +++ b/MaterialLib/SolidModels/MFront/MFront.cpp @@ -160,6 +160,14 @@ const char* varTypeToString(int v) OGS_FATAL("Unknown variable type {:d}.", v); } +int getEquivalentPlasticStrainOffset(mgis::behaviour::Behaviour const& b) +{ + return mgis::behaviour::contains(b.isvs, "EquivalentPlasticStrain") + ? mgis::behaviour::getVariableOffset( + b.isvs, "EquivalentPlasticStrain", b.hypothesis) + : -1; +} + template <int DisplacementDim> MFront<DisplacementDim>::MFront( mgis::behaviour::Behaviour&& behaviour, @@ -167,6 +175,8 @@ MFront<DisplacementDim>::MFront( boost::optional<ParameterLib::CoordinateSystem> const& local_coordinate_system) : _behaviour(std::move(behaviour)), + equivalent_plastic_strain_offset_( + getEquivalentPlasticStrainOffset(_behaviour)), _material_properties(std::move(material_properties)), _local_coordinate_system( local_coordinate_system ? &local_coordinate_system.get() : nullptr) @@ -243,7 +253,8 @@ template <int DisplacementDim> std::unique_ptr<typename MechanicsBase<DisplacementDim>::MaterialStateVariables> MFront<DisplacementDim>::createMaterialStateVariables() const { - return std::make_unique<MaterialStateVariables>(_behaviour); + return std::make_unique<MaterialStateVariables>( + equivalent_plastic_strain_offset_, _behaviour); } template <int DisplacementDim> @@ -457,6 +468,20 @@ double MFront<DisplacementDim>::computeFreeEnergyDensity( return std::numeric_limits<double>::quiet_NaN(); } +template <int DisplacementDim> +double MFront< + DisplacementDim>::MaterialStateVariables::getEquivalentPlasticStrain() const +{ + if (equivalent_plastic_strain_offset_ >= 0) + { + return _behaviour_data.s1 + .internal_state_variables[static_cast<mgis::size_type>( + equivalent_plastic_strain_offset_)]; + } + + return 0.0; +} + template class MFront<2>; template class MFront<3>; diff --git a/MaterialLib/SolidModels/MFront/MFront.h b/MaterialLib/SolidModels/MFront/MFront.h index cd32c3eaa481ebca5cf725305c8e4e2cdf9146c0..0af729a8542db13124a4fff863bb93d6b5a809e2 100644 --- a/MaterialLib/SolidModels/MFront/MFront.h +++ b/MaterialLib/SolidModels/MFront/MFront.h @@ -43,8 +43,12 @@ public: struct MaterialStateVariables : public MechanicsBase<DisplacementDim>::MaterialStateVariables { - explicit MaterialStateVariables(mgis::behaviour::Behaviour const& b) - : _behaviour_data{b} + explicit MaterialStateVariables( + int const equivalent_plastic_strain_offset, + mgis::behaviour::Behaviour const& b) + : equivalent_plastic_strain_offset_( + equivalent_plastic_strain_offset), + _behaviour_data{b} { } @@ -56,7 +60,10 @@ public: mgis::behaviour::update(_behaviour_data); } + int const equivalent_plastic_strain_offset_; mgis::behaviour::BehaviourData _behaviour_data; + + double getEquivalentPlasticStrain() const override; }; using KelvinVector = @@ -70,10 +77,9 @@ public: boost::optional<ParameterLib::CoordinateSystem> const& local_coordinate_system); - std::unique_ptr< - typename MechanicsBase<DisplacementDim>:: - MaterialStateVariables> createMaterialStateVariables() - const override; + std::unique_ptr< + typename MechanicsBase<DisplacementDim>::MaterialStateVariables> + createMaterialStateVariables() const override; std::optional<std::tuple<KelvinVector, std::unique_ptr<typename MechanicsBase< @@ -106,6 +112,7 @@ public: private: mgis::behaviour::Behaviour _behaviour; + int const equivalent_plastic_strain_offset_; std::vector<ParameterLib::Parameter<double> const*> _material_properties; ParameterLib::CoordinateSystem const* const _local_coordinate_system; };