OGS
HydroMechanicsLocalAssemblerMatrixNearFracture-impl.h
Go to the documentation of this file.
1
11#pragma once
12
15
16namespace ProcessLib
17{
18namespace LIE
19{
20namespace HydroMechanics
21{
22template <typename ShapeFunctionDisplacement, typename ShapeFunctionPressure,
23 int GlobalDim>
24HydroMechanicsLocalAssemblerMatrixNearFracture<
25 ShapeFunctionDisplacement, ShapeFunctionPressure, GlobalDim>::
26 HydroMechanicsLocalAssemblerMatrixNearFracture(
27 MeshLib::Element const& e,
28 std::size_t const n_variables,
29 std::size_t const local_matrix_size,
30 std::vector<unsigned> const& dofIndex_to_localIndex,
31 NumLib::GenericIntegrationMethod const& integration_method,
32 bool const is_axially_symmetric,
34 : HydroMechanicsLocalAssemblerMatrix<ShapeFunctionDisplacement,
35 ShapeFunctionPressure, GlobalDim>(
36 e, n_variables, local_matrix_size, dofIndex_to_localIndex,
37 integration_method, is_axially_symmetric, process_data),
38 _e_center_coords(getCenterOfGravity(e).data())
39{
40 // currently not supporting multiple fractures
41 _fracture_props.push_back(process_data.fracture_property.get());
42 _fracID_to_local.insert({0, 0});
43}
44
45template <typename ShapeFunctionDisplacement, typename ShapeFunctionPressure,
46 int GlobalDim>
48 ShapeFunctionDisplacement, ShapeFunctionPressure,
49 GlobalDim>::assembleWithJacobianConcrete(double const t, double const dt,
50 Eigen::VectorXd const& local_x,
51 Eigen::VectorXd const&
52 local_x_prev,
53 Eigen::VectorXd& local_b,
54 Eigen::MatrixXd& local_J)
55{
56 auto p = const_cast<Eigen::VectorXd&>(local_x).segment(pressure_index,
57 pressure_size);
58 auto p_prev = const_cast<Eigen::VectorXd&>(local_x_prev)
59 .segment(pressure_index, pressure_size);
60 if (_process_data.deactivate_matrix_in_flow)
61 {
62 Base::setPressureOfInactiveNodes(t, p);
63 }
64 auto const u = local_x.segment(displacement_index, displacement_size);
65 auto const u_prev =
66 local_x_prev.segment(displacement_index, displacement_size);
67
68 auto rhs_p = local_b.segment(pressure_index, pressure_size);
69 auto rhs_u = local_b.segment(displacement_index, displacement_size);
70
71 auto J_pp = local_J.block(pressure_index, pressure_index, pressure_size,
72 pressure_size);
73 auto J_pu = local_J.block(pressure_index, displacement_index, pressure_size,
74 displacement_size);
75 auto J_up = local_J.block(displacement_index, pressure_index,
76 displacement_size, pressure_size);
77 auto J_uu = local_J.block(displacement_index, displacement_index,
78 displacement_size, displacement_size);
79
80 // levelset value of the element
81 // remark: this assumes the levelset function is uniform within an element
82 std::vector<double> levelsets = uGlobalEnrichments(
83 _fracture_props, _junction_props, _fracID_to_local, _e_center_coords);
84 double const ele_levelset = levelsets[0]; // single fracture
85
86 if (ele_levelset == 0)
87 {
88 // no DoF exists for displacement jumps. do the normal assembly
89 Base::assembleBlockMatricesWithJacobian(
90 t, dt, p, p_prev, u, u_prev, rhs_p, rhs_u, J_pp, J_pu, J_uu, J_up);
91 return;
92 }
93
94 // Displacement jumps should be taken into account
95
96 // compute true displacements
97 auto const g = local_x.segment(displacement_jump_index, displacement_size);
98 auto const g_prev =
99 local_x_prev.segment(displacement_jump_index, displacement_size);
100 Eigen::VectorXd const total_u = u + ele_levelset * g;
101 Eigen::VectorXd const total_u_prev = u_prev + ele_levelset * g_prev;
102
103 // evaluate residuals and Jacobians for pressure and displacements
104 Base::assembleBlockMatricesWithJacobian(t, dt, p, p_prev, total_u,
105 total_u_prev, rhs_p, rhs_u, J_pp,
106 J_pu, J_uu, J_up);
107
108 // compute residuals and Jacobians for displacement jumps
109 auto rhs_g = local_b.segment(displacement_jump_index, displacement_size);
110 auto J_pg = local_J.block(pressure_index, displacement_jump_index,
111 pressure_size, displacement_size);
112 auto J_ug = local_J.block(displacement_index, displacement_jump_index,
113 displacement_size, displacement_size);
114 auto J_gp = local_J.block(displacement_jump_index, pressure_index,
115 displacement_size, pressure_size);
116 auto J_gu = local_J.block(displacement_jump_index, displacement_index,
117 displacement_size, displacement_size);
118 auto J_gg = local_J.block(displacement_jump_index, displacement_jump_index,
119 displacement_size, displacement_size);
120
121 rhs_g = ele_levelset * rhs_u;
122 J_pg = ele_levelset * J_pu;
123 J_ug = ele_levelset * J_uu;
124 J_gp = ele_levelset * J_up;
125 J_gu = ele_levelset * J_uu;
126 J_gg = ele_levelset * ele_levelset * J_uu;
127}
128
129template <typename ShapeFunctionDisplacement, typename ShapeFunctionPressure,
130 int GlobalDim>
132 ShapeFunctionDisplacement, ShapeFunctionPressure,
133 GlobalDim>::postTimestepConcreteWithVector(double const t, double const dt,
134 Eigen::VectorXd const& local_x)
135{
136 auto p = const_cast<Eigen::VectorXd&>(local_x).segment(pressure_index,
137 pressure_size);
138 if (_process_data.deactivate_matrix_in_flow)
139 {
140 Base::setPressureOfInactiveNodes(t, p);
141 }
142 auto u = local_x.segment(displacement_index, displacement_size);
143
144 // levelset value of the element
145 // remark: this assumes the levelset function is uniform within an element
146 std::vector<double> levelsets = uGlobalEnrichments(
147 _fracture_props, _junction_props, _fracID_to_local, _e_center_coords);
148 double const ele_levelset = levelsets[0]; // single fracture
149
150 if (ele_levelset == 0)
151 {
152 // no DoF exists for displacement jumps. do the normal assembly
153 Base::postTimestepConcreteWithBlockVectors(t, dt, p, u);
154 return;
155 }
156
157 // Displacement jumps should be taken into account
158
159 // compute true displacements
160 auto const g = local_x.segment(displacement_jump_index, displacement_size);
161 Eigen::VectorXd const total_u = u + ele_levelset * g;
162
163 // evaluate residuals and Jacobians for pressure and displacements
164 Base::postTimestepConcreteWithBlockVectors(t, dt, p, total_u);
165}
166
167} // namespace HydroMechanics
168} // namespace LIE
169} // namespace ProcessLib
std::vector< double > uGlobalEnrichments(std::vector< FractureProperty * > const &frac_props, std::vector< JunctionProperty * > const &junction_props, std::unordered_map< int, int > const &fracID_to_local, Eigen::Vector3d const &x)