diff --git a/MaterialLib/SolidModels/Ehlers.cpp b/MaterialLib/SolidModels/Ehlers.cpp index efbc6a5d9f4fd338ffeb6c57b3ab55ed996b6073..ee7c261af640237f4bf69f9361be6b43ca6a2030 100644 --- a/MaterialLib/SolidModels/Ehlers.cpp +++ b/MaterialLib/SolidModels/Ehlers.cpp @@ -720,6 +720,15 @@ SolidEhlers<DisplacementDim>::getInternalVariables() const cache.resize(1); cache.front() = ehlers_state.damage.kappa_d(); return cache; + }, + [](typename MechanicsBase<DisplacementDim>::MaterialStateVariables& + state) -> BaseLib::DynamicSpan<double> { + assert(dynamic_cast<StateVariables<DisplacementDim> const*>( + &state) != nullptr); + auto& ehlers_state = + static_cast<StateVariables<DisplacementDim>&>(state); + + return {&ehlers_state.damage.kappa_d(), 1}; }}, {"damage.value", 1, [](typename MechanicsBase< @@ -733,6 +742,15 @@ SolidEhlers<DisplacementDim>::getInternalVariables() const cache.resize(1); cache.front() = ehlers_state.damage.value(); return cache; + }, + [](typename MechanicsBase<DisplacementDim>::MaterialStateVariables& + state) -> BaseLib::DynamicSpan<double> { + assert(dynamic_cast<StateVariables<DisplacementDim> const*>( + &state) != nullptr); + auto& ehlers_state = + static_cast<StateVariables<DisplacementDim>&>(state); + + return {&ehlers_state.damage.value(), 1}; }}, {"eps_p.D", KelvinVector::RowsAtCompileTime, [](typename MechanicsBase< @@ -750,6 +768,17 @@ SolidEhlers<DisplacementDim>::getInternalVariables() const ehlers_state.eps_p.D); return cache; + }, + [](typename MechanicsBase<DisplacementDim>::MaterialStateVariables& + state) -> BaseLib::DynamicSpan<double> { + assert(dynamic_cast<StateVariables<DisplacementDim> const*>( + &state) != nullptr); + auto& ehlers_state = + static_cast<StateVariables<DisplacementDim>&>(state); + + return { + ehlers_state.eps_p.D.data(), + static_cast<std::size_t>(KelvinVector::RowsAtCompileTime)}; }}, {"eps_p.V", 1, [](typename MechanicsBase< @@ -763,6 +792,15 @@ SolidEhlers<DisplacementDim>::getInternalVariables() const cache.resize(1); cache.front() = ehlers_state.eps_p.V; return cache; + }, + [](typename MechanicsBase<DisplacementDim>::MaterialStateVariables& + state) -> BaseLib::DynamicSpan<double> { + assert(dynamic_cast<StateVariables<DisplacementDim> const*>( + &state) != nullptr); + auto& ehlers_state = + static_cast<StateVariables<DisplacementDim>&>(state); + + return {&ehlers_state.eps_p.V, 1}; }}, {"eps_p.eff", 1, [](typename MechanicsBase< @@ -776,6 +814,15 @@ SolidEhlers<DisplacementDim>::getInternalVariables() const cache.resize(1); cache.front() = ehlers_state.eps_p.eff; return cache; + }, + [](typename MechanicsBase<DisplacementDim>::MaterialStateVariables& + state) -> BaseLib::DynamicSpan<double> { + assert(dynamic_cast<StateVariables<DisplacementDim> const*>( + &state) != nullptr); + auto& ehlers_state = + static_cast<StateVariables<DisplacementDim>&>(state); + + return {&ehlers_state.eps_p.eff, 1}; }}}; } diff --git a/MaterialLib/SolidModels/Ehlers.h b/MaterialLib/SolidModels/Ehlers.h index cddd1c104f5e4955606420248ff34b250168c217..1ff8c3ed1bdaefda2c801f52d3f4fcc854c5e839 100644 --- a/MaterialLib/SolidModels/Ehlers.h +++ b/MaterialLib/SolidModels/Ehlers.h @@ -209,7 +209,9 @@ public: } double kappa_d() const { return _kappa_d; } + double& kappa_d() { return _kappa_d; } double value() const { return _value; } + double& value() { return _value; } private: double _kappa_d = 0; ///< damage driving variable diff --git a/MaterialLib/SolidModels/MFront/MFront.cpp b/MaterialLib/SolidModels/MFront/MFront.cpp index 08a6d03445eb646c2ae2e3104f8462a5b6d82517..e6cb2b3f01b54f892d4ad646979380ecf08c96f4 100644 --- a/MaterialLib/SolidModels/MFront/MFront.cpp +++ b/MaterialLib/SolidModels/MFront/MFront.cpp @@ -431,6 +431,17 @@ MFront<DisplacementDim>::getInternalVariables() const size, begin(cache)); return cache; + }, + [offset, size]( + typename MechanicsBase<DisplacementDim>::MaterialStateVariables& + state) -> BaseLib::DynamicSpan<double> { + assert(dynamic_cast<MaterialStateVariables const*>(&state) != + nullptr); + auto& internal_state_variables = + static_cast<MaterialStateVariables&>(state) + ._behaviour_data.s1.internal_state_variables; + + return {internal_state_variables.data() + offset, size}; }}; internal_variables.push_back(new_variable); } diff --git a/MaterialLib/SolidModels/MechanicsBase.h b/MaterialLib/SolidModels/MechanicsBase.h index 936a372be4b64c321ec3946c478045760c9e87d9..684509c0da760e8c9218101296b6a965e21ae716 100644 --- a/MaterialLib/SolidModels/MechanicsBase.h +++ b/MaterialLib/SolidModels/MechanicsBase.h @@ -9,15 +9,16 @@ #pragma once -#include <optional> #include <functional> #include <memory> +#include <optional> #include <tuple> #include <vector> +#include "BaseLib/DynamicSpan.h" #include "BaseLib/Error.h" -#include "MathLib/KelvinVector.h" #include "MaterialLib/MPL/VariableType.h" +#include "MathLib/KelvinVector.h" namespace ParameterLib { @@ -96,6 +97,8 @@ struct MechanicsBase { using Getter = std::function<std::vector<double> const&( MaterialStateVariables const&, std::vector<double>& /*cache*/)>; + using WriteAccess = std::function<BaseLib::DynamicSpan<double>( + MaterialStateVariables&)>; /// name of the internal variable std::string const name; @@ -105,6 +108,9 @@ struct MechanicsBase /// function accessing the internal variable Getter const getter; + + /// function accessing the internal variable + WriteAccess const reference; }; /// Returns internal variables defined by the specific material model, if