OGS
TH2MFEM.h
Go to the documentation of this file.
1
11#pragma once
12
13#include <memory>
14#include <vector>
15
33
34namespace ProcessLib
35{
36namespace TH2M
37{
40template <typename ShapeMatrixType>
42{
43 std::vector<ShapeMatrixType, Eigen::aligned_allocator<ShapeMatrixType>> N_u;
44};
45
46template <typename ShapeFunctionDisplacement, typename ShapeFunctionPressure,
47 int DisplacementDim>
48class TH2MLocalAssembler : public LocalAssemblerInterface<DisplacementDim>
49{
50public:
53
56
57 template <int N>
58 using VectorType =
59 typename ShapeMatricesTypePressure::template VectorType<N>;
60
61 template <int M, int N>
62 using MatrixType =
63 typename ShapeMatricesTypePressure::template MatrixType<M, N>;
64
67
70
71 static int const KelvinVectorSize =
73 using SymmetricTensor = Eigen::Matrix<double, KelvinVectorSize, 1>;
74
75 static constexpr auto& N_u_op = MathLib::eigenBlockMatrixView<
76 DisplacementDim,
78
80
83
85 MeshLib::Element const& e,
86 std::size_t const /*local_matrix_size*/,
87 NumLib::GenericIntegrationMethod const& integration_method,
88 bool const is_axially_symmetric,
90
91private:
94 std::string_view const name,
95 double const* values,
96 int const integration_order) override;
97
98 void setInitialConditionsConcrete(Eigen::VectorXd const local_x,
99 double const t,
100 int const process_id) override;
101
102 void assemble(double const /*t*/, double const /*dt*/,
103 std::vector<double> const& /*local_x*/,
104 std::vector<double> const& /*local_x_prev*/,
105 std::vector<double>& /*local_M_data*/,
106 std::vector<double>& /*local_K_data*/,
107 std::vector<double>& /*local_rhs_data*/) override;
108
109 void assembleWithJacobian(double const t, double const dt,
110 std::vector<double> const& local_x,
111 std::vector<double> const& local_x_prev,
112 std::vector<double>& local_rhs_data,
113 std::vector<double>& local_Jac_data) override;
114
115 void initializeConcrete() override
116 {
117 unsigned const n_integration_points =
119
120 for (unsigned ip = 0; ip < n_integration_points; ip++)
121 {
122 auto& ip_data = _ip_data[ip];
123
124 ParameterLib::SpatialPosition const x_position{
125 std::nullopt, this->element_.getID(), ip,
127 ShapeFunctionDisplacement,
129 ip_data.N_u))};
130
132 if (this->process_data_.initial_stress.value)
133 {
134 this->current_states_[ip].eff_stress_data.sigma.noalias() =
136 DisplacementDim>(
137 (*this->process_data_.initial_stress.value)(
138 std::numeric_limits<
139 double>::quiet_NaN() /* time independent */,
140 x_position));
141 }
142
143 double const t = 0; // TODO (naumov) pass t from top
144 auto& material_state = this->material_states_[ip];
145 this->solid_material_.initializeInternalStateVariables(
146 t, x_position, *material_state.material_state_variables);
147
148 material_state.pushBackState();
149 }
150
151 for (unsigned ip = 0; ip < n_integration_points; ip++)
152 {
153 this->prev_states_[ip] = this->current_states_[ip];
154 }
155 }
156
157 void postTimestepConcrete(Eigen::VectorXd const& /*local_x*/,
158 Eigen::VectorXd const& /*local_x_prev*/,
159 double const /*t*/, double const /*dt*/,
160 int const /*process_id*/) override
161 {
162 unsigned const n_integration_points =
164
165 for (unsigned ip = 0; ip < n_integration_points; ip++)
166 {
167 this->material_states_[ip].pushBackState();
168 }
169
170 for (unsigned ip = 0; ip < n_integration_points; ip++)
171 {
172 this->prev_states_[ip] = this->current_states_[ip];
173 }
174 }
175
177 double const t, double const dt, Eigen::VectorXd const& local_x,
178 Eigen::VectorXd const& local_x_prev) override;
179
180 Eigen::Map<const Eigen::RowVectorXd> getShapeMatrix(
181 const unsigned integration_point) const override
182 {
183 auto const& N_u = _secondary_data.N_u[integration_point];
184
185 // assumes N is stored contiguously in memory
186 return Eigen::Map<const Eigen::RowVectorXd>(N_u.data(), N_u.size());
187 }
188
189 std::tuple<
190 std::vector<ConstitutiveRelations::ConstitutiveData<DisplacementDim>>,
191 std::vector<
194 Eigen::VectorXd const& local_x, Eigen::VectorXd const& local_x_prev,
195 double const t, double const dt,
197 models);
198
199 std::vector<ConstitutiveRelations::DerivativesData<DisplacementDim>>
201 Eigen::VectorXd const& local_x, Eigen::VectorXd const& local_x_prev,
202 double const t, double const dt,
203 std::vector<
205 ip_constitutive_data,
206 std::vector<
208 ip_constitutive_variables,
210 models);
211
212private:
217 std::vector<IpData> _ip_data;
218
220 typename ShapeMatricesTypeDisplacement::ShapeMatrices::ShapeType>
222
223 // The shape function of pressure has the same form with the shape function
224 // of temperature
225 static const int gas_pressure_index = 0;
226 static const int gas_pressure_size = ShapeFunctionPressure::NPOINTS;
227 static const int capillary_pressure_index = ShapeFunctionPressure::NPOINTS;
228 static const int capillary_pressure_size = ShapeFunctionPressure::NPOINTS;
229 static const int temperature_index = 2 * ShapeFunctionPressure::NPOINTS;
230 static const int temperature_size = ShapeFunctionPressure::NPOINTS;
231 static const int displacement_index = ShapeFunctionPressure::NPOINTS * 3;
232 static const int displacement_size =
233 ShapeFunctionDisplacement::NPOINTS * DisplacementDim;
234
235 static const int C_index = 0;
236 static const int C_size = ShapeFunctionPressure::NPOINTS;
237 static const int W_index = ShapeFunctionPressure::NPOINTS;
238 static const int W_size = ShapeFunctionPressure::NPOINTS;
239};
240
241} // namespace TH2M
242} // namespace ProcessLib
243
244#include "TH2MFEM-impl.h"
std::size_t getID() const
Returns the ID of the element.
Definition Element.h:89
void assemble(double const, double const, std::vector< double > const &, std::vector< double > const &, std::vector< double > &, std::vector< double > &, std::vector< double > &) override
std::size_t setIPDataInitialConditions(std::string_view const name, double const *values, int const integration_order) override
static constexpr auto & N_u_op
Definition TH2MFEM.h:75
static const int capillary_pressure_index
Definition TH2MFEM.h:227
ShapeMatrixPolicyType< ShapeFunctionDisplacement, DisplacementDim > ShapeMatricesTypeDisplacement
Definition TH2MFEM.h:51
Eigen::Matrix< double, KelvinVectorSize, 1 > SymmetricTensor
Definition TH2MFEM.h:73
typename ShapeMatricesTypePressure::template VectorType< N > VectorType
Definition TH2MFEM.h:58
std::vector< ConstitutiveRelations::DerivativesData< DisplacementDim > > updateConstitutiveVariablesDerivatives(Eigen::VectorXd const &local_x, Eigen::VectorXd const &local_x_prev, double const t, double const dt, std::vector< ConstitutiveRelations::ConstitutiveData< DisplacementDim > > const &ip_constitutive_data, std::vector< ConstitutiveRelations::ConstitutiveTempData< DisplacementDim > > const &ip_constitutive_variables, ConstitutiveRelations::ConstitutiveModels< DisplacementDim > const &models)
SecondaryData< typename ShapeMatricesTypeDisplacement::ShapeMatrices::ShapeType > _secondary_data
Definition TH2MFEM.h:221
void postTimestepConcrete(Eigen::VectorXd const &, Eigen::VectorXd const &, double const, double const, int const) override
Definition TH2MFEM.h:157
static const int capillary_pressure_size
Definition TH2MFEM.h:228
TH2MLocalAssembler(TH2MLocalAssembler &&)=delete
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
typename ShapeMatricesTypePressure::template MatrixType< M, N > MatrixType
Definition TH2MFEM.h:62
Eigen::Map< const Eigen::RowVectorXd > getShapeMatrix(const unsigned integration_point) const override
Provides the shape matrix at the given integration point.
Definition TH2MFEM.h:180
static const int gas_pressure_index
Definition TH2MFEM.h:225
static int const KelvinVectorSize
Definition TH2MFEM.h:71
TH2MLocalAssembler(TH2MLocalAssembler const &)=delete
std::tuple< std::vector< ConstitutiveRelations::ConstitutiveData< DisplacementDim > >, std::vector< ConstitutiveRelations::ConstitutiveTempData< DisplacementDim > > > updateConstitutiveVariables(Eigen::VectorXd const &local_x, Eigen::VectorXd const &local_x_prev, double const t, double const dt, ConstitutiveRelations::ConstitutiveModels< DisplacementDim > const &models)
void computeSecondaryVariableConcrete(double const t, double const dt, Eigen::VectorXd const &local_x, Eigen::VectorXd const &local_x_prev) override
typename ShapeMatricesTypePressure::GlobalDimVectorType GlobalDimVectorType
Definition TH2MFEM.h:68
typename ShapeMatricesTypePressure::GlobalDimMatrixType GlobalDimMatrixType
Definition TH2MFEM.h:65
void setInitialConditionsConcrete(Eigen::VectorXd const local_x, double const t, int const process_id) override
static const int displacement_index
Definition TH2MFEM.h:231
std::vector< IpData > _ip_data
Definition TH2MFEM.h:217
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)
constexpr Eigen::CwiseNullaryOp< EigenBlockMatrixViewFunctor< D, M >, typename EigenBlockMatrixViewFunctor< D, M >::Matrix > eigenBlockMatrixView(const Eigen::MatrixBase< M > &matrix)
std::array< double, 3 > interpolateCoordinates(MeshLib::Element const &e, typename ShapeMatricesType::ShapeMatrices::ShapeType const &N)
MatrixType< GlobalDim, GlobalDim > GlobalDimMatrixType
VectorType< GlobalDim > GlobalDimVectorType
RowVectorType< ShapeFunction::NPOINTS > NodalRowVectorType
std::vector< ShapeMatrixType, Eigen::aligned_allocator< ShapeMatrixType > > N_u
Data that is needed for the equation system assembly.
NumLib::GenericIntegrationMethod const & integration_method_
TH2MProcessData< DisplacementDim > & process_data_
ConstitutiveRelations::SolidConstitutiveRelation< DisplacementDim > const & solid_material_
std::vector< typename ConstitutiveRelations::StatefulData< DisplacementDim > > current_states_
std::vector< typename ConstitutiveRelations::StatefulDataPrev< DisplacementDim > > prev_states_
std::vector< ConstitutiveRelations::MaterialStateData< DisplacementDim > > material_states_
std::vector< ShapeMatrixType, Eigen::aligned_allocator< ShapeMatrixType > > N_u
Definition TH2MFEM.h:43