27namespace MPL = MaterialPropertyLib;
29template <
typename ShapeFunctionDisplacement,
typename ShapeFunctionPressure,
32 ShapeFunctionPressure, DisplacementDim>::
33 HydroMechanicsLocalAssemblerMatrix(
35 std::size_t
const n_variables,
37 std::vector<unsigned>
const& dofIndex_to_localIndex,
39 bool const is_axially_symmetric,
42 e, is_axially_symmetric, integration_method,
43 (n_variables - 1) * ShapeFunctionDisplacement::NPOINTS *
45 ShapeFunctionPressure::NPOINTS,
46 dofIndex_to_localIndex),
49 unsigned const n_integration_points =
52 _ip_data.reserve(n_integration_points);
55 auto const shape_matrices_u =
58 DisplacementDim>(e, is_axially_symmetric,
61 auto const shape_matrices_p =
64 e, is_axially_symmetric, integration_method);
71 for (
unsigned ip = 0; ip < n_integration_points; ip++)
73 _ip_data.emplace_back(solid_material);
75 auto const& sm_u = shape_matrices_u[ip];
76 auto const& sm_p = shape_matrices_p[ip];
78 ip_data.integration_weight =
79 sm_u.detJ * sm_u.integralMeasure *
81 ip_data.darcy_velocity.setZero();
84 ip_data.dNdx_u = sm_u.dNdx;
86 for (
int i = 0; i < DisplacementDim; ++i)
91 .noalias() = ip_data.N_u;
95 ip_data.dNdx_p = sm_p.dNdx;
106 auto const initial_effective_stress =
110 ip_data.sigma_eff[i] = initial_effective_stress[i];
111 ip_data.sigma_eff_prev[i] = initial_effective_stress[i];
116template <
typename ShapeFunctionDisplacement,
typename ShapeFunctionPressure,
119 ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim>::
120 assembleWithJacobianConcrete(
double const t,
double const dt,
121 Eigen::VectorXd
const& local_x,
122 Eigen::VectorXd
const& local_x_prev,
123 Eigen::VectorXd& local_rhs,
124 Eigen::MatrixXd& local_Jac)
126 auto p =
const_cast<Eigen::VectorXd&
>(local_x).segment(
pressure_index,
138 auto rhs_p = local_rhs.template segment<pressure_size>(
pressure_index);
142 auto J_pp = local_Jac.template block<pressure_size, pressure_size>(
144 auto J_pu = local_Jac.template block<pressure_size, displacement_size>(
146 auto J_uu = local_Jac.template block<displacement_size, displacement_size>(
148 auto J_up = local_Jac.template block<displacement_size, pressure_size>(
152 J_pp, J_pu, J_uu, J_up);
155template <
typename ShapeFunctionDisplacement,
typename ShapeFunctionPressure,
158 ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim>::
159 assembleBlockMatricesWithJacobian(
160 double const t,
double const dt,
161 Eigen::Ref<const Eigen::VectorXd>
const& p,
162 Eigen::Ref<const Eigen::VectorXd>
const& p_prev,
163 Eigen::Ref<const Eigen::VectorXd>
const& u,
164 Eigen::Ref<const Eigen::VectorXd>
const& u_prev,
165 Eigen::Ref<Eigen::VectorXd> rhs_p, Eigen::Ref<Eigen::VectorXd> rhs_u,
166 Eigen::Ref<Eigen::MatrixXd> J_pp, Eigen::Ref<Eigen::MatrixXd> J_pu,
167 Eigen::Ref<Eigen::MatrixXd> J_uu, Eigen::Ref<Eigen::MatrixXd> J_up)
169 assert(this->
_element.getDimension() == DisplacementDim);
172 ShapeMatricesTypePressure::NodalMatrixType::Zero(
pressure_size,
176 ShapeMatricesTypePressure::NodalMatrixType::Zero(
pressure_size,
179 typename ShapeMatricesTypeDisplacement::template MatrixType<
181 Kup = ShapeMatricesTypeDisplacement::template MatrixType<
193 auto const& liquid_phase = medium->phase(
"AqueousLiquid");
194 auto const& solid_phase = medium->phase(
"Solid");
198 .template value<double>(variables, x_position, t, dt);
202 bool const has_storage_property =
207 unsigned const n_integration_points =
_ip_data.size();
208 for (
unsigned ip = 0; ip < n_integration_points; ip++)
211 auto const& ip_w = ip_data.integration_weight;
212 auto const& N_u = ip_data.N_u;
213 auto const& dNdx_u = ip_data.dNdx_u;
214 auto const& N_p = ip_data.N_p;
215 auto const& dNdx_p = ip_data.dNdx_p;
216 auto const& H_u = ip_data.H_u;
231 DisplacementDim, ShapeFunctionDisplacement::NPOINTS,
236 auto const& eps_prev = ip_data.eps_prev;
237 auto const& sigma_eff_prev = ip_data.sigma_eff_prev;
238 auto& sigma_eff = ip_data.sigma_eff;
240 auto& eps = ip_data.eps;
241 auto& state = ip_data.material_state_variables;
245 .template value<double>(variables, x_position, t, dt);
248 .template value<double>(variables, x_position, t, dt);
252 .template value<double>(variables, x_position, t, dt);
253 auto const porosity =
255 .template value<double>(variables, x_position, t, dt);
257 double const rho = rho_sr * (1 - porosity) + porosity * rho_fr;
258 auto const& identity2 =
261 eps.noalias() = B * u;
275 auto&& solution =
_ip_data[ip].solid_material.integrateStress(
276 variables_prev, variables, t, x_position, dt, *state);
280 OGS_FATAL(
"Computation of local constitutive relation failed.");
284 std::tie(sigma_eff, state, C) = std::move(*solution);
286 J_uu.noalias() += (B.transpose() * C * B) * ip_w;
288 rhs_u.noalias() -= B.transpose() * sigma_eff * ip_w;
289 rhs_u.noalias() -= -H_u.transpose() * rho * gravity_vec * ip_w;
298 Kup.noalias() += B.transpose() * alpha * identity2 * N_p * ip_w;
303 .template value<double>(variables, x_position, t, dt);
305 auto const k_over_mu =
308 .value(variables, x_position, t, dt)) /
315 .template value<double>(variables, x_position, t, dt)
318 .
template dValue<double>(
323 (alpha - porosity) * (1.0 - alpha) /
324 _ip_data[ip].solid_material.getBulkModulus(
327 auto q = ip_data.darcy_velocity.head(DisplacementDim);
328 q.noalias() = -k_over_mu * (dNdx_p * p + rho_fr * gravity_vec);
330 laplace_p.noalias() +=
331 dNdx_p.transpose() * k_over_mu * dNdx_p * ip_w;
332 storage_p.noalias() += N_p.transpose() * S * N_p * ip_w;
335 dNdx_p.transpose() * rho_fr * k_over_mu * gravity_vec * ip_w;
340 J_up.noalias() -= Kup;
343 J_pp.noalias() += laplace_p + storage_p / dt;
346 J_pu.noalias() += Kup.transpose() / dt;
349 rhs_p.noalias() -= laplace_p * p + storage_p * (p - p_prev) / dt +
350 Kup.transpose() * (u - u_prev) / dt;
353 rhs_u.noalias() -= -Kup * p;
356template <
typename ShapeFunctionDisplacement,
typename ShapeFunctionPressure,
359 ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim>::
360 postTimestepConcreteWithVector(
double const t,
double const dt,
361 Eigen::VectorXd
const& local_x)
363 auto p =
const_cast<Eigen::VectorXd&
>(local_x).segment(
pressure_index,
374template <
typename ShapeFunctionDisplacement,
typename ShapeFunctionPressure,
377 ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim>::
378 postTimestepConcreteWithBlockVectors(
379 double const t,
double const dt,
380 Eigen::Ref<const Eigen::VectorXd>
const& p,
381 Eigen::Ref<const Eigen::VectorXd>
const& u)
391 KV sigma_avg = KV::Zero();
393 velocity_avg.setZero();
395 unsigned const n_integration_points =
_ip_data.size();
398 auto const& liquid_phase = medium->phase(
"AqueousLiquid");
401 .template value<double>(variables, x_position, t, dt);
407 for (
unsigned ip = 0; ip < n_integration_points; ip++)
411 auto const& eps_prev = ip_data.eps_prev;
412 auto const& sigma_eff_prev = ip_data.sigma_eff_prev;
414 auto& eps = ip_data.eps;
415 auto& sigma_eff = ip_data.sigma_eff;
416 auto& state = ip_data.material_state_variables;
418 auto const& N_u = ip_data.N_u;
419 auto const& N_p = ip_data.N_p;
420 auto const& dNdx_u = ip_data.dNdx_u;
435 DisplacementDim, ShapeFunctionDisplacement::NPOINTS,
440 eps.noalias() = B * u;
453 auto&& solution =
_ip_data[ip].solid_material.integrateStress(
454 variables_prev, variables, t, x_position, dt, *state);
458 OGS_FATAL(
"Computation of local constitutive relation failed.");
462 std::tie(sigma_eff, state, C) = std::move(*solution);
464 sigma_avg += ip_data.sigma_eff;
471 .template value<double>(variables, x_position, t, dt);
475 .template value<double>(variables, x_position, t, dt);
479 .value(variables, x_position, t, dt))
485 auto const& dNdx_p = ip_data.dNdx_p;
487 ip_data.darcy_velocity.head(DisplacementDim).noalias() =
488 -k_over_mu * (dNdx_p * p + rho_fr * gravity_vec);
489 velocity_avg.noalias() +=
490 ip_data.darcy_velocity.head(DisplacementDim);
494 sigma_avg /= n_integration_points;
495 velocity_avg /= n_integration_points;
498 &(*
_process_data.element_stresses)[e_id * KV::RowsAtCompileTime]) =
501 Eigen::Map<DisplacementDimVector>(
502 &(*
_process_data.element_velocities)[e_id * DisplacementDim]) =
506 ShapeFunctionPressure,
typename ShapeFunctionDisplacement::MeshElement,
511template <
typename ShapeFunctionDisplacement,
typename ShapeFunctionPressure,
514 ShapeFunctionDisplacement, ShapeFunctionPressure,
516 Eigen::Ref<Eigen::VectorXd> p)
533template <
typename ShapeFunctionDisplacement,
typename ShapeFunctionPressure,
536 ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim>::
539 std::vector<GlobalVector*>
const& ,
540 std::vector<NumLib::LocalToGlobalIndexMap const*>
const& ,
541 std::vector<double>& cache)
const
546template <
typename ShapeFunctionDisplacement,
typename ShapeFunctionPressure,
549 ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim>::
552 std::vector<GlobalVector*>
const& ,
553 std::vector<NumLib::LocalToGlobalIndexMap const*>
const& ,
554 std::vector<double>& cache)
const
560template <
typename ShapeFunctionDisplacement,
typename ShapeFunctionPressure,
563 ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim>::
564 getIntPtDarcyVelocity(
566 std::vector<GlobalVector*>
const& ,
567 std::vector<NumLib::LocalToGlobalIndexMap const*>
const& ,
568 std::vector<double>& cache)
const
570 unsigned const n_integration_points =
_ip_data.size();
574 double, DisplacementDim, Eigen::Dynamic, Eigen::RowMajor>>(
575 cache, DisplacementDim, n_integration_points);
577 for (
unsigned ip = 0; ip < n_integration_points; ip++)
579 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