From d28b746dc93eab176e2ff5c78337415eb0c9eddf Mon Sep 17 00:00:00 2001 From: Christoph Lehmann <christoph.lehmann@ufz.de> Date: Wed, 19 Jul 2017 16:55:20 +0200 Subject: [PATCH] [PL] added vectorial output for small deformation sigma, eps --- .../LocalAssemblerInterface.h | 14 ++++ .../SmallDeformation/SmallDeformationFEM.h | 80 +++++++++++++++++++ .../SmallDeformationProcess-impl.h | 17 ++++ 3 files changed, 111 insertions(+) diff --git a/ProcessLib/SmallDeformation/LocalAssemblerInterface.h b/ProcessLib/SmallDeformation/LocalAssemblerInterface.h index e29ecb9d75b..9bb2c3edfc4 100644 --- a/ProcessLib/SmallDeformation/LocalAssemblerInterface.h +++ b/ProcessLib/SmallDeformation/LocalAssemblerInterface.h @@ -24,6 +24,13 @@ struct SmallDeformationLocalAssemblerInterface : public ProcessLib::LocalAssemblerInterface, public NumLib::ExtrapolatableElement { + virtual std::vector<double> const& getIntPtSigma( + const double /*t*/, + GlobalVector const& /*current_solution*/, + NumLib::LocalToGlobalIndexMap const& /*dof_table*/, + std::vector<double>& cache) const = 0; + + // TODO remove the component-wise methods. virtual std::vector<double> const& getIntPtSigmaXX( const double /*t*/, GlobalVector const& /*current_solution*/, @@ -60,6 +67,13 @@ struct SmallDeformationLocalAssemblerInterface NumLib::LocalToGlobalIndexMap const& /*dof_table*/, std::vector<double>& cache) const = 0; + virtual std::vector<double> const& getIntPtEpsilon( + const double /*t*/, + GlobalVector const& /*current_solution*/, + NumLib::LocalToGlobalIndexMap const& /*dof_table*/, + std::vector<double>& cache) const = 0; + + // TODO remove the component-wise methods virtual std::vector<double> const& getIntPtEpsilonXX( const double /*t*/, GlobalVector const& /*current_solution*/, diff --git a/ProcessLib/SmallDeformation/SmallDeformationFEM.h b/ProcessLib/SmallDeformation/SmallDeformationFEM.h index 201b6516c68..f1bf21ba097 100644 --- a/ProcessLib/SmallDeformation/SmallDeformationFEM.h +++ b/ProcessLib/SmallDeformation/SmallDeformationFEM.h @@ -242,6 +242,46 @@ public: return Eigen::Map<const Eigen::RowVectorXd>(N.data(), N.size()); } + std::vector<double> const& getIntPtSigma( + const double /*t*/, + GlobalVector const& /*current_solution*/, + NumLib::LocalToGlobalIndexMap const& /*dof_table*/, + std::vector<double>& cache) const override + { + using KelvinVectorType = typename BMatricesType::KelvinVectorType; + auto const kelvin_vector_size = + KelvinVectorDimensions<DisplacementDim>::value; + auto const num_intpts = _ip_data.size(); + + cache.clear(); + auto cache_mat = MathLib::createZeroedMatrix<Eigen::Matrix< + double, kelvin_vector_size, Eigen::Dynamic, Eigen::RowMajor>>( + cache, kelvin_vector_size, num_intpts); + + // TODO make a general implementation for converting KelvinVectors + // back to symmetric rank-2 tensors. + for (unsigned ip = 0; ip < num_intpts; ++ip) + { + auto const& sigma = _ip_data[ip].sigma; + + for (typename KelvinVectorType::Index component = 0; + component < kelvin_vector_size && component < 3; + ++component) + { // xx, yy, zz components + cache_mat(component, ip) = sigma[component]; + } + for (typename KelvinVectorType::Index component = 3; + component < kelvin_vector_size; + ++component) + { // mixed xy, yz, xz components + cache_mat(component, ip) = sigma[component] / std::sqrt(2); + } + } + + return cache; + } + + // TODO remove the component-wise methods. std::vector<double> const& getIntPtSigmaXX( const double /*t*/, GlobalVector const& /*current_solution*/, @@ -298,6 +338,46 @@ public: return getIntPtSigma(cache, 5); } + virtual std::vector<double> const& getIntPtEpsilon( + const double /*t*/, + GlobalVector const& /*current_solution*/, + NumLib::LocalToGlobalIndexMap const& /*dof_table*/, + std::vector<double>& cache) const override + { + using KelvinVectorType = typename BMatricesType::KelvinVectorType; + auto const kelvin_vector_size = + KelvinVectorDimensions<DisplacementDim>::value; + auto const num_intpts = _ip_data.size(); + + cache.clear(); + auto cache_mat = MathLib::createZeroedMatrix<Eigen::Matrix< + double, kelvin_vector_size, Eigen::Dynamic, Eigen::RowMajor>>( + cache, kelvin_vector_size, num_intpts); + + // TODO make a general implementation for converting KelvinVectors + // back to symmetric rank-2 tensors. + for (unsigned ip = 0; ip < num_intpts; ++ip) + { + auto const& eps = _ip_data[ip].eps; + + for (typename KelvinVectorType::Index component = 0; + component < kelvin_vector_size && component < 3; + ++component) + { // xx, yy, zz components + cache_mat(component, ip) = eps[component]; + } + for (typename KelvinVectorType::Index component = 3; + component < kelvin_vector_size; + ++component) + { // mixed xy, yz, xz components + cache_mat(component, ip) = eps[component] / std::sqrt(2); + } + } + + return cache; + } + + // TODO remove the component-wise methods std::vector<double> const& getIntPtEpsilonXX( const double /*t*/, GlobalVector const& /*current_solution*/, diff --git a/ProcessLib/SmallDeformation/SmallDeformationProcess-impl.h b/ProcessLib/SmallDeformation/SmallDeformationProcess-impl.h index 633f1e00c49..dd9363a9f20 100644 --- a/ProcessLib/SmallDeformation/SmallDeformationProcess-impl.h +++ b/ProcessLib/SmallDeformation/SmallDeformationProcess-impl.h @@ -69,6 +69,14 @@ void SmallDeformationProcess<DisplacementDim>::initializeConcreteProcess( NumLib::ComponentOrder::BY_LOCATION); _nodal_forces->resize(DisplacementDim * mesh.getNumberOfNodes()); + Base::_secondary_variables.addSecondaryVariable( + "sigma", + makeExtrapolator( + ProcessLib::KelvinVectorType<DisplacementDim>::RowsAtCompileTime, + getExtrapolator(), _local_assemblers, + &LocalAssemblerInterface::getIntPtSigma)); + + // TODO remove the component-wise methods Base::_secondary_variables.addSecondaryVariable( "sigma_xx", makeExtrapolator(1, getExtrapolator(), _local_assemblers, @@ -102,6 +110,14 @@ void SmallDeformationProcess<DisplacementDim>::initializeConcreteProcess( &LocalAssemblerInterface::getIntPtSigmaYZ)); } + Base::_secondary_variables.addSecondaryVariable( + "epsilon", + makeExtrapolator( + ProcessLib::KelvinVectorType<DisplacementDim>::RowsAtCompileTime, + getExtrapolator(), _local_assemblers, + &LocalAssemblerInterface::getIntPtEpsilon)); + + // TODO remove the component-wise methods Base::_secondary_variables.addSecondaryVariable( "epsilon_xx", makeExtrapolator(1, getExtrapolator(), _local_assemblers, @@ -134,6 +150,7 @@ void SmallDeformationProcess<DisplacementDim>::initializeConcreteProcess( &LocalAssemblerInterface::getIntPtEpsilonXZ)); } + // enable output of internal variables defined by material models auto const internal_variables = _process_data.material->getInternalVariables(); for (auto const& internal_variable : internal_variables) -- GitLab