34namespace MPL = MaterialPropertyLib;
36template <
typename ShapeFunctionDisplacement,
typename ShapeFunctionPressure,
39 ShapeFunctionPressure, DisplacementDim>::
40 HydroMechanicsLocalAssemblerMatrix(
42 std::size_t
const n_variables,
44 std::vector<unsigned>
const& dofIndex_to_localIndex,
46 bool const is_axially_symmetric,
49 e, is_axially_symmetric, integration_method,
50 (n_variables - 1) * ShapeFunctionDisplacement::NPOINTS *
52 ShapeFunctionPressure::NPOINTS,
53 dofIndex_to_localIndex),
56 unsigned const n_integration_points =
59 _ip_data.reserve(n_integration_points);
62 auto const shape_matrices_u =
65 DisplacementDim>(e, is_axially_symmetric,
68 auto const shape_matrices_p =
71 e, is_axially_symmetric, integration_method);
78 for (
unsigned ip = 0; ip < n_integration_points; ip++)
80 _ip_data.emplace_back(solid_material);
82 auto const& sm_u = shape_matrices_u[ip];
83 auto const& sm_p = shape_matrices_p[ip];
85 ip_data.integration_weight =
86 sm_u.detJ * sm_u.integralMeasure *
88 ip_data.darcy_velocity.setZero();
91 ip_data.dNdx_u = sm_u.dNdx;
93 for (
int i = 0; i < DisplacementDim; ++i)
98 .noalias() = ip_data.N_u;
101 ip_data.N_p = sm_p.N;
102 ip_data.dNdx_p = sm_p.dNdx;
113 auto const initial_effective_stress =
117 ip_data.sigma_eff[i] = initial_effective_stress[i];
118 ip_data.sigma_eff_prev[i] = initial_effective_stress[i];
123template <
typename ShapeFunctionDisplacement,
typename ShapeFunctionPressure,
126 ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim>::
127 assembleWithJacobianConcrete(
double const t,
double const dt,
128 Eigen::VectorXd
const& local_x,
129 Eigen::VectorXd
const& local_x_prev,
130 Eigen::VectorXd& local_rhs,
131 Eigen::MatrixXd& local_Jac)
133 auto p =
const_cast<Eigen::VectorXd&
>(local_x).segment(
pressure_index,
145 auto rhs_p = local_rhs.template segment<pressure_size>(
pressure_index);
149 auto J_pp = local_Jac.template block<pressure_size, pressure_size>(
151 auto J_pu = local_Jac.template block<pressure_size, displacement_size>(
153 auto J_uu = local_Jac.template block<displacement_size, displacement_size>(
155 auto J_up = local_Jac.template block<displacement_size, pressure_size>(
159 J_pp, J_pu, J_uu, J_up);
162template <
typename ShapeFunctionDisplacement,
typename ShapeFunctionPressure,
165 ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim>::
166 assembleBlockMatricesWithJacobian(
167 double const t,
double const dt,
168 Eigen::Ref<const Eigen::VectorXd>
const& p,
169 Eigen::Ref<const Eigen::VectorXd>
const& p_prev,
170 Eigen::Ref<const Eigen::VectorXd>
const& u,
171 Eigen::Ref<const Eigen::VectorXd>
const& u_prev,
172 Eigen::Ref<Eigen::VectorXd> rhs_p, Eigen::Ref<Eigen::VectorXd> rhs_u,
173 Eigen::Ref<Eigen::MatrixXd> J_pp, Eigen::Ref<Eigen::MatrixXd> J_pu,
174 Eigen::Ref<Eigen::MatrixXd> J_uu, Eigen::Ref<Eigen::MatrixXd> J_up)
176 assert(this->
_element.getDimension() == DisplacementDim);
179 ShapeMatricesTypePressure::NodalMatrixType::Zero(
pressure_size,
183 ShapeMatricesTypePressure::NodalMatrixType::Zero(
pressure_size,
186 typename ShapeMatricesTypeDisplacement::template MatrixType<
188 Kup = ShapeMatricesTypeDisplacement::template MatrixType<
200 auto const& liquid_phase = medium->phase(
"AqueousLiquid");
201 auto const& solid_phase = medium->phase(
"Solid");
205 .template value<double>(variables, x_position, t, dt);
209 bool const has_storage_property =
214 unsigned const n_integration_points =
_ip_data.size();
215 for (
unsigned ip = 0; ip < n_integration_points; ip++)
218 auto const& ip_w = ip_data.integration_weight;
219 auto const& N_u = ip_data.N_u;
220 auto const& dNdx_u = ip_data.dNdx_u;
221 auto const& N_p = ip_data.N_p;
222 auto const& dNdx_p = ip_data.dNdx_p;
223 auto const& H_u = ip_data.H_u;
238 DisplacementDim, ShapeFunctionDisplacement::NPOINTS,
243 auto const& eps_prev = ip_data.eps_prev;
244 auto const& sigma_eff_prev = ip_data.sigma_eff_prev;
245 auto& sigma_eff = ip_data.sigma_eff;
247 auto& eps = ip_data.eps;
248 auto& state = ip_data.material_state_variables;
252 .template value<double>(variables, x_position, t, dt);
255 .template value<double>(variables, x_position, t, dt);
259 .template value<double>(variables, x_position, t, dt);
260 auto const porosity =
262 .template value<double>(variables, x_position, t, dt);
264 double const rho = rho_sr * (1 - porosity) + porosity * rho_fr;
265 auto const& identity2 =
268 eps.noalias() = B * u;
282 auto&& solution =
_ip_data[ip].solid_material.integrateStress(
283 variables_prev, variables, t, x_position, dt, *state);
287 OGS_FATAL(
"Computation of local constitutive relation failed.");
291 std::tie(sigma_eff, state, C) = std::move(*solution);
293 J_uu.noalias() += B.transpose() * C * B * ip_w;
295 rhs_u.noalias() -= B.transpose() * sigma_eff * ip_w;
296 rhs_u.noalias() -= -H_u.transpose() * rho * gravity_vec * ip_w;
305 Kup.noalias() += B.transpose() * alpha * identity2 * N_p * ip_w;
310 .template value<double>(variables, x_position, t, dt);
312 auto const k_over_mu =
315 .value(variables, x_position, t, dt)) /
322 .template value<double>(variables, x_position, t, dt)
325 .
template dValue<double>(
330 (alpha - porosity) * (1.0 - alpha) /
331 _ip_data[ip].solid_material.getBulkModulus(
334 auto q = ip_data.darcy_velocity.head(DisplacementDim);
335 q.noalias() = -k_over_mu * (dNdx_p * p + rho_fr * gravity_vec);
337 laplace_p.noalias() +=
338 dNdx_p.transpose() * k_over_mu * dNdx_p * ip_w;
339 storage_p.noalias() += N_p.transpose() * S * N_p * ip_w;
342 dNdx_p.transpose() * rho_fr * k_over_mu * gravity_vec * ip_w;
347 J_up.noalias() -= Kup;
350 J_pp.noalias() += laplace_p + storage_p / dt;
353 J_pu.noalias() += Kup.transpose() / dt;
356 rhs_p.noalias() -= laplace_p * p + storage_p * (p - p_prev) / dt +
357 Kup.transpose() * (u - u_prev) / dt;
360 rhs_u.noalias() -= -Kup * p;
363template <
typename ShapeFunctionDisplacement,
typename ShapeFunctionPressure,
366 ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim>::
367 postTimestepConcreteWithVector(
double const t,
double const dt,
368 Eigen::VectorXd
const& local_x)
370 auto p =
const_cast<Eigen::VectorXd&
>(local_x).segment(
pressure_index,
381template <
typename ShapeFunctionDisplacement,
typename ShapeFunctionPressure,
384 ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim>::
385 postTimestepConcreteWithBlockVectors(
386 double const t,
double const dt,
387 Eigen::Ref<const Eigen::VectorXd>
const& p,
388 Eigen::Ref<const Eigen::VectorXd>
const& u)
398 KV sigma_avg = KV::Zero();
400 velocity_avg.setZero();
402 unsigned const n_integration_points =
_ip_data.size();
405 auto const& liquid_phase = medium->phase(
"AqueousLiquid");
408 .template value<double>(variables, x_position, t, dt);
414 for (
unsigned ip = 0; ip < n_integration_points; ip++)
418 auto const& eps_prev = ip_data.eps_prev;
419 auto const& sigma_eff_prev = ip_data.sigma_eff_prev;
421 auto& eps = ip_data.eps;
422 auto& sigma_eff = ip_data.sigma_eff;
423 auto& state = ip_data.material_state_variables;
425 auto const& N_u = ip_data.N_u;
426 auto const& N_p = ip_data.N_p;
427 auto const& dNdx_u = ip_data.dNdx_u;
442 DisplacementDim, ShapeFunctionDisplacement::NPOINTS,
447 eps.noalias() = B * u;
460 auto&& solution =
_ip_data[ip].solid_material.integrateStress(
461 variables_prev, variables, t, x_position, dt, *state);
465 OGS_FATAL(
"Computation of local constitutive relation failed.");
469 std::tie(sigma_eff, state, C) = std::move(*solution);
471 sigma_avg += ip_data.sigma_eff;
478 .template value<double>(variables, x_position, t, dt);
482 .template value<double>(variables, x_position, t, dt);
486 .value(variables, x_position, t, dt))
492 auto const& dNdx_p = ip_data.dNdx_p;
494 ip_data.darcy_velocity.head(DisplacementDim).noalias() =
495 -k_over_mu * (dNdx_p * p + rho_fr * gravity_vec);
496 velocity_avg.noalias() +=
497 ip_data.darcy_velocity.head(DisplacementDim);
501 sigma_avg /= n_integration_points;
502 velocity_avg /= n_integration_points;
505 &(*
_process_data.element_stresses)[e_id * KV::RowsAtCompileTime]) =
508 Eigen::Map<DisplacementDimVector>(
509 &(*
_process_data.element_velocities)[e_id * DisplacementDim]) =
513 ShapeFunctionPressure,
typename ShapeFunctionDisplacement::MeshElement,
518template <
typename ShapeFunctionDisplacement,
typename ShapeFunctionPressure,
521 ShapeFunctionDisplacement, ShapeFunctionPressure,
523 Eigen::Ref<Eigen::VectorXd> p)
540template <
typename ShapeFunctionDisplacement,
typename ShapeFunctionPressure,
543 ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim>::
546 std::vector<GlobalVector*>
const& ,
547 std::vector<NumLib::LocalToGlobalIndexMap const*>
const& ,
548 std::vector<double>& cache)
const
553template <
typename ShapeFunctionDisplacement,
typename ShapeFunctionPressure,
556 ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim>::
559 std::vector<GlobalVector*>
const& ,
560 std::vector<NumLib::LocalToGlobalIndexMap const*>
const& ,
561 std::vector<double>& cache)
const
567template <
typename ShapeFunctionDisplacement,
typename ShapeFunctionPressure,
570 ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim>::
571 getIntPtDarcyVelocity(
573 std::vector<GlobalVector*>
const& ,
574 std::vector<NumLib::LocalToGlobalIndexMap const*>
const& ,
575 std::vector<double>& cache)
const
577 unsigned const n_integration_points =
_ip_data.size();
581 double, DisplacementDim, Eigen::Dynamic, Eigen::RowMajor>>(
582 cache, DisplacementDim, n_integration_points);
584 for (
unsigned ip = 0; ip < n_integration_points; ip++)
586 cache_matrix.col(ip).noalias() =
_ip_data[ip].darcy_velocity;
Definition of the ElementStatus class.
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)
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