39 DisplacementDim, ConstitutiveTraits>::
40 ThermoRichardsMechanicsLocalAssembler(
44 bool const is_axially_symmetric,
48 e, integration_method, is_axially_symmetric, process_data)
50 unsigned const n_integration_points =
53 ip_data_.resize(n_integration_points);
55 auto const shape_matrices_u =
58 DisplacementDim>(e, is_axially_symmetric,
61 auto const shape_matrices =
63 DisplacementDim>(e, is_axially_symmetric,
66 for (
unsigned ip = 0; ip < n_integration_points; ip++)
69 auto const& sm_u = shape_matrices_u[ip];
72 sm_u.integralMeasure * sm_u.detJ;
75 ip_data.dNdx_u = sm_u.dNdx;
78 ip_data.N_p = shape_matrices[ip].N;
79 ip_data.dNdx_p = shape_matrices[ip].dNdx;
87 ConstitutiveTraits>::setInitialConditionsConcrete(Eigen::VectorXd
const
92 assert(local_x.size() ==
93 temperature_size + pressure_size + displacement_size);
95 auto const p_L = local_x.template segment<pressure_size>(pressure_index);
97 local_x.template segment<temperature_size>(temperature_index);
99 constexpr double dt = std::numeric_limits<double>::quiet_NaN();
101 *this->process_data_.media_map.getMedium(this->element_.getID());
105 typename ConstitutiveTraits::ConstitutiveSetting
const constitutive_setting;
106 auto models = ConstitutiveTraits::createConstitutiveModels(
107 this->process_data_, this->solid_material_);
109 unsigned const n_integration_points =
110 this->integration_method_.getNumberOfPoints();
111 for (
unsigned ip = 0; ip < n_integration_points; ip++)
114 auto const& N = ip_data_[ip].N_p;
117 std::nullopt, this->element_.getID(), ip,
121 this->element_, ip_data_[ip].N_u))};
131 if (medium.hasProperty(MPL::PropertyType::saturation))
141 medium.property(MPL::PropertyType::saturation)
142 .template value<double>(variables, x_position, t, dt);
143 std::get<PrevState<SaturationData>>(this->prev_states_[ip])->S_L =
149 constitutive_setting.init(models, t, dt, x_position, media_data,
150 {T_ip, 0, {}}, this->current_states_[ip],
151 this->prev_states_[ip]);
153 if (this->process_data_.initial_stress.value)
155 if (!medium.hasProperty(MPL::PropertyType::saturation))
158 "The medium has no saturation property required to compute "
161 convertInitialStressType(ip, t, x_position, medium, variables,
171 ConstitutiveTraits>::
172 convertInitialStressType(
unsigned const ip,
177 double const p_at_ip)
179 bool constexpr is_strain_temperature_constitutive =
182 ConstitutiveTraits>::value;
183 if (is_strain_temperature_constitutive &&
184 this->process_data_.initial_stress.type ==
190 if (!is_strain_temperature_constitutive &&
196 double const alpha_b =
197 medium.
property(MPL::PropertyType::biot_coefficient)
198 .template value<double>(variables, x_position, t, 0.0 );
200 double const bishop =
201 medium.
property(MPL::PropertyType::bishops_effective_stress)
202 .template value<double>(variables, x_position, t, 0.0 );
204 ConstitutiveTraits::ConstitutiveSetting::convertInitialStressType(
205 this->current_states_[ip], this->prev_states_[ip],
206 bishop * alpha_b * p_at_ip * Invariants::identity2);
213 ConstitutiveTraits>::
214 assembleWithJacobian(
double const t,
double const dt,
215 std::vector<double>
const& local_x,
216 std::vector<double>
const& local_x_prev,
217 std::vector<double>& local_rhs_data,
218 std::vector<double>& local_Jac_data)
221 *this->process_data_.media_map.getMedium(this->element_.getID());
228 typename ConstitutiveTraits::ConstitutiveSetting constitutive_setting;
230 for (
unsigned ip = 0; ip < this->integration_method_.getNumberOfPoints();
234 std::nullopt, this->element_.getID(), ip,
238 this->element_, ip_data_[ip].N_u))};
240 assembleWithJacobianSingleIP(
242 local_x, local_x_prev,
243 ip_data_[ip], constitutive_setting,
246 this->current_states_[ip], this->prev_states_[ip],
247 this->material_states_[ip], this->output_data_[ip]);
248 loc_mat += loc_mat_current_ip;
251 massLumping(loc_mat);
253 addToLocalMatrixData(dt, local_x, local_x_prev, loc_mat, local_rhs_data,
281 ConstitutiveTraits>::
282 addToLocalMatrixData(
284 std::vector<double>
const& local_x,
285 std::vector<double>
const& local_x_prev,
287 ShapeFunctionDisplacement, ShapeFunction, DisplacementDim,
288 ConstitutiveTraits>::LocalMatrices
const& loc_mat,
289 std::vector<double>& local_rhs_data,
290 std::vector<double>& local_Jac_data)
const
292 constexpr auto local_matrix_dim =
293 displacement_size + pressure_size + temperature_size;
294 assert(local_x.size() == local_matrix_dim);
297 typename ShapeMatricesTypeDisplacement::template MatrixType<
298 local_matrix_dim, local_matrix_dim>>(
299 local_Jac_data, local_matrix_dim, local_matrix_dim);
303 template VectorType<local_matrix_dim>>(
304 local_rhs_data, local_matrix_dim);
306 local_Jac.noalias() = loc_mat.Jac;
307 local_rhs.noalias() = -loc_mat.res;
312 block_TT(local_Jac).noalias() += loc_mat.M_TT / dt + loc_mat.K_TT;
313 block_Tp(local_Jac).noalias() +=
314 loc_mat.K_Tp + loc_mat.dK_TT_dp + loc_mat.M_Tp / dt;
316 block_pT(local_Jac).noalias() += loc_mat.M_pT / dt + loc_mat.K_pT;
317 block_pp(local_Jac).noalias() +=
318 loc_mat.K_pp + loc_mat.storage_p_a_p / dt + loc_mat.storage_p_a_S_Jpp;
319 block_pu(local_Jac).noalias() = loc_mat.M_pu / dt;
324 auto const [T, p_L, u] = localDOF(local_x);
325 auto const [T_prev, p_L_prev, u_prev] = localDOF(local_x_prev);
327 block_T(local_rhs).noalias() -= loc_mat.M_TT * (T - T_prev) / dt +
328 loc_mat.K_TT * T + loc_mat.K_Tp * p_L +
329 loc_mat.M_Tp * (p_L - p_L_prev) / dt;
330 block_p(local_rhs).noalias() -=
331 loc_mat.K_pp * p_L + loc_mat.K_pT * T +
332 (loc_mat.storage_p_a_p + loc_mat.storage_p_a_S) * (p_L - p_L_prev) /
334 loc_mat.M_pu * (u - u_prev) / dt + loc_mat.M_pT * (T - T_prev) / dt;
341 ConstitutiveTraits>::
342 assembleWithJacobianSingleIP(
343 double const t,
double const dt,
345 std::vector<double>
const& local_x,
346 std::vector<double>
const& local_x_prev,
348 ShapeFunctionDisplacement, ShapeFunction, DisplacementDim,
349 ConstitutiveTraits>::IpData
const& ip_data,
350 typename ConstitutiveTraits::ConstitutiveSetting& CS,
353 ShapeFunctionDisplacement, ShapeFunction, DisplacementDim,
354 ConstitutiveTraits>::LocalMatrices& out,
355 typename ConstitutiveTraits::StatefulData& current_state,
356 typename ConstitutiveTraits::StatefulDataPrev
const& prev_state,
358 typename ConstitutiveTraits::OutputData& output_data)
const
360 auto const& N_u = ip_data.N_u;
361 auto const& dNdx_u = ip_data.dNdx_u;
364 auto const& N = ip_data.N_p;
365 auto const& dNdx = ip_data.dNdx_p;
369 ShapeFunctionDisplacement::NPOINTS,
372 this->is_axially_symmetric_);
374 typename ConstitutiveTraits::ConstitutiveData CD;
376 auto const [T, p_L, u] = localDOF(local_x);
377 auto const [T_prev, p_L_prev, u_prev] = localDOF(local_x_prev);
380 auto models = ConstitutiveTraits::createConstitutiveModels(
381 this->process_data_, this->solid_material_);
382 typename ConstitutiveTraits::ConstitutiveTempData tmp;
384 double const T_ip = N * T;
385 double const T_prev_ip = N * T_prev;
388 double const p_cap_ip = -N * p_L;
389 double const p_cap_prev_ip = -N * p_L_prev;
394 CS.eval(models, t, dt, x_position,
396 {T_ip, T_prev_ip, grad_T_ip},
397 {p_cap_ip, p_cap_prev_ip, grad_p_cap_ip},
398 eps, current_state, prev_state, mat_state, tmp, output_data,
403 NodalMatrix
const NTN = N.transpose() * N;
404 NodalMatrix
const dNTdN = dNdx.transpose() * dNdx;
409 DisplacementDim)>::identity2;
410 typename ShapeMatricesTypeDisplacement::template MatrixType<
411 displacement_size, pressure_size>
412 BTI2N = B.transpose() * identity2 * N;
434 block_p(out.res).noalias() =
435 dNdx.transpose() * std::get<EqPData<DisplacementDim>>(CD).rhs_p_dNT_V;
436 block_u(out.res).noalias() =
441 static_cast<int>(this->process_data_.apply_body_force_for_deformation) *
442 N_u_op(N_u).transpose() *
443 std::get<GravityData<DisplacementDim>>(CD).volumetric_body_force;
446 out.storage_p_a_p.noalias() =
447 std::get<EqPData<DisplacementDim>>(CD).storage_p_a_p_X_NTN * NTN;
448 out.storage_p_a_S.noalias() =
449 std::get<TRMStorageData>(CD).storage_p_a_S_X_NTN * NTN;
450 out.storage_p_a_S_Jpp.noalias() =
451 std::get<TRMStorageData>(CD).storage_p_a_S_Jpp_X_NTN * NTN;
455 std::get<EqTData<DisplacementDim>>(CD).M_TT_X_NTN * NTN;
457 std::get<TRMVaporDiffusionData<DisplacementDim>>(CD).M_Tp_X_NTN * NTN;
460 std::get<EqPData<DisplacementDim>>(CD).M_pT_X_NTN * NTN;
462 std::get<EqPData<DisplacementDim>>(CD).M_pu_X_BTI2N * BTI2N.transpose();
467 std::get<TRMHeatStorageAndFluxData<DisplacementDim>>(CD)
471 (std::get<EqTData<DisplacementDim>>(CD).K_TT_NT_V_dN.transpose() *
473 std::get<TRMVaporDiffusionData<DisplacementDim>>(CD).K_TT_X_dNTdN *
476 out.dK_TT_dp.noalias() =
478 (std::get<TRMHeatStorageAndFluxData<DisplacementDim>>(CD)
479 .K_Tp_NT_V_dN.transpose() *
481 std::get<TRMHeatStorageAndFluxData<DisplacementDim>>(CD).K_Tp_X_NTN *
485 std::get<ThermoOsmosisData<DisplacementDim>>(CD).K_Tp_Laplace *
491 dNdx.transpose() * std::get<EqPData<DisplacementDim>>(CD).K_pp_Laplace *
497 std::get<ThermoOsmosisData<DisplacementDim>>(CD).K_pT_Laplace * dNdx;
500 block_pT(out.Jac).noalias() =
501 std::get<TRMVaporDiffusionData<DisplacementDim>>(CD).J_pT_X_dNTdN *
503 block_pp(out.Jac).noalias() =
504 std::get<TRMStorageData>(CD).J_pp_X_NTN * NTN +
505 std::get<EqPData<DisplacementDim>>(CD).J_pp_X_BTI2NT_u_dot_N *
506 BTI2N.transpose() * (u - u_prev) / dt *
509 std::get<EqPData<DisplacementDim>>(CD).J_pp_dNT_V_N * N;
511 block_uT(out.Jac).noalias() =
513 std::get<SolidMechanicsDataStateless<DisplacementDim>>(CD).J_uT_BT_K_N *
515 block_up(out.Jac).noalias() =
517 std::get<SolidMechanicsDataStateless<DisplacementDim>>(CD)
520 N_u_op(N_u).transpose() *
521 std::get<GravityData<DisplacementDim>>(CD).J_up_HT_V_N * N;
522 block_uu(out.Jac).noalias() =
524 std::get<SolidMechanicsDataStateless<DisplacementDim>>(CD)
528 out *= ip_data.integration_weight;
535 ConstitutiveTraits>::
536 computeSecondaryVariableConcrete(
double const t,
double const dt,
537 Eigen::VectorXd
const& local_x,
538 Eigen::VectorXd
const& local_x_prev)
540 auto const T = block_T(local_x);
541 auto const p_L = block_p(local_x);
542 auto const u = block_u(local_x);
544 auto const T_prev = block_T(local_x_prev);
545 auto const p_L_prev = block_p(local_x_prev);
547 auto const e_id = this->element_.getID();
548 auto const& process_data = this->process_data_;
549 auto& medium = *process_data.media_map.getMedium(e_id);
551 unsigned const n_integration_points =
552 this->integration_method_.getNumberOfPoints();
554 typename ConstitutiveTraits::ConstitutiveSetting constitutive_setting;
556 auto models = ConstitutiveTraits::createConstitutiveModels(
557 process_data, this->solid_material_);
558 typename ConstitutiveTraits::ConstitutiveTempData tmp;
559 typename ConstitutiveTraits::ConstitutiveData CD;
561 for (
unsigned ip = 0; ip < n_integration_points; ip++)
563 auto& current_state = this->current_states_[ip];
564 auto& output_data = this->output_data_[ip];
566 auto const& ip_data = ip_data_[ip];
569 auto const& N = ip_data.N_p;
570 auto const& N_u = ip_data.N_u;
571 auto const& dNdx_u = ip_data.dNdx_u;
572 auto const& dNdx = ip_data.dNdx_p;
575 std::nullopt, this->element_.getID(), ip,
579 this->element_, N_u))};
583 this->element_, N_u);
586 ShapeFunctionDisplacement::NPOINTS,
588 dNdx_u, N_u, x_coord, this->is_axially_symmetric_);
590 double const T_ip = N * T;
591 double const T_prev_ip = N * T_prev;
594 double const p_cap_ip = -N * p_L;
595 double const p_cap_prev_ip = -N * p_L_prev;
600 constitutive_setting.eval(models,
603 {T_ip, T_prev_ip, grad_T_ip},
604 {p_cap_ip, p_cap_prev_ip, grad_p_cap_ip},
605 eps, current_state, this->prev_states_[ip],
606 this->material_states_[ip], tmp, output_data,
611 ShapeFunction,
typename ShapeFunctionDisplacement::MeshElement,
612 DisplacementDim>(this->element_, this->is_axially_symmetric_, p_L,
613 *process_data.pressure_interpolated);
615 ShapeFunction,
typename ShapeFunctionDisplacement::MeshElement,
616 DisplacementDim>(this->element_, this->is_axially_symmetric_, T,
617 *process_data.temperature_interpolated);