OGS
ThermoMechanicsFEM.h
Go to the documentation of this file.
1
11#pragma once
12
13#include <memory>
14#include <vector>
15
29
30namespace ProcessLib
31{
32namespace ThermoMechanics
33{
34namespace MPL = MaterialPropertyLib;
35
36template <typename BMatricesType, typename ShapeMatricesType,
37 int DisplacementDim>
39{
48
49 // total stress
50 typename BMatricesType::KelvinVectorType sigma, sigma_prev;
51
52 // total strain
53 typename BMatricesType::KelvinVectorType eps, eps_prev;
54
55 // mechanical strain
56 typename BMatricesType::KelvinVectorType eps_m, eps_m_prev;
57
59 std::unique_ptr<typename MaterialLib::Solids::MechanicsBase<
60 DisplacementDim>::MaterialStateVariables>
62
64 typename ShapeMatricesType::NodalRowVectorType N;
65 typename ShapeMatricesType::GlobalDimNodalMatrixType dNdx;
66
68 {
69 eps_prev = eps;
72 material_state_variables->pushBackState();
73 }
74
76};
77
80template <typename ShapeMatrixType>
82{
83 std::vector<ShapeMatrixType, Eigen::aligned_allocator<ShapeMatrixType>> N;
84};
85
126template <typename ShapeFunction, int DisplacementDim>
128 : public ThermoMechanicsLocalAssemblerInterface<DisplacementDim>
129{
130public:
133
134 // Types for displacement.
135 // (Higher order elements = ShapeFunction).
139
140 static int const KelvinVectorSize =
143
145 using RhsVector = typename ShapeMatricesType::template VectorType<
146 ShapeFunction::NPOINTS + ShapeFunction::NPOINTS * DisplacementDim>;
147 using JacobianMatrix = typename ShapeMatricesType::template MatrixType<
148 ShapeFunction::NPOINTS + ShapeFunction::NPOINTS * DisplacementDim,
149 ShapeFunction::NPOINTS + ShapeFunction::NPOINTS * DisplacementDim>;
150 using IpData =
152
154 delete;
156
158 MeshLib::Element const& e,
159 std::size_t const /*local_matrix_size*/,
160 NumLib::GenericIntegrationMethod const& integration_method,
161 bool const is_axially_symmetric,
163
165 std::size_t setIPDataInitialConditions(
166 std::string_view const name,
167 double const* values,
168 int const integration_order) override;
169
170 void assemble(double const /*t*/, double const /*dt*/,
171 std::vector<double> const& /*local_x*/,
172 std::vector<double> const& /*local_x_prev*/,
173 std::vector<double>& /*local_M_data*/,
174 std::vector<double>& /*local_K_data*/,
175 std::vector<double>& /*local_rhs_data*/) override
176 {
177 OGS_FATAL(
178 "ThermoMechanicsLocalAssembler: assembly without jacobian is not "
179 "implemented.");
180 }
181
183 double const t, double const dt, Eigen::VectorXd const& local_x,
184 Eigen::VectorXd const& local_x_prev, int const process_id,
185 std::vector<double>& local_b_data,
186 std::vector<double>& local_Jac_data) override;
187
188 void assembleWithJacobian(double const t, double const dt,
189 std::vector<double> const& local_x,
190 std::vector<double> const& local_x_prev,
191 std::vector<double>& local_rhs_data,
192 std::vector<double>& local_Jac_data) override;
193
194 void initializeConcrete() override
195 {
196 unsigned const n_integration_points =
198 for (unsigned ip = 0; ip < n_integration_points; ip++)
199 {
200 auto& ip_data = _ip_data[ip];
201
202 ParameterLib::SpatialPosition const x_position{
203 std::nullopt, _element.getID(), ip,
205 NumLib::interpolateCoordinates<ShapeFunction,
207 _element, ip_data.N))};
208
210 if (_process_data.initial_stress != nullptr)
211 {
212 ip_data.sigma =
214 DisplacementDim>((*_process_data.initial_stress)(
215 std::numeric_limits<
216 double>::quiet_NaN() /* time independent */,
217 x_position));
218 }
219
220 double const t = 0; // TODO (naumov) pass t from top
221 ip_data.solid_material.initializeInternalStateVariables(
222 t, x_position, *ip_data.material_state_variables);
223
224 ip_data.pushBackState();
225 }
226 }
227
228 void postTimestepConcrete(Eigen::VectorXd const& /*local_x*/,
229 Eigen::VectorXd const& /*local_x_prev*/,
230 double const /*t*/, double const /*dt*/,
231 int const /*process_id*/) override
232 {
233 unsigned const n_integration_points =
235
236 for (unsigned ip = 0; ip < n_integration_points; ip++)
237 {
238 _ip_data[ip].pushBackState();
239 }
240 }
241
242 Eigen::Map<const Eigen::RowVectorXd> getShapeMatrix(
243 const unsigned integration_point) const override
244 {
245 auto const& N = _secondary_data.N[integration_point];
246
247 // assumes N is stored contiguously in memory
248 return Eigen::Map<const Eigen::RowVectorXd>(N.data(), N.size());
249 }
250
251private:
275 const double t, double const dt, Eigen::VectorXd const& local_x,
276 Eigen::VectorXd const& local_x_prev, std::vector<double>& local_b_data,
277 std::vector<double>& local_Jac_data);
278
300 const double t, double const dt, Eigen::VectorXd const& local_x,
301 Eigen::VectorXd const& local_x_prev, std::vector<double>& local_b_data,
302 std::vector<double>& local_Jac_data);
303
304 std::size_t setSigma(double const* values);
305
306 // TODO (naumov) This method is same as getIntPtSigma but for arguments and
307 // the ordering of the cache_mat.
308 // There should be only one.
309 std::vector<double> getSigma() const override;
310
311 std::vector<double> const& getIntPtSigma(
312 const double t,
313 std::vector<GlobalVector*> const& x,
314 std::vector<NumLib::LocalToGlobalIndexMap const*> const& dof_table,
315 std::vector<double>& cache) const override;
316
317 std::size_t setEpsilon(double const* values);
318
319 std::vector<double> getEpsilon() const override;
320
321 std::vector<double> const& getIntPtEpsilon(
322 const double t,
323 std::vector<GlobalVector*> const& x,
324 std::vector<NumLib::LocalToGlobalIndexMap const*> const& dof_table,
325 std::vector<double>& cache) const override;
326
327 std::vector<double> const& getIntPtEpsilonMechanical(
328 const double t,
329 std::vector<GlobalVector*> const& x,
330 std::vector<NumLib::LocalToGlobalIndexMap const*> const& dof_table,
331 std::vector<double>& cache) const override;
332
333 std::size_t setEpsilonMechanical(double const* values);
334
335 std::vector<double> getEpsilonMechanical() const override;
336
337 unsigned getNumberOfIntegrationPoints() const override;
338
339 int getMaterialID() const override;
340
342 DisplacementDim>::MaterialStateVariables const&
343 getMaterialStateVariablesAt(unsigned integration_point) const override;
344
345private:
347
348 std::vector<IpData, Eigen::aligned_allocator<IpData>> _ip_data;
349
354
355 static const int temperature_index = 0;
356 static const int temperature_size = ShapeFunction::NPOINTS;
357 static const int displacement_index = ShapeFunction::NPOINTS;
358 static const int displacement_size =
359 ShapeFunction::NPOINTS * DisplacementDim;
360};
361
362} // namespace ThermoMechanics
363} // namespace ProcessLib
364
#define OGS_FATAL(...)
Definition Error.h:26
std::size_t getID() const
Returns the ID of the element.
Definition Element.h:89
VectorType< _number_of_dof > NodalForceVectorType
Rhs residual.
std::vector< double > const & getIntPtEpsilonMechanical(const double t, std::vector< GlobalVector * > const &x, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_table, std::vector< double > &cache) const override
typename BMatricesType::NodalForceVectorType NodalForceVectorType
SecondaryData< typename ShapeMatrices::ShapeType > _secondary_data
std::size_t setIPDataInitialConditions(std::string_view const name, double const *values, int const integration_order) override
Returns number of read integration points.
typename ShapeMatricesType::template MatrixType< ShapeFunction::NPOINTS+ShapeFunction::NPOINTS *DisplacementDim, ShapeFunction::NPOINTS+ShapeFunction::NPOINTS *DisplacementDim > JacobianMatrix
std::vector< double > const & getIntPtSigma(const double t, std::vector< GlobalVector * > const &x, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_table, std::vector< double > &cache) const override
void postTimestepConcrete(Eigen::VectorXd const &, Eigen::VectorXd const &, double const, double const, int const) override
ThermoMechanicsLocalAssembler(ThermoMechanicsLocalAssembler const &)=delete
MaterialLib::Solids::MechanicsBase< DisplacementDim >::MaterialStateVariables const & getMaterialStateVariablesAt(unsigned integration_point) const override
typename ShapeMatricesType::template VectorType< ShapeFunction::NPOINTS+ShapeFunction::NPOINTS *DisplacementDim > RhsVector
Eigen::Map< const Eigen::RowVectorXd > getShapeMatrix(const unsigned integration_point) const override
Provides the shape matrix at the given integration point.
ThermoMechanicsProcessData< DisplacementDim > & _process_data
NumLib::GenericIntegrationMethod const & _integration_method
void assembleWithJacobianForHeatConductionEquations(const double t, double const dt, Eigen::VectorXd const &local_x, Eigen::VectorXd const &local_x_prev, std::vector< double > &local_b_data, std::vector< double > &local_Jac_data)
void assembleWithJacobianForDeformationEquations(const double t, double const dt, Eigen::VectorXd const &local_x, Eigen::VectorXd const &local_x_prev, std::vector< double > &local_b_data, std::vector< double > &local_Jac_data)
void assembleWithJacobianForStaggeredScheme(double const t, double const dt, Eigen::VectorXd const &local_x, Eigen::VectorXd const &local_x_prev, int const process_id, std::vector< double > &local_b_data, std::vector< double > &local_Jac_data) override
void assemble(double const, double const, std::vector< double > const &, std::vector< double > const &, std::vector< double > &, std::vector< double > &, std::vector< double > &) override
typename ShapeMatricesType::ShapeMatrices ShapeMatrices
typename ShapeMatricesType::GlobalDimMatrixType GlobalDimMatrixType
ThermoMechanicsLocalAssembler(ThermoMechanicsLocalAssembler &&)=delete
std::vector< IpData, Eigen::aligned_allocator< IpData > > _ip_data
std::vector< double > const & getIntPtEpsilon(const double t, std::vector< GlobalVector * > const &x, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_table, std::vector< double > &cache) const override
void assembleWithJacobian(double const t, double const dt, std::vector< double > const &local_x, std::vector< double > const &local_x_prev, std::vector< double > &local_rhs_data, std::vector< double > &local_Jac_data) override
constexpr int kelvin_vector_dimensions(int const displacement_dim)
Kelvin vector dimensions for given displacement dimension.
Eigen::Matrix< double, Eigen::MatrixBase< Derived >::RowsAtCompileTime, 1 > symmetricTensorToKelvinVector(Eigen::MatrixBase< Derived > const &v)
std::array< double, 3 > interpolateCoordinates(MeshLib::Element const &e, typename ShapeMatricesType::ShapeMatrices::ShapeType const &N)
NumLib::ShapeMatrices< NodalRowVectorType, DimNodalMatrixType, DimMatrixType, GlobalDimNodalMatrixType > ShapeMatrices
MatrixType< GlobalDim, GlobalDim > GlobalDimMatrixType
MaterialLib::Solids::MechanicsBase< DisplacementDim > const & solid_material
ShapeMatricesType::NodalRowVectorType N
std::unique_ptr< typename MaterialLib::Solids::MechanicsBase< DisplacementDim >::MaterialStateVariables > material_state_variables
ShapeMatricesType::GlobalDimNodalMatrixType dNdx
IntegrationPointData(MaterialLib::Solids::MechanicsBase< DisplacementDim > const &solid_material)
std::vector< ShapeMatrixType, Eigen::aligned_allocator< ShapeMatrixType > > N