39 ShapeFunctionPressure, GlobalDim>::
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 * GlobalDim +
51 ShapeFunctionPressure::NPOINTS,
52 dofIndex_to_localIndex),
53 _process_data(process_data)
55 unsigned const n_integration_points =
58 _ip_data.reserve(n_integration_points);
61 auto const shape_matrices_u =
64 e, is_axially_symmetric, integration_method);
66 auto const shape_matrices_p =
69 e, is_axially_symmetric, integration_method);
76 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 < GlobalDim; ++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];
126 ShapeFunctionPressure, GlobalDim>::
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,
135 auto const p_prev = local_x_prev.segment(pressure_index, pressure_size);
137 if (_process_data.deactivate_matrix_in_flow)
139 setPressureOfInactiveNodes(t, p);
142 auto u = local_x.segment(displacement_index, displacement_size);
143 auto u_prev = local_x_prev.segment(displacement_index, displacement_size);
145 auto rhs_p = local_rhs.template segment<pressure_size>(pressure_index);
147 local_rhs.template segment<displacement_size>(displacement_index);
149 auto J_pp = local_Jac.template block<pressure_size, pressure_size>(
150 pressure_index, pressure_index);
151 auto J_pu = local_Jac.template block<pressure_size, displacement_size>(
152 pressure_index, displacement_index);
153 auto J_uu = local_Jac.template block<displacement_size, displacement_size>(
154 displacement_index, displacement_index);
155 auto J_up = local_Jac.template block<displacement_size, pressure_size>(
156 displacement_index, pressure_index);
158 assembleBlockMatricesWithJacobian(t, dt, p, p_prev, u, u_prev, rhs_p, rhs_u,
159 J_pp, J_pu, J_uu, J_up);
165 ShapeFunctionPressure, GlobalDim>::
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() == GlobalDim);
179 ShapeMatricesTypePressure::NodalMatrixType::Zero(pressure_size,
183 ShapeMatricesTypePressure::NodalMatrixType::Zero(pressure_size,
186 typename ShapeMatricesTypeDisplacement::template MatrixType<
187 displacement_size, pressure_size>
188 Kup = ShapeMatricesTypeDisplacement::template MatrixType<
189 displacement_size, pressure_size>::Zero(displacement_size,
192 auto const& gravity_vec = _process_data.specific_body_force;
199 auto const& medium = _process_data.media_map.getMedium(_element.getID());
200 auto const& liquid_phase = medium->phase(
"AqueousLiquid");
201 auto const& solid_phase = medium->phase(
"Solid");
204 medium->property(MPL::PropertyType::reference_temperature)
205 .template value<double>(variables, x_position, t, dt);
209 bool const has_storage_property =
210 medium->hasProperty(MPL::PropertyType::storage);
212 auto const B_dil_bar = getDilatationalBBarMatrix();
214 unsigned const n_integration_points = _ip_data.size();
215 for (
unsigned ip = 0; ip < n_integration_points; ip++)
219 auto& ip_data = _ip_data[ip];
220 auto const& ip_w = ip_data.integration_weight;
221 auto const& N_u = ip_data.N_u;
222 auto const& dNdx_u = ip_data.dNdx_u;
223 auto const& N_p = ip_data.N_p;
224 auto const& dNdx_p = ip_data.dNdx_p;
225 auto const& H_u = ip_data.H_u;
237 dNdx_u, N_u, B_dil_bar, x_coord, this->_is_axially_symmetric)
240 auto const& eps_prev = ip_data.eps_prev;
241 auto const& sigma_eff_prev = ip_data.sigma_eff_prev;
242 auto& sigma_eff = ip_data.sigma_eff;
244 auto& eps = ip_data.eps;
245 auto& state = ip_data.material_state_variables;
248 solid_phase.property(MPL::PropertyType::density)
249 .template value<double>(variables, x_position, t, dt);
251 liquid_phase.property(MPL::PropertyType::density)
252 .template value<double>(variables, x_position, t, dt);
255 medium->property(MPL::PropertyType::biot_coefficient)
256 .template value<double>(variables, x_position, t, dt);
257 auto const porosity =
258 medium->property(MPL::PropertyType::porosity)
259 .template value<double>(variables, x_position, t, dt);
261 double const rho = rho_sr * (1 - porosity) + porosity * rho_fr;
262 auto const& identity2 =
265 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;
298 if (!_process_data.deactivate_matrix_in_flow)
301 Kup.noalias() += B.transpose() * alpha * identity2 * N_p * ip_w;
305 liquid_phase.property(MPL::PropertyType::viscosity)
306 .template value<double>(variables, x_position, t, dt);
308 auto const k_over_mu =
310 medium->property(MPL::PropertyType::permeability)
311 .value(variables, x_position, t, dt)) /
317 ? medium->property(MPL::PropertyType::storage)
318 .template value<double>(variables, x_position, t, dt)
320 (liquid_phase.property(MPL::PropertyType::density)
321 .template dValue<double>(
323 MPL::Variable::liquid_phase_pressure,
326 (alpha - porosity) * (1.0 - alpha) /
327 _ip_data[ip].solid_material.getBulkModulus(
330 auto q = ip_data.darcy_velocity.head(GlobalDim);
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;
380 ShapeFunctionPressure, GlobalDim>::
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)
390 auto const e_id = _element.getID();
394 KV sigma_avg = KV::Zero();
396 velocity_avg.setZero();
398 unsigned const n_integration_points = _ip_data.size();
400 auto const& medium = _process_data.media_map.getMedium(_element.getID());
401 auto const& liquid_phase = medium->phase(
"AqueousLiquid");
403 medium->property(MPL::PropertyType::reference_temperature)
404 .template value<double>(variables, x_position, t, dt);
408 auto const B_dil_bar = getDilatationalBBarMatrix();
410 for (
unsigned ip = 0; ip < n_integration_points; ip++)
414 auto& ip_data = _ip_data[ip];
416 auto const& eps_prev = ip_data.eps_prev;
417 auto const& sigma_eff_prev = ip_data.sigma_eff_prev;
419 auto& eps = ip_data.eps;
420 auto& sigma_eff = ip_data.sigma_eff;
421 auto& state = ip_data.material_state_variables;
423 auto const& N_u = ip_data.N_u;
424 auto const& N_p = ip_data.N_p;
425 auto const& dNdx_u = ip_data.dNdx_u;
437 dNdx_u, N_u, B_dil_bar, x_coord, this->_is_axially_symmetric)
440 eps.noalias() = B * u;
452 auto&& solution = _ip_data[ip].solid_material.integrateStress(
453 variables_prev, variables, t, x_position, dt, *state);
457 OGS_FATAL(
"Computation of local constitutive relation failed.");
461 std::tie(sigma_eff, state, C) = std::move(*solution);
463 sigma_avg += ip_data.sigma_eff;
465 if (!_process_data.deactivate_matrix_in_flow)
469 liquid_phase.property(MPL::PropertyType::density)
470 .template value<double>(variables, x_position, t, dt);
473 liquid_phase.property(MPL::PropertyType::viscosity)
474 .template value<double>(variables, x_position, t, dt);
477 medium->property(MPL::PropertyType::permeability)
478 .value(variables, x_position, t, dt))
483 auto const& gravity_vec = _process_data.specific_body_force;
484 auto const& dNdx_p = ip_data.dNdx_p;
486 ip_data.darcy_velocity.head(GlobalDim).noalias() =
487 -k_over_mu * (dNdx_p * p + rho_fr * gravity_vec);
488 velocity_avg.noalias() += ip_data.darcy_velocity.head(GlobalDim);
492 sigma_avg /= n_integration_points;
493 velocity_avg /= n_integration_points;
496 &(*_process_data.element_stresses)[e_id * KV::RowsAtCompileTime]) =
499 Eigen::Map<GlobalDimVector>(
500 &(*_process_data.element_velocities)[e_id * GlobalDim]) = velocity_avg;
503 ShapeFunctionPressure,
typename ShapeFunctionDisplacement::MeshElement,
504 GlobalDim>(_element, _is_axially_symmetric, p,
505 *_process_data.mesh_prop_nodal_p);