diff --git a/ProcessLib/ThermoMechanics/LocalAssemblerInterface.h b/ProcessLib/ThermoMechanics/LocalAssemblerInterface.h index 4ff9813373b305fd5dc0888c10884ee65f1fda0f..07f661cffcd8664c687f77da83748d693049dee4 100644 --- a/ProcessLib/ThermoMechanics/LocalAssemblerInterface.h +++ b/ProcessLib/ThermoMechanics/LocalAssemblerInterface.h @@ -12,6 +12,7 @@ #include <vector> +#include "MaterialLib/SolidModels/MechanicsBase.h" #include "NumLib/Extrapolation/ExtrapolatableElement.h" #include "ProcessLib/LocalAssemblerInterface.h" @@ -19,6 +20,7 @@ namespace ProcessLib { namespace ThermoMechanics { +template <int DisplacementDim> struct ThermoMechanicsLocalAssemblerInterface : public ProcessLib::LocalAssemblerInterface, public NumLib::ExtrapolatableElement @@ -44,6 +46,13 @@ struct ThermoMechanicsLocalAssemblerInterface std::vector<GlobalVector*> const& x, std::vector<NumLib::LocalToGlobalIndexMap const*> const& dof_table, std::vector<double>& cache) const = 0; + + // TODO move to NumLib::ExtrapolatableElement + virtual unsigned getNumberOfIntegrationPoints() const = 0; + + virtual typename MaterialLib::Solids::MechanicsBase< + DisplacementDim>::MaterialStateVariables const& + getMaterialStateVariablesAt(unsigned /*integration_point*/) const = 0; }; } // namespace ThermoMechanics diff --git a/ProcessLib/ThermoMechanics/ThermoMechanicsFEM-impl.h b/ProcessLib/ThermoMechanics/ThermoMechanicsFEM-impl.h index 91157581dd5937265c36c64c160dbee8aaab2f59..44499e06acf7b89900fc10a861fa767fe76f5090 100644 --- a/ProcessLib/ThermoMechanics/ThermoMechanicsFEM-impl.h +++ b/ProcessLib/ThermoMechanics/ThermoMechanicsFEM-impl.h @@ -753,5 +753,24 @@ ThermoMechanicsLocalAssembler<ShapeFunction, IntegrationMethod, return ip_epsilon_m_values; } +template <typename ShapeFunction, typename IntegrationMethod, + int DisplacementDim> +unsigned ThermoMechanicsLocalAssembler< + ShapeFunction, IntegrationMethod, + DisplacementDim>::getNumberOfIntegrationPoints() const +{ + return _integration_method.getNumberOfPoints(); +} + +template <typename ShapeFunction, typename IntegrationMethod, + int DisplacementDim> +typename MaterialLib::Solids::MechanicsBase< + DisplacementDim>::MaterialStateVariables const& +ThermoMechanicsLocalAssembler<ShapeFunction, IntegrationMethod, + DisplacementDim>:: + getMaterialStateVariablesAt(unsigned integration_point) const +{ + return *_ip_data[integration_point].material_state_variables; +} } // namespace ThermoMechanics } // namespace ProcessLib diff --git a/ProcessLib/ThermoMechanics/ThermoMechanicsFEM.h b/ProcessLib/ThermoMechanics/ThermoMechanicsFEM.h index 144c113791a103048f721238399ecc05d13eb461..2197ea7c1b6972a606840390cb34815b82b172b7 100644 --- a/ProcessLib/ThermoMechanics/ThermoMechanicsFEM.h +++ b/ProcessLib/ThermoMechanics/ThermoMechanicsFEM.h @@ -87,7 +87,7 @@ struct SecondaryData template <typename ShapeFunction, typename IntegrationMethod, int DisplacementDim> class ThermoMechanicsLocalAssembler - : public ThermoMechanicsLocalAssemblerInterface + : public ThermoMechanicsLocalAssemblerInterface<DisplacementDim> { public: using ShapeMatricesType = @@ -295,6 +295,14 @@ private: std::vector<double> getEpsilonMechanical() const override; + unsigned getNumberOfIntegrationPoints() const override; + + typename MaterialLib::Solids::MechanicsBase< + DisplacementDim>::MaterialStateVariables const& + getMaterialStateVariablesAt(unsigned integration_point) const override; + +private: + ThermoMechanicsProcessData<DisplacementDim>& _process_data; std::vector< diff --git a/ProcessLib/ThermoMechanics/ThermoMechanicsProcess.cpp b/ProcessLib/ThermoMechanics/ThermoMechanicsProcess.cpp index 5bba6a26d6e7718a2f281a6e10c19d4a624aaed2..477749f3a5cb92981fdba44f15e15bed2d9a7847 100644 --- a/ProcessLib/ThermoMechanics/ThermoMechanicsProcess.cpp +++ b/ProcessLib/ThermoMechanics/ThermoMechanicsProcess.cpp @@ -14,9 +14,9 @@ #include "NumLib/DOF/ComputeSparsityPattern.h" #include "NumLib/DOF/DOFTableUtil.h" +#include "ProcessLib/Deformation/SolidMaterialInternalToSecondaryVariables.h" #include "ProcessLib/Output/IntegrationPointWriter.h" #include "ProcessLib/SmallDeformation/CreateLocalAssemblers.h" - #include "ThermoMechanicsFEM.h" namespace ProcessLib @@ -178,21 +178,32 @@ void ThermoMechanicsProcess<DisplacementDim>::initializeConcreteProcess( mesh.getElements(), dof_table, _local_assemblers, mesh.isAxiallySymmetric(), integration_order, _process_data); - _secondary_variables.addSecondaryVariable( - "sigma", - makeExtrapolator( - MathLib::KelvinVector::KelvinVectorType< - DisplacementDim>::RowsAtCompileTime, - getExtrapolator(), _local_assemblers, - &ThermoMechanicsLocalAssemblerInterface::getIntPtSigma)); - - _secondary_variables.addSecondaryVariable( - "epsilon", - makeExtrapolator( - MathLib::KelvinVector::KelvinVectorType< - DisplacementDim>::RowsAtCompileTime, - getExtrapolator(), _local_assemblers, - &ThermoMechanicsLocalAssemblerInterface::getIntPtEpsilon)); + auto add_secondary_variable = [&](std::string const& name, + int const num_components, + auto get_ip_values_function) { + _secondary_variables.addSecondaryVariable( + name, + makeExtrapolator(num_components, getExtrapolator(), + _local_assemblers, + std::move(get_ip_values_function))); + }; + + add_secondary_variable("sigma", + MathLib::KelvinVector::KelvinVectorType< + DisplacementDim>::RowsAtCompileTime, + &LocalAssemblerInterface::getIntPtSigma); + + add_secondary_variable("epsilon", + MathLib::KelvinVector::KelvinVectorType< + DisplacementDim>::RowsAtCompileTime, + &LocalAssemblerInterface::getIntPtEpsilon); + + // + // enable output of internal variables defined by material models + // + ProcessLib::Deformation::solidMaterialInternalToSecondaryVariables< + LocalAssemblerInterface>(_process_data.solid_materials, + add_secondary_variable); // Set initial conditions for integration point data. for (auto const& ip_writer : _integration_point_writer) @@ -392,9 +403,9 @@ void ThermoMechanicsProcess<DisplacementDim>::preTimestepConcreteProcess( if (process_id == _process_data.mechanics_process_id) { GlobalExecutor::executeSelectedMemberOnDereferenced( - &ThermoMechanicsLocalAssemblerInterface::preTimestep, - _local_assemblers, pv.getActiveElementIDs(), - *_local_to_global_index_map, *x[process_id], t, dt); + &LocalAssemblerInterface::preTimestep, _local_assemblers, + pv.getActiveElementIDs(), *_local_to_global_index_map, + *x[process_id], t, dt); return; } @@ -429,9 +440,9 @@ void ThermoMechanicsProcess<DisplacementDim>::postTimestepConcreteProcess( ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0]; GlobalExecutor::executeSelectedMemberOnDereferenced( - &ThermoMechanicsLocalAssemblerInterface::postTimestep, - _local_assemblers, pv.getActiveElementIDs(), - *_local_to_global_index_map, *x[process_id], t, dt); + &LocalAssemblerInterface::postTimestep, _local_assemblers, + pv.getActiveElementIDs(), *_local_to_global_index_map, *x[process_id], + t, dt); } template <int DisplacementDim> diff --git a/ProcessLib/ThermoMechanics/ThermoMechanicsProcess.h b/ProcessLib/ThermoMechanics/ThermoMechanicsProcess.h index 9a7563b936706677b98ca35dd4cd820d0fb4552b..d4597f9cd58470125fb92ed3bec62105bf48f290 100644 --- a/ProcessLib/ThermoMechanics/ThermoMechanicsProcess.h +++ b/ProcessLib/ThermoMechanics/ThermoMechanicsProcess.h @@ -19,8 +19,6 @@ namespace ProcessLib { namespace ThermoMechanics { -struct ThermoMechanicsLocalAssemblerInterface; - template <int DisplacementDim> class ThermoMechanicsProcess final : public Process { @@ -57,6 +55,9 @@ public: const int process_id) const override; private: + using LocalAssemblerInterface = + ThermoMechanicsLocalAssemblerInterface<DisplacementDim>; + void constructDofTable() override; void initializeConcreteProcess( @@ -91,8 +92,7 @@ private: private: ThermoMechanicsProcessData<DisplacementDim> _process_data; - std::vector<std::unique_ptr<ThermoMechanicsLocalAssemblerInterface>> - _local_assemblers; + std::vector<std::unique_ptr<LocalAssemblerInterface>> _local_assemblers; std::unique_ptr<NumLib::LocalToGlobalIndexMap> _local_to_global_index_map_single_component;