Loading [MathJax]/jax/input/TeX/config.js
OGS
RichardsComponentTransportFEM-impl.h
Go to the documentation of this file.
1
16
17namespace ProcessLib
18{
19namespace RichardsComponentTransport
20{
21template <typename ShapeFunction, int GlobalDim>
23 MeshLib::Element const& element,
24 std::size_t const local_matrix_size,
25 NumLib::GenericIntegrationMethod const& integration_method,
26 bool is_axially_symmetric,
27 RichardsComponentTransportProcessData const& process_data,
28 ProcessVariable const& transport_process_variable)
29 : _element_id(element.getID()),
30 _process_data(process_data),
31 _integration_method(integration_method),
32 _transport_process_variable(transport_process_variable)
33{
34 // This assertion is valid only if all nodal d.o.f. use the same shape
35 // matrices.
36 assert(local_matrix_size == ShapeFunction::NPOINTS * NUM_NODAL_DOF);
37 (void)local_matrix_size;
38
39 unsigned const n_integration_points =
41 _ip_data.reserve(n_integration_points);
42
43 auto const shape_matrices =
45 element, is_axially_symmetric, _integration_method);
46
47 for (unsigned ip = 0; ip < n_integration_points; ip++)
48 {
49 auto const& sm = shape_matrices[ip];
50 double const integration_factor = sm.integralMeasure * sm.detJ;
51 _ip_data.emplace_back(
52 sm.N, sm.dNdx,
54 integration_factor,
55 sm.N.transpose() * sm.N * integration_factor *
57 }
58}
59
60template <typename ShapeFunction, int GlobalDim>
62 double const t, double const dt, std::vector<double> const& local_x,
63 std::vector<double> const& /*local_x_prev*/,
64 std::vector<double>& local_M_data, std::vector<double>& local_K_data,
65 std::vector<double>& local_b_data)
66{
67 auto const local_matrix_size = local_x.size();
68 // This assertion is valid only if all nodal d.o.f. use the same shape
69 // matrices.
70 assert(local_matrix_size == ShapeFunction::NPOINTS * NUM_NODAL_DOF);
71
73 local_M_data, local_matrix_size, local_matrix_size);
75 local_K_data, local_matrix_size, local_matrix_size);
77 local_b_data, local_matrix_size);
78
79 unsigned const n_integration_points =
80 _integration_method.getNumberOfPoints();
81
83 pos.setElementID(_element_id);
84
85 auto p_nodal_values = Eigen::Map<const NodalVectorType>(
86 &local_x[pressure_index], pressure_size);
87
88 auto const& b = _process_data.specific_body_force;
89
91
92 GlobalDimMatrixType const& I(
93 GlobalDimMatrixType::Identity(GlobalDim, GlobalDim));
94
95 // Get material properties
96 auto const& medium = *_process_data.media_map.getMedium(_element_id);
97 auto const& phase = medium.phase("AqueousLiquid");
98 auto const& component =
99 phase.component(_transport_process_variable.getName());
100
101 auto KCC = local_K.template block<concentration_size, concentration_size>(
102 concentration_index, concentration_index);
103 auto MCC = local_M.template block<concentration_size, concentration_size>(
104 concentration_index, concentration_index);
105 auto Kpp = local_K.template block<pressure_size, pressure_size>(
106 pressure_index, pressure_index);
107 auto Mpp = local_M.template block<pressure_size, pressure_size>(
108 pressure_index, pressure_index);
109 auto Bp = local_b.template block<pressure_size, 1>(pressure_index, 0);
110
111 for (std::size_t ip(0); ip < n_integration_points; ++ip)
112 {
113 auto const& ip_data = _ip_data[ip];
114 auto const& N = ip_data.N;
115 auto const& dNdx = ip_data.dNdx;
116 auto const& w = ip_data.integration_weight;
117
118 double C_int_pt = 0.0;
119 double p_int_pt = 0.0;
120 // Order matters: First C, then p!
121 NumLib::shapeFunctionInterpolate(local_x, N, C_int_pt, p_int_pt);
122
123 vars.capillary_pressure = -p_int_pt;
125 .template value<double>(vars, pos, t, dt);
126
127 double const dSw_dpc =
129 .template dValue<double>(
131 pos, t, dt);
132
133 vars.concentration = C_int_pt;
134 vars.liquid_phase_pressure = p_int_pt;
135 // setting pG to 1 atm
136 // TODO : rewrite equations s.t. p_L = pG-p_cap
137 vars.gas_phase_pressure = 1.0e5;
138
139 // \todo the argument to getValue() has to be changed for non
140 // constant storage model
141 auto const specific_storage =
143 .template value<double>(vars, pos, t, dt);
144 // \todo the first argument has to be changed for non constant
145 // porosity model
146 auto const porosity =
148 .template value<double>(vars, pos, t, dt);
149
150 auto const retardation_factor =
152 .template value<double>(vars, pos, t, dt);
153
154 auto const solute_dispersivity_transverse =
156 .template value<double>(vars, pos, t, dt);
157 auto const solute_dispersivity_longitudinal =
159 .template value<double>(vars, pos, t, dt);
160
161 // Use the fluid density model to compute the density
162 auto const density = phase[MaterialPropertyLib::PropertyType::density]
163 .template value<double>(vars, pos, t, dt);
164 vars.density = density;
165
166 auto const decay_rate =
168 .template value<double>(vars, pos, t, dt);
169 auto const pore_diffusion_coefficient =
172 .value(vars, pos, t, dt));
173
176 vars, pos, t, dt));
177 vars.liquid_saturation = Sw;
178 auto const k_rel =
180 .template value<double>(vars, pos, t, dt);
181 // Use the viscosity model to compute the viscosity
183 .template value<double>(vars, pos, t, dt);
184 auto const K_times_k_rel_over_mu = K * (k_rel / mu);
185
186 GlobalDimVectorType const velocity =
187 _process_data.has_gravity
188 ? GlobalDimVectorType(-K_times_k_rel_over_mu *
189 (dNdx * p_nodal_values - density * b))
190 : GlobalDimVectorType(-K_times_k_rel_over_mu * dNdx *
191 p_nodal_values);
192
193 double const velocity_magnitude = velocity.norm();
194 GlobalDimMatrixType const hydrodynamic_dispersion =
195 velocity_magnitude != 0.0
197 porosity * pore_diffusion_coefficient +
198 solute_dispersivity_transverse * velocity_magnitude * I +
199 (solute_dispersivity_longitudinal -
200 solute_dispersivity_transverse) /
201 velocity_magnitude * velocity * velocity.transpose())
202 : GlobalDimMatrixType(porosity * pore_diffusion_coefficient +
203 solute_dispersivity_transverse *
204 velocity_magnitude * I);
205
206 // matrix assembly
207 KCC.noalias() +=
208 (dNdx.transpose() * hydrodynamic_dispersion * dNdx +
209 N.transpose() * velocity.transpose() * dNdx +
210 N.transpose() * decay_rate * porosity * retardation_factor * N) *
211 w;
212 MCC.noalias() += w * N.transpose() * porosity * retardation_factor * N;
213 Kpp.noalias() += w * dNdx.transpose() * K_times_k_rel_over_mu * dNdx;
214 // \TODO Extend to pressure dependent density.
215 double const drhow_dp(0.0);
216 Mpp.noalias() += (specific_storage * Sw + porosity * Sw * drhow_dp -
217 porosity * dSw_dpc) *
218 ip_data.mass_operator;
219
220 if (_process_data.has_gravity)
221 {
222 Bp += w * density * dNdx.transpose() * K_times_k_rel_over_mu * b;
223 }
224 /* with Oberbeck-Boussing assumption density difference only exists
225 * in buoyancy effects */
226 }
227}
228
229template <typename ShapeFunction, int GlobalDim>
230std::vector<double> const&
232 const double t,
233 std::vector<GlobalVector*> const& x,
234 std::vector<NumLib::LocalToGlobalIndexMap const*> const& dof_table,
235 std::vector<double>& cache) const
236{
237 unsigned const n_integration_points =
238 _integration_method.getNumberOfPoints();
239
240 constexpr int process_id = 0; // monolithic scheme
241 auto const indices =
242 NumLib::getIndices(_element_id, *dof_table[process_id]);
243 assert(!indices.empty());
244 auto const local_x = x[process_id]->get(indices);
245
246 cache.clear();
247 auto cache_mat = MathLib::createZeroedMatrix<
248 Eigen::Matrix<double, GlobalDim, Eigen::Dynamic, Eigen::RowMajor>>(
249 cache, GlobalDim, n_integration_points);
250
252 pos.setElementID(_element_id);
253
255
256 // Get material properties
257 auto const& medium = *_process_data.media_map.getMedium(_element_id);
258 auto const& phase = medium.phase("AqueousLiquid");
259
260 auto const p_nodal_values = Eigen::Map<const NodalVectorType>(
261 &local_x[ShapeFunction::NPOINTS], ShapeFunction::NPOINTS);
262
263 for (unsigned ip = 0; ip < n_integration_points; ++ip)
264 {
265 auto const& ip_data = _ip_data[ip];
266 auto const& N = ip_data.N;
267 auto const& dNdx = ip_data.dNdx;
268
269 auto const dt = std::numeric_limits<double>::quiet_NaN();
272 vars, pos, t, dt));
274 .template value<double>(vars, pos, t, dt);
275
276 double C_int_pt = 0.0;
277 double p_int_pt = 0.0;
278 NumLib::shapeFunctionInterpolate(local_x, N, C_int_pt, p_int_pt);
279
280 // saturation
281 vars.capillary_pressure = -p_int_pt;
283 .template value<double>(vars, pos, t, dt);
284
285 vars.liquid_saturation = Sw;
286 auto const k_rel =
288 .template value<double>(vars, pos, t, dt);
289
290 cache_mat.col(ip).noalias() = -dNdx * p_nodal_values;
291 if (_process_data.has_gravity)
292 {
293 vars.concentration = C_int_pt;
294 vars.liquid_phase_pressure = p_int_pt;
295 auto const rho_w = phase[MaterialPropertyLib::PropertyType::density]
296 .template value<double>(vars, pos, t, dt);
297 auto const b = _process_data.specific_body_force;
298 // here it is assumed that the vector b is directed 'downwards'
299 cache_mat.col(ip).noalias() += rho_w * b;
300 }
301 cache_mat.col(ip).noalias() = k_rel / mu * (K * cache_mat.col(ip));
302 }
303 return cache;
304}
305
306template <typename ShapeFunction, int GlobalDim>
307Eigen::Map<const Eigen::RowVectorXd>
309 const unsigned integration_point) const
310{
311 auto const& N = _ip_data[integration_point].N;
312
313 // assumes N is stored contiguously in memory
314 return Eigen::Map<const Eigen::RowVectorXd>(N.data(), N.size());
315}
316
317template <typename ShapeFunction, int GlobalDim>
318std::vector<double> const&
320 const double t,
321 std::vector<GlobalVector*> const& x,
322 std::vector<NumLib::LocalToGlobalIndexMap const*> const& dof_table,
323 std::vector<double>& cache) const
324{
326 pos.setElementID(_element_id);
327
329
330 auto const& medium = *_process_data.media_map.getMedium(_element_id);
331
332 unsigned const n_integration_points =
333 _integration_method.getNumberOfPoints();
334
335 constexpr int process_id = 0; // monolithic scheme
336 auto const indices =
337 NumLib::getIndices(_element_id, *dof_table[process_id]);
338 assert(!indices.empty());
339 auto const local_x = x[process_id]->get(indices);
340
341 cache.clear();
342 auto cache_vec = MathLib::createZeroedVector<
343 Eigen::Matrix<double, 1, Eigen::Dynamic, Eigen::RowMajor>>(
344 cache, n_integration_points);
345
346 for (unsigned ip = 0; ip < n_integration_points; ++ip)
347 {
348 auto const& ip_data = _ip_data[ip];
349 auto const& N = ip_data.N;
350
351 double C_int_pt = 0.0;
352 double p_int_pt = 0.0;
353 NumLib::shapeFunctionInterpolate(local_x, N, C_int_pt, p_int_pt);
354
355 // saturation
356 vars.capillary_pressure = -p_int_pt;
357 auto const dt = std::numeric_limits<double>::quiet_NaN();
359 .template value<double>(vars, pos, t, dt);
360 cache_vec[ip] = Sw;
361 }
362
363 return cache;
364}
365
366} // namespace RichardsComponentTransport
367} // namespace ProcessLib
constexpr double getWeight() const
MathLib::WeightedPoint const & getWeightedPoint(unsigned const igp) const
void setElementID(std::size_t element_id)
std::vector< IntegrationPointData< NodalRowVectorType, GlobalDimNodalMatrixType, NodalMatrixType >, Eigen::aligned_allocator< IntegrationPointData< NodalRowVectorType, GlobalDimNodalMatrixType, NodalMatrixType > > > _ip_data
typename ShapeMatricesType::GlobalDimVectorType GlobalDimVectorType
LocalAssemblerData(MeshLib::Element const &element, std::size_t const local_matrix_size, NumLib::GenericIntegrationMethod const &integration_method, bool is_axially_symmetric, RichardsComponentTransportProcessData const &process_data, ProcessVariable const &transport_process_variable)
std::vector< double > const & getIntPtSaturation(const double t, std::vector< GlobalVector * > const &x, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_table, std::vector< double > &cache) const override
std::vector< double > const & getIntPtDarcyVelocity(const double t, std::vector< GlobalVector * > const &x, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_table, std::vector< double > &cache) const override
void assemble(double const t, double const dt, std::vector< double > const &local_x, std::vector< double > const &local_x_prev, std::vector< double > &local_M_data, std::vector< double > &local_K_data, std::vector< double > &local_b_data) override
typename ShapeMatricesType::GlobalDimMatrixType GlobalDimMatrixType
Eigen::Map< const Eigen::RowVectorXd > getShapeMatrix(const unsigned integration_point) const override
Provides the shape matrix at the given integration point.
Eigen::Matrix< double, GlobalDim, GlobalDim > formEigenTensor(MaterialPropertyLib::PropertyDataType const &values)
@ longitudinal_dispersivity
used to compute the hydrodynamic dispersion tensor.
@ transversal_dispersivity
used to compute the hydrodynamic dispersion tensor.
@ retardation_factor
specify retardation factor used in component transport process.
Eigen::Map< Vector > createZeroedVector(std::vector< double > &data, Eigen::VectorXd::Index size)
Eigen::Map< Matrix > createZeroedMatrix(std::vector< double > &data, Eigen::MatrixXd::Index rows, Eigen::MatrixXd::Index cols)
void shapeFunctionInterpolate(const NodalValues &, const ShapeMatrix &)
std::vector< GlobalIndexType > getIndices(std::size_t const mesh_item_id, NumLib::LocalToGlobalIndexMap const &dof_table)
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)