OGS
MonolithicHTFEM.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <Eigen/Core>
7#include <typeinfo>
8#include <vector>
9
10#include "HTFEM.h"
11#include "HTProcessData.h"
22
23namespace ProcessLib
24{
25namespace HT
26{
27const unsigned NUM_NODAL_DOF = 2;
28
29template <typename ShapeFunction, int GlobalDim>
30class MonolithicHTFEM : public HTFEM<ShapeFunction, GlobalDim>
31{
34
35 using LocalMatrixType = typename ShapeMatricesType::template MatrixType<
36 NUM_NODAL_DOF * ShapeFunction::NPOINTS,
37 NUM_NODAL_DOF * ShapeFunction::NPOINTS>;
39 typename ShapeMatricesType::template VectorType<NUM_NODAL_DOF *
40 ShapeFunction::NPOINTS>;
41
45
48
49public:
51 std::size_t const local_matrix_size,
52 NumLib::GenericIntegrationMethod const& integration_method,
53 bool is_axially_symmetric,
54 HTProcessData const& process_data)
55 : HTFEM<ShapeFunction, GlobalDim>(
56 element, local_matrix_size, integration_method,
57 is_axially_symmetric, process_data, NUM_NODAL_DOF)
58 {
59 }
60
61 void assemble(double const t, double const dt,
62 std::vector<double> const& local_x,
63 std::vector<double> const& /*local_x_prev*/,
64 std::vector<double>& local_M_data,
65 std::vector<double>& local_K_data,
66 std::vector<double>& local_b_data) override
67 {
68 auto const local_matrix_size = local_x.size();
69 // This assertion is valid only if all nodal d.o.f. use the same shape
70 // matrices.
71 assert(local_matrix_size == ShapeFunction::NPOINTS * NUM_NODAL_DOF);
72
74 local_M_data, local_matrix_size, local_matrix_size);
76 local_K_data, local_matrix_size, local_matrix_size);
78 local_b_data, local_matrix_size);
79
80 auto KTT = local_K.template block<temperature_size, temperature_size>(
82 auto MTT = local_M.template block<temperature_size, temperature_size>(
84 auto Kpp = local_K.template block<pressure_size, pressure_size>(
86 auto Mpp = local_M.template block<pressure_size, pressure_size>(
88 auto Bp = local_b.template block<pressure_size, 1>(pressure_index, 0);
89
90 auto const& process_data = this->_process_data;
91
92 auto p_nodal_values = Eigen::Map<const NodalVectorType>(
93 &local_x[pressure_index], pressure_size);
94
95 auto const& medium =
96 *process_data.media_map.getMedium(this->_element.getID());
97 auto const& liquid_phase = medium.phase("AqueousLiquid");
98 auto const& solid_phase = medium.phase("Solid");
99
100 auto const& b =
101 process_data
102 .projected_specific_body_force_vectors[this->_element.getID()];
103
105
106 unsigned const n_integration_points =
107 this->_integration_method.getNumberOfPoints();
108
109 std::vector<GlobalDimVectorType> ip_flux_vector;
110 double average_velocity_norm = 0.0;
111 ip_flux_vector.reserve(n_integration_points);
112
113 auto const& Ns =
114 process_data.shape_matrix_cache
115 .template NsHigherOrder<typename ShapeFunction::MeshElement>();
116
117 for (unsigned ip(0); ip < n_integration_points; ip++)
118 {
119 auto const& ip_data = this->_ip_data[ip];
120 auto const& dNdx = ip_data.dNdx;
121 auto const& N = Ns[ip];
122 auto const& w = ip_data.integration_weight;
123
125 std::nullopt, this->_element.getID(),
129 this->_element, N))};
130
131 double T_int_pt = 0.0;
132 double p_int_pt = 0.0;
133 // Order matters: First T, then P!
134 NumLib::shapeFunctionInterpolate(local_x, N, T_int_pt, p_int_pt);
135
136 vars.temperature = T_int_pt;
137 vars.liquid_phase_pressure = p_int_pt;
138
139 vars.liquid_saturation = 1.0;
140 // \todo the argument to getValue() has to be changed for non
141 // constant storage model
142 auto const specific_storage =
144 .template value<double>(vars, pos, t, dt);
145
146 auto const porosity =
148 .template value<double>(vars, pos, t, dt);
149 vars.porosity = porosity;
150
151 auto const intrinsic_permeability =
153 medium
154 .property(
156 .value(vars, pos, t, dt));
157
158 auto const specific_heat_capacity_fluid =
159 liquid_phase
161 .template value<double>(vars, pos, t, dt);
162
163 // Use the fluid density model to compute the density
164 auto const fluid_density =
165 liquid_phase
167 .template value<double>(vars, pos, t, dt);
168
169 vars.density = fluid_density;
170 // Use the viscosity model to compute the viscosity
171 auto const viscosity =
172 liquid_phase
174 .template value<double>(vars, pos, t, dt);
175 GlobalDimMatrixType K_over_mu = intrinsic_permeability / viscosity;
176
177 GlobalDimVectorType const velocity =
178 process_data.has_gravity
179 ? GlobalDimVectorType(-K_over_mu * (dNdx * p_nodal_values -
180 fluid_density * b))
181 : GlobalDimVectorType(-K_over_mu * dNdx * p_nodal_values);
182
183 // matrix assembly
184 GlobalDimMatrixType const thermal_conductivity_dispersivity =
186 vars, fluid_density, specific_heat_capacity_fluid, velocity,
187 pos, t, dt);
188
189 KTT.noalias() +=
190 dNdx.transpose() * thermal_conductivity_dispersivity * dNdx * w;
191
192 ip_flux_vector.emplace_back(velocity * fluid_density *
193 specific_heat_capacity_fluid);
194 average_velocity_norm += velocity.norm();
195
196 Kpp.noalias() += w * dNdx.transpose() * K_over_mu * dNdx;
197 MTT.noalias() += w *
199 vars, porosity, fluid_density,
200 specific_heat_capacity_fluid, pos, t, dt) *
201 N.transpose() * N;
202 Mpp.noalias() += w * N.transpose() * specific_storage * N;
203 if (process_data.has_gravity)
204 {
205 Bp += w * fluid_density * dNdx.transpose() * K_over_mu * b;
206 }
207 /* with Oberbeck-Boussing assumption density difference only exists
208 * in buoyancy effects */
209 }
210
212 process_data.stabilizer, this->_ip_data,
213 process_data.shape_matrix_cache, ip_flux_vector,
214 average_velocity_norm / static_cast<double>(n_integration_points),
215 KTT);
216 }
217
218 std::vector<double> const& getIntPtDarcyVelocity(
219 const double t,
220 std::vector<GlobalVector*> const& x,
221 std::vector<NumLib::LocalToGlobalIndexMap const*> const& dof_table,
222 std::vector<double>& cache) const override
223 {
224 int const process_id = 0; // monolithic case.
225 auto const indices =
226 NumLib::getIndices(this->_element.getID(), *dof_table[process_id]);
227 assert(!indices.empty());
228 auto const& local_x = x[process_id]->get(indices);
229
230 return this->getIntPtDarcyVelocityLocal(t, local_x, cache);
231 }
232
233private:
234 using HTFEM<ShapeFunction, GlobalDim>::pressure_index;
235 using HTFEM<ShapeFunction, GlobalDim>::pressure_size;
236 using HTFEM<ShapeFunction, GlobalDim>::temperature_index;
237 using HTFEM<ShapeFunction, GlobalDim>::temperature_size;
238};
239
240} // namespace HT
241} // namespace ProcessLib
EigenFixedShapeMatrixPolicy< ShapeFunction, GlobalDim > ShapeMatrixPolicyType
std::vector< double > const & getIntPtDarcyVelocityLocal(const double t, std::vector< double > const &local_x, std::vector< double > &cache) const
Definition HTFEM.h:232
NumLib::GenericIntegrationMethod const & _integration_method
Definition HTFEM.h:164
static const int temperature_index
Definition HTFEM.h:316
static const int temperature_size
Definition HTFEM.h:317
double getHeatEnergyCoefficient(MaterialPropertyLib::VariableArray const &vars, const double porosity, const double fluid_density, const double specific_heat_capacity_fluid, ParameterLib::SpatialPosition const &pos, double const t, double const dt)
Definition HTFEM.h:167
HTFEM(MeshLib::Element const &element, std::size_t const local_matrix_size, NumLib::GenericIntegrationMethod const &integration_method, bool const is_axially_symmetric, HTProcessData const &process_data, const unsigned dof_per_node)
Definition HTFEM.h:41
static const int pressure_size
Definition HTFEM.h:315
GlobalDimMatrixType getThermalConductivityDispersivity(MaterialPropertyLib::VariableArray const &vars, const double fluid_density, const double specific_heat_capacity_fluid, const GlobalDimVectorType &velocity, ParameterLib::SpatialPosition const &pos, double const t, double const dt)
Definition HTFEM.h:191
MeshLib::Element const & _element
Definition HTFEM.h:161
HTProcessData const & _process_data
Definition HTFEM.h:162
std::vector< IntegrationPointData< GlobalDimNodalMatrixType > > _ip_data
Definition HTFEM.h:165
static const int pressure_index
Definition HTFEM.h:314
typename ShapeMatricesType::NodalMatrixType NodalMatrixType
typename ShapeMatricesType::template MatrixType< NUM_NODAL_DOF *ShapeFunction::NPOINTS, NUM_NODAL_DOF *ShapeFunction::NPOINTS > LocalMatrixType
typename ShapeMatricesType::template VectorType< NUM_NODAL_DOF * ShapeFunction::NPOINTS > LocalVectorType
typename ShapeMatricesType::ShapeMatrices ShapeMatrices
typename ShapeMatricesType::NodalRowVectorType NodalRowVectorType
MonolithicHTFEM(MeshLib::Element const &element, std::size_t const local_matrix_size, NumLib::GenericIntegrationMethod const &integration_method, bool is_axially_symmetric, HTProcessData const &process_data)
typename ShapeMatricesType::GlobalDimVectorType GlobalDimVectorType
void assemble(double const t, double const dt, std::vector< double > const &local_x, std::vector< double > const &, std::vector< double > &local_M_data, std::vector< double > &local_K_data, std::vector< double > &local_b_data) override
typename ShapeMatricesType::NodalVectorType NodalVectorType
ShapeMatrixPolicyType< ShapeFunction, GlobalDim > ShapeMatricesType
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
typename ShapeMatricesType::GlobalDimMatrixType GlobalDimMatrixType
constexpr Eigen::Matrix< double, GlobalDim, GlobalDim > formEigenTensor(MaterialPropertyLib::PropertyDataType const &values)
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 &)
void assembleAdvectionMatrix(IPData const &ip_data_vector, NumLib::ShapeMatrixCache const &shape_matrix_cache, std::vector< FluxVectorType > const &ip_flux_vector, Eigen::MatrixBase< Derived > &laplacian_matrix)
std::vector< GlobalIndexType > getIndices(std::size_t const mesh_item_id, NumLib::LocalToGlobalIndexMap const &dof_table)
std::array< double, 3 > interpolateCoordinates(MeshLib::Element const &e, typename ShapeMatricesType::ShapeMatrices::ShapeType const &N)
const unsigned NUM_NODAL_DOF
NumLib::ShapeMatrices< NodalRowVectorType, DimNodalMatrixType, DimMatrixType, GlobalDimNodalMatrixType > ShapeMatrices
MatrixType< ShapeFunction::NPOINTS, ShapeFunction::NPOINTS > NodalMatrixType
MatrixType< GlobalDim, GlobalDim > GlobalDimMatrixType
VectorType< GlobalDim > GlobalDimVectorType
VectorType< ShapeFunction::NPOINTS > NodalVectorType
RowVectorType< ShapeFunction::NPOINTS > NodalRowVectorType