47 double const t,
double const dt, std::vector<double>
const& local_x,
48 std::vector<double>
const& ,
49 std::vector<double>& local_M_data, std::vector<double>& local_K_data,
50 std::vector<double>& local_b_data)
52 auto const local_matrix_size = local_x.size();
54 assert(local_matrix_size == ShapeFunction::NPOINTS *
NUM_NODAL_DOF);
57 local_M_data, local_matrix_size, local_matrix_size);
59 local_K_data, local_matrix_size, local_matrix_size);
61 local_b_data, local_matrix_size);
64 local_M.template block<nonwet_pressure_size, nonwet_pressure_size>(
65 nonwet_pressure_matrix_index, nonwet_pressure_matrix_index);
66 auto Mgpc = local_M.template block<nonwet_pressure_size, cap_pressure_size>(
67 nonwet_pressure_matrix_index, cap_pressure_matrix_index);
69 auto Mlpc = local_M.template block<cap_pressure_size, cap_pressure_size>(
70 cap_pressure_matrix_index, cap_pressure_matrix_index);
73 NodalMatrixType::Zero(ShapeFunction::NPOINTS, ShapeFunction::NPOINTS);
76 local_K.template block<nonwet_pressure_size, nonwet_pressure_size>(
77 nonwet_pressure_matrix_index, nonwet_pressure_matrix_index);
79 auto Klp = local_K.template block<cap_pressure_size, nonwet_pressure_size>(
80 cap_pressure_matrix_index, nonwet_pressure_matrix_index);
82 auto Klpc = local_K.template block<cap_pressure_size, cap_pressure_size>(
83 cap_pressure_matrix_index, cap_pressure_matrix_index);
85 auto Bg = local_b.template segment<nonwet_pressure_size>(
86 nonwet_pressure_matrix_index);
89 local_b.template segment<cap_pressure_size>(cap_pressure_matrix_index);
91 auto const& medium = *_process_data.media_map.getMedium(_element.getID());
92 auto const& liquid_phase = medium.phase(
"AqueousLiquid");
93 auto const& gas_phase = medium.phase(
"Gas");
95 unsigned const n_integration_points =
96 _integration_method.getNumberOfPoints();
101 for (
unsigned ip = 0; ip < n_integration_points; ip++)
104 auto const& w = _ip_data[ip].integration_weight;
105 auto const& dNdx = _ip_data[ip].dNdx;
106 auto const& M = _ip_data[ip].massOperator;
108 double pc_int_pt = 0.;
109 double pn_int_pt = 0.;
113 _pressure_wet[ip] = pn_int_pt - pc_int_pt;
118 variables.
temperature = _process_data.temperature(t, pos)[0];
120 gas_phase.property(MPL::PropertyType::molar_mass)
121 .template value<double>(variables, pos, t, dt);
123 auto const rho_nonwet =
124 gas_phase.property(MPL::PropertyType::density)
125 .template value<double>(variables, pos, t, dt);
127 auto const rho_wet = liquid_phase.property(MPL::PropertyType::density)
128 .template value<double>(variables, pos, t, dt);
129 auto& Sw = _saturation[ip];
130 Sw = medium.property(MPL::PropertyType::saturation)
131 .template value<double>(variables, pos, t, dt);
134 medium.property(MPL::PropertyType::saturation)
135 .template dValue<double>(
136 variables, MPL::Variable::capillary_pressure, pos, t, dt);
138 auto const porosity =
139 medium.property(MPL::PropertyType::porosity)
140 .template value<double>(variables, pos, t, dt);
142 auto const drhononwet_dpn =
143 gas_phase.property(MPL::PropertyType::density)
144 .template dValue<double>(
145 variables, MPL::Variable::gas_phase_pressure, pos, t, dt);
147 auto const k_rel_wet =
148 medium.property(MPL::PropertyType::relative_permeability)
149 .template value<double>(variables, pos, t, dt);
150 auto const k_rel_nonwet =
153 MPL::PropertyType::relative_permeability_nonwetting_phase)
154 .template value<double>(variables, pos, t, dt);
156 auto const mu_nonwet =
157 gas_phase.property(MPL::PropertyType::viscosity)
158 .template value<double>(variables, pos, t, dt);
160 auto const lambda_nonwet = k_rel_nonwet / mu_nonwet;
162 auto const mu_wet = liquid_phase.property(MPL::PropertyType::viscosity)
163 .template value<double>(variables, pos, t, dt);
165 auto const lambda_wet = k_rel_wet / mu_wet;
168 medium.property(MPL::PropertyType::permeability)
169 .template value<double>(variables, pos, t, dt));
171 Mgp.noalias() += porosity * (1 - Sw) * drhononwet_dpn * M;
172 Mgpc.noalias() += -porosity * rho_nonwet * dSw_dpc * M;
173 Mlpc.noalias() += porosity * dSw_dpc * rho_wet * M;
175 laplace_operator.noalias() = dNdx.transpose() * K * dNdx * w;
177 Kgp.noalias() += rho_nonwet * lambda_nonwet * laplace_operator;
178 Klp.noalias() += rho_wet * lambda_wet * laplace_operator;
179 Klpc.noalias() += -rho_wet * lambda_wet * laplace_operator;
181 if (_process_data.has_gravity)
183 auto const& b = _process_data.specific_body_force;
187 rho_nonwet * rho_nonwet * lambda_nonwet * gravity_operator;
188 Bl.noalias() += rho_wet * rho_wet * lambda_wet * gravity_operator;
191 if (_process_data.has_mass_lumping)
193 for (
unsigned row = 0; row < Mgpc.cols(); row++)
195 for (
unsigned column = 0; column < Mgpc.cols(); column++)
199 Mgpc(row, row) += Mgpc(row, column);
200 Mgpc(row, column) = 0.0;
201 Mgp(row, row) += Mgp(row, column);
202 Mgp(row, column) = 0.0;
203 Mlpc(row, row) += Mlpc(row, column);
204 Mlpc(row, column) = 0.0;