28namespace MPL = MaterialPropertyLib;
30template <
typename ShapeFunctionDisplacement,
typename ShapeFunctionPressure,
33 ShapeFunctionPressure, DisplacementDim>::
34 HydroMechanicsLocalAssemblerMatrix(
36 std::size_t
const n_variables,
38 std::vector<unsigned>
const& dofIndex_to_localIndex,
40 bool const is_axially_symmetric,
43 e, is_axially_symmetric, integration_method,
44 (n_variables - 1) * ShapeFunctionDisplacement::NPOINTS *
46 ShapeFunctionPressure::NPOINTS,
47 dofIndex_to_localIndex),
50 unsigned const n_integration_points =
53 _ip_data.reserve(n_integration_points);
56 auto const shape_matrices_u =
59 DisplacementDim>(e, is_axially_symmetric,
62 auto const shape_matrices_p =
65 e, is_axially_symmetric, integration_method);
72 for (
unsigned ip = 0; ip < n_integration_points; ip++)
74 _ip_data.emplace_back(solid_material);
76 auto const& sm_u = shape_matrices_u[ip];
77 auto const& sm_p = shape_matrices_p[ip];
79 ip_data.integration_weight =
80 sm_u.detJ * sm_u.integralMeasure *
82 ip_data.darcy_velocity.setZero();
85 ip_data.dNdx_u = sm_u.dNdx;
87 for (
int i = 0; i < DisplacementDim; ++i)
92 .noalias() = ip_data.N_u;
96 ip_data.dNdx_p = sm_p.dNdx;
107 auto const initial_effective_stress =
111 ip_data.sigma_eff[i] = initial_effective_stress[i];
112 ip_data.sigma_eff_prev[i] = initial_effective_stress[i];
117template <
typename ShapeFunctionDisplacement,
typename ShapeFunctionPressure,
120 ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim>::
121 assembleWithJacobianConcrete(
double const t,
double const dt,
122 Eigen::VectorXd
const& local_x,
123 Eigen::VectorXd
const& local_x_prev,
124 Eigen::VectorXd& local_rhs,
125 Eigen::MatrixXd& local_Jac)
127 auto p =
const_cast<Eigen::VectorXd&
>(local_x).segment(
pressure_index,
139 auto rhs_p = local_rhs.template segment<pressure_size>(
pressure_index);
143 auto J_pp = local_Jac.template block<pressure_size, pressure_size>(
145 auto J_pu = local_Jac.template block<pressure_size, displacement_size>(
147 auto J_uu = local_Jac.template block<displacement_size, displacement_size>(
149 auto J_up = local_Jac.template block<displacement_size, pressure_size>(
153 J_pp, J_pu, J_uu, J_up);
156template <
typename ShapeFunctionDisplacement,
typename ShapeFunctionPressure,
159 ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim>::
160 assembleBlockMatricesWithJacobian(
161 double const t,
double const dt,
162 Eigen::Ref<const Eigen::VectorXd>
const& p,
163 Eigen::Ref<const Eigen::VectorXd>
const& p_prev,
164 Eigen::Ref<const Eigen::VectorXd>
const& u,
165 Eigen::Ref<const Eigen::VectorXd>
const& u_prev,
166 Eigen::Ref<Eigen::VectorXd> rhs_p, Eigen::Ref<Eigen::VectorXd> rhs_u,
167 Eigen::Ref<Eigen::MatrixXd> J_pp, Eigen::Ref<Eigen::MatrixXd> J_pu,
168 Eigen::Ref<Eigen::MatrixXd> J_uu, Eigen::Ref<Eigen::MatrixXd> J_up)
170 assert(this->
_element.getDimension() == DisplacementDim);
173 ShapeMatricesTypePressure::NodalMatrixType::Zero(
pressure_size,
177 ShapeMatricesTypePressure::NodalMatrixType::Zero(
pressure_size,
180 typename ShapeMatricesTypeDisplacement::template MatrixType<
182 Kup = ShapeMatricesTypeDisplacement::template MatrixType<
194 auto const& liquid_phase =
196 auto const& solid_phase =
201 .template value<double>(variables, x_position, t, dt);
205 bool const has_storage_property =
210 unsigned const n_integration_points =
_ip_data.size();
211 for (
unsigned ip = 0; ip < n_integration_points; ip++)
214 auto const& ip_w = ip_data.integration_weight;
215 auto const& N_u = ip_data.N_u;
216 auto const& dNdx_u = ip_data.dNdx_u;
217 auto const& N_p = ip_data.N_p;
218 auto const& dNdx_p = ip_data.dNdx_p;
219 auto const& H_u = ip_data.H_u;
234 DisplacementDim, ShapeFunctionDisplacement::NPOINTS,
239 auto const& eps_prev = ip_data.eps_prev;
240 auto const& sigma_eff_prev = ip_data.sigma_eff_prev;
241 auto& sigma_eff = ip_data.sigma_eff;
243 auto& eps = ip_data.eps;
244 auto& state = ip_data.material_state_variables;
248 .template value<double>(variables, x_position, t, dt);
251 .template value<double>(variables, x_position, t, dt);
255 .template value<double>(variables, x_position, t, dt);
256 auto const porosity =
258 .template value<double>(variables, x_position, t, dt);
260 double const rho = rho_sr * (1 - porosity) + porosity * rho_fr;
261 auto const& identity2 =
264 eps.noalias() = B * u;
278 auto&& solution =
_ip_data[ip].solid_material.integrateStress(
279 variables_prev, variables, t, x_position, dt, *state);
283 OGS_FATAL(
"Computation of local constitutive relation failed.");
287 std::tie(sigma_eff, state, C) = std::move(*solution);
289 J_uu.noalias() += (B.transpose() * C * B) * ip_w;
291 rhs_u.noalias() -= B.transpose() * sigma_eff * ip_w;
292 rhs_u.noalias() -= -H_u.transpose() * rho * gravity_vec * ip_w;
301 Kup.noalias() += B.transpose() * alpha * identity2 * N_p * ip_w;
306 .template value<double>(variables, x_position, t, dt);
308 auto const k_over_mu =
311 .value(variables, x_position, t, dt)) /
318 .template value<double>(variables, x_position, t, dt)
321 .
template dValue<double>(
326 (alpha - porosity) * (1.0 - alpha) /
327 _ip_data[ip].solid_material.getBulkModulus(
330 auto q = ip_data.darcy_velocity.head(DisplacementDim);
331 q.noalias() = -k_over_mu * (dNdx_p * p + rho_fr * gravity_vec);
333 laplace_p.noalias() +=
334 dNdx_p.transpose() * k_over_mu * dNdx_p * ip_w;
335 storage_p.noalias() += N_p.transpose() * S * N_p * ip_w;
338 dNdx_p.transpose() * rho_fr * k_over_mu * gravity_vec * ip_w;
343 J_up.noalias() -= Kup;
346 J_pp.noalias() += laplace_p + storage_p / dt;
349 J_pu.noalias() += Kup.transpose() / dt;
352 rhs_p.noalias() -= laplace_p * p + storage_p * (p - p_prev) / dt +
353 Kup.transpose() * (u - u_prev) / dt;
356 rhs_u.noalias() -= -Kup * p;
359template <
typename ShapeFunctionDisplacement,
typename ShapeFunctionPressure,
362 ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim>::
363 postTimestepConcreteWithVector(
double const t,
double const dt,
364 Eigen::VectorXd
const& local_x)
366 auto p =
const_cast<Eigen::VectorXd&
>(local_x).segment(
pressure_index,
377template <
typename ShapeFunctionDisplacement,
typename ShapeFunctionPressure,
380 ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim>::
381 postTimestepConcreteWithBlockVectors(
382 double const t,
double const dt,
383 Eigen::Ref<const Eigen::VectorXd>
const& p,
384 Eigen::Ref<const Eigen::VectorXd>
const& u)
394 KV sigma_avg = KV::Zero();
396 velocity_avg.setZero();
398 unsigned const n_integration_points =
_ip_data.size();
401 auto const& liquid_phase =
405 .template value<double>(variables, x_position, t, dt);
411 for (
unsigned ip = 0; ip < n_integration_points; ip++)
415 auto const& eps_prev = ip_data.eps_prev;
416 auto const& sigma_eff_prev = ip_data.sigma_eff_prev;
418 auto& eps = ip_data.eps;
419 auto& sigma_eff = ip_data.sigma_eff;
420 auto& state = ip_data.material_state_variables;
422 auto const& N_u = ip_data.N_u;
423 auto const& N_p = ip_data.N_p;
424 auto const& dNdx_u = ip_data.dNdx_u;
439 DisplacementDim, ShapeFunctionDisplacement::NPOINTS,
444 eps.noalias() = B * u;
457 auto&& solution =
_ip_data[ip].solid_material.integrateStress(
458 variables_prev, variables, t, x_position, dt, *state);
462 OGS_FATAL(
"Computation of local constitutive relation failed.");
466 std::tie(sigma_eff, state, C) = std::move(*solution);
468 sigma_avg += ip_data.sigma_eff;
475 .template value<double>(variables, x_position, t, dt);
479 .template value<double>(variables, x_position, t, dt);
483 .value(variables, x_position, t, dt))
489 auto const& dNdx_p = ip_data.dNdx_p;
491 ip_data.darcy_velocity.head(DisplacementDim).noalias() =
492 -k_over_mu * (dNdx_p * p + rho_fr * gravity_vec);
493 velocity_avg.noalias() +=
494 ip_data.darcy_velocity.head(DisplacementDim);
498 sigma_avg /= n_integration_points;
499 velocity_avg /= n_integration_points;
502 &(*
_process_data.element_stresses)[e_id * KV::RowsAtCompileTime]) =
505 Eigen::Map<DisplacementDimVector>(
506 &(*
_process_data.element_velocities)[e_id * DisplacementDim]) =
510 ShapeFunctionPressure,
typename ShapeFunctionDisplacement::MeshElement,
515template <
typename ShapeFunctionDisplacement,
typename ShapeFunctionPressure,
518 ShapeFunctionDisplacement, ShapeFunctionPressure,
520 Eigen::Ref<Eigen::VectorXd> p)
537template <
typename ShapeFunctionDisplacement,
typename ShapeFunctionPressure,
540 ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim>::
543 std::vector<GlobalVector*>
const& ,
544 std::vector<NumLib::LocalToGlobalIndexMap const*>
const& ,
545 std::vector<double>& cache)
const
550template <
typename ShapeFunctionDisplacement,
typename ShapeFunctionPressure,
553 ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim>::
556 std::vector<GlobalVector*>
const& ,
557 std::vector<NumLib::LocalToGlobalIndexMap const*>
const& ,
558 std::vector<double>& cache)
const
564template <
typename ShapeFunctionDisplacement,
typename ShapeFunctionPressure,
567 ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim>::
568 getIntPtDarcyVelocity(
570 std::vector<GlobalVector*>
const& ,
571 std::vector<NumLib::LocalToGlobalIndexMap const*>
const& ,
572 std::vector<double>& cache)
const
574 unsigned const n_integration_points =
_ip_data.size();
578 double, DisplacementDim, Eigen::Dynamic, Eigen::RowMajor>>(
579 cache, DisplacementDim, n_integration_points);
581 for (
unsigned ip = 0; ip < n_integration_points; ip++)
583 cache_matrix.col(ip).noalias() =
_ip_data[ip].darcy_velocity;
KelvinVector mechanical_strain
double liquid_phase_pressure
constexpr double getWeight() const
std::size_t getID() const
Returns the ID of the element.
MathLib::WeightedPoint const & getWeightedPoint(unsigned const igp) const
unsigned getNumberOfPoints() const
void setNodeID(std::size_t node_id)
void setElementID(std::size_t element_id)
std::optional< MathLib::Point3d > const getCoordinates() const
MatrixType< _kelvin_vector_size, _number_of_dof > BMatrixType
bool const _is_axially_symmetric
MeshLib::Element const & _element
HydroMechanicsLocalAssemblerInterface(MeshLib::Element const &element, bool const is_axially_symmetric, NumLib::GenericIntegrationMethod const &integration_method, std::size_t n_local_size, std::vector< unsigned > dofIndex_to_localIndex)
HydroMechanicsProcessData< DisplacementDim > & _process_data
std::vector< IntegrationPointDataType, Eigen::aligned_allocator< IntegrationPointDataType > > _ip_data
typename BMatricesType::BBarMatrixType BBarMatrixType
typename ShapeMatricesTypePressure::GlobalDimMatrixType GlobalDimMatrixType
ShapeMatrixPolicyType< ShapeFunctionDisplacement, DisplacementDim > ShapeMatricesTypeDisplacement
void postTimestepConcreteWithBlockVectors(double const t, double const dt, Eigen::Ref< const Eigen::VectorXd > const &p, Eigen::Ref< const Eigen::VectorXd > const &u)
ShapeMatrixPolicyType< ShapeFunctionPressure, DisplacementDim > ShapeMatricesTypePressure
static const int displacement_size
static const int pressure_size
static const int displacement_index
std::optional< BBarMatrixType > getDilatationalBBarMatrix() const
static const int kelvin_vector_size
SecondaryData< typename ShapeMatricesTypeDisplacement::ShapeMatrices::ShapeType > _secondary_data
void assembleBlockMatricesWithJacobian(double const t, double const dt, Eigen::Ref< const Eigen::VectorXd > const &p, Eigen::Ref< const Eigen::VectorXd > const &p_prev, Eigen::Ref< const Eigen::VectorXd > const &u, Eigen::Ref< const Eigen::VectorXd > const &u_prev, Eigen::Ref< Eigen::VectorXd > rhs_p, Eigen::Ref< Eigen::VectorXd > rhs_u, Eigen::Ref< Eigen::MatrixXd > J_pp, Eigen::Ref< Eigen::MatrixXd > J_pu, Eigen::Ref< Eigen::MatrixXd > J_uu, Eigen::Ref< Eigen::MatrixXd > J_up)
Eigen::Matrix< double, DisplacementDim, 1 > DisplacementDimVector
void setPressureOfInactiveNodes(double const t, Eigen::Ref< Eigen::VectorXd > p)
static const int pressure_index
auto & selectSolidConstitutiveRelation(SolidMaterialsMap const &constitutive_relations, MeshLib::PropertyVector< int > const *const material_ids, std::size_t const element_id)
constexpr Eigen::Matrix< double, GlobalDim, GlobalDim > formEigenTensor(MaterialPropertyLib::PropertyDataType const &values)
Eigen::Matrix< double, 4, 1 > kelvinVectorToSymmetricTensor(Eigen::Matrix< double, 4, 1, Eigen::ColMajor, 4, 1 > const &v)
Eigen::Matrix< double, kelvin_vector_dimensions(DisplacementDim), 1, Eigen::ColMajor > KelvinVectorType
Eigen::Matrix< double, kelvin_vector_dimensions(DisplacementDim), kelvin_vector_dimensions(DisplacementDim), Eigen::RowMajor > KelvinMatrixType
Eigen::Map< Matrix > createZeroedMatrix(std::vector< double > &data, Eigen::MatrixXd::Index rows, Eigen::MatrixXd::Index cols)
void interpolateToHigherOrderNodes(MeshLib::Element const &element, bool const is_axially_symmetric, Eigen::MatrixBase< EigenMatrixType > const &node_values, MeshLib::PropertyVector< double > &interpolated_values_global_vector)
std::vector< typename ShapeMatricesType::ShapeMatrices, Eigen::aligned_allocator< typename ShapeMatricesType::ShapeMatrices > > initShapeMatrices(MeshLib::Element const &e, bool const is_axially_symmetric, IntegrationMethod const &integration_method)
std::array< double, 3 > interpolateCoordinates(MeshLib::Element const &e, typename ShapeMatricesType::ShapeMatrices::ShapeType const &N)
BMatrixType computeBMatrixPossiblyWithBbar(DNDX_Type const &dNdx, N_Type const &N, std::optional< BBarMatrixType > const &B_dil_bar, const double radius, const bool is_axially_symmetric)
Fills a B matrix, or a B bar matrix if required.
std::vector< double > const & getIntegrationPointKelvinVectorData(IntegrationPointDataVector const &ip_data_vector, MemberType IpData::*const member, std::vector< double > &cache)
MatrixType< ShapeFunction::NPOINTS, ShapeFunction::NPOINTS > NodalMatrixType
static Eigen::Matrix< double, KelvinVectorSize, 1 > const identity2
Kelvin mapping of 2nd order identity tensor.
BMatricesType::KelvinVectorType eps
BMatricesType::KelvinVectorType sigma_eff