Loading [MathJax]/extensions/tex2jax.js
OGS
MonolithicHTFEM.h
Go to the documentation of this file.
1
12#pragma once
13
14#include <Eigen/Core>
15#include <typeinfo>
16#include <vector>
17
18#include "HTFEM.h"
19#include "HTProcessData.h"
30
31namespace ProcessLib
32{
33namespace HT
34{
35const unsigned NUM_NODAL_DOF = 2;
36
37template <typename ShapeFunction, int GlobalDim>
38class MonolithicHTFEM : public HTFEM<ShapeFunction, GlobalDim>
39{
42
43 using LocalMatrixType = typename ShapeMatricesType::template MatrixType<
44 NUM_NODAL_DOF * ShapeFunction::NPOINTS,
45 NUM_NODAL_DOF * ShapeFunction::NPOINTS>;
47 typename ShapeMatricesType::template VectorType<NUM_NODAL_DOF *
48 ShapeFunction::NPOINTS>;
49
53
56
57public:
59 std::size_t const local_matrix_size,
60 NumLib::GenericIntegrationMethod const& integration_method,
61 bool is_axially_symmetric,
62 HTProcessData const& process_data)
63 : HTFEM<ShapeFunction, GlobalDim>(
64 element, local_matrix_size, integration_method,
65 is_axially_symmetric, process_data, NUM_NODAL_DOF)
66 {
67 }
68
69 void assemble(double const t, double const dt,
70 std::vector<double> const& local_x,
71 std::vector<double> const& /*local_x_prev*/,
72 std::vector<double>& local_M_data,
73 std::vector<double>& local_K_data,
74 std::vector<double>& local_b_data) override
75 {
76 auto const local_matrix_size = local_x.size();
77 // This assertion is valid only if all nodal d.o.f. use the same shape
78 // matrices.
79 assert(local_matrix_size == ShapeFunction::NPOINTS * NUM_NODAL_DOF);
80
82 local_M_data, local_matrix_size, local_matrix_size);
84 local_K_data, local_matrix_size, local_matrix_size);
86 local_b_data, local_matrix_size);
87
88 auto KTT = local_K.template block<temperature_size, temperature_size>(
90 auto MTT = local_M.template block<temperature_size, temperature_size>(
92 auto Kpp = local_K.template block<pressure_size, pressure_size>(
94 auto Mpp = local_M.template block<pressure_size, pressure_size>(
96 auto Bp = local_b.template block<pressure_size, 1>(pressure_index, 0);
97
98 auto const& process_data = this->_process_data;
99
100 auto p_nodal_values = Eigen::Map<const NodalVectorType>(
101 &local_x[pressure_index], pressure_size);
102
103 auto const& medium =
104 *process_data.media_map.getMedium(this->_element.getID());
105 auto const& liquid_phase = medium.phase("AqueousLiquid");
106 auto const& solid_phase = medium.phase("Solid");
107
108 auto const& b =
109 process_data
110 .projected_specific_body_force_vectors[this->_element.getID()];
111
113
114 unsigned const n_integration_points =
116
117 std::vector<GlobalDimVectorType> ip_flux_vector;
118 double average_velocity_norm = 0.0;
119 ip_flux_vector.reserve(n_integration_points);
120
121 auto const& Ns =
122 process_data.shape_matrix_cache
123 .template NsHigherOrder<typename ShapeFunction::MeshElement>();
124
125 for (unsigned ip(0); ip < n_integration_points; ip++)
126 {
127 auto const& ip_data = this->_ip_data[ip];
128 auto const& dNdx = ip_data.dNdx;
129 auto const& N = Ns[ip];
130 auto const& w = ip_data.integration_weight;
131
133 std::nullopt, this->_element.getID(),
135 NumLib::interpolateCoordinates<ShapeFunction,
137 this->_element, N))};
138
139 double T_int_pt = 0.0;
140 double p_int_pt = 0.0;
141 // Order matters: First T, then P!
142 NumLib::shapeFunctionInterpolate(local_x, N, T_int_pt, p_int_pt);
143
144 vars.temperature = T_int_pt;
145 vars.liquid_phase_pressure = p_int_pt;
146
147 vars.liquid_saturation = 1.0;
148 // \todo the argument to getValue() has to be changed for non
149 // constant storage model
150 auto const specific_storage =
152 .template value<double>(vars, pos, t, dt);
153
154 auto const porosity =
156 .template value<double>(vars, pos, t, dt);
157 vars.porosity = porosity;
158
159 auto const intrinsic_permeability =
161 medium
162 .property(
164 .value(vars, pos, t, dt));
165
166 auto const specific_heat_capacity_fluid =
167 liquid_phase
169 .template value<double>(vars, pos, t, dt);
170
171 // Use the fluid density model to compute the density
172 auto const fluid_density =
173 liquid_phase
175 .template value<double>(vars, pos, t, dt);
176
177 vars.density = fluid_density;
178 // Use the viscosity model to compute the viscosity
179 auto const viscosity =
180 liquid_phase
182 .template value<double>(vars, pos, t, dt);
183 GlobalDimMatrixType K_over_mu = intrinsic_permeability / viscosity;
184
185 GlobalDimVectorType const velocity =
186 process_data.has_gravity
187 ? GlobalDimVectorType(-K_over_mu * (dNdx * p_nodal_values -
188 fluid_density * b))
189 : GlobalDimVectorType(-K_over_mu * dNdx * p_nodal_values);
190
191 // matrix assembly
192 GlobalDimMatrixType const thermal_conductivity_dispersivity =
194 vars, fluid_density, specific_heat_capacity_fluid, velocity,
195 pos, t, dt);
196
197 KTT.noalias() +=
198 dNdx.transpose() * thermal_conductivity_dispersivity * dNdx * w;
199
200 ip_flux_vector.emplace_back(velocity * fluid_density *
201 specific_heat_capacity_fluid);
202 average_velocity_norm += velocity.norm();
203
204 Kpp.noalias() += w * dNdx.transpose() * K_over_mu * dNdx;
205 MTT.noalias() += w *
207 vars, porosity, fluid_density,
208 specific_heat_capacity_fluid, pos, t, dt) *
209 N.transpose() * N;
210 Mpp.noalias() += w * N.transpose() * specific_storage * N;
211 if (process_data.has_gravity)
212 {
213 Bp += w * fluid_density * dNdx.transpose() * K_over_mu * b;
214 }
215 /* with Oberbeck-Boussing assumption density difference only exists
216 * in buoyancy effects */
217 }
218
220 process_data.stabilizer, this->_ip_data,
221 process_data.shape_matrix_cache, ip_flux_vector,
222 average_velocity_norm / static_cast<double>(n_integration_points),
223 KTT);
224 }
225
226 std::vector<double> const& getIntPtDarcyVelocity(
227 const double t,
228 std::vector<GlobalVector*> const& x,
229 std::vector<NumLib::LocalToGlobalIndexMap const*> const& dof_table,
230 std::vector<double>& cache) const override
231 {
232 int const process_id = 0; // monolithic case.
233 auto const indices =
234 NumLib::getIndices(this->_element.getID(), *dof_table[process_id]);
235 assert(!indices.empty());
236 auto const& local_x = x[process_id]->get(indices);
237
238 return this->getIntPtDarcyVelocityLocal(t, local_x, cache);
239 }
240
241private:
242 using HTFEM<ShapeFunction, GlobalDim>::pressure_index;
243 using HTFEM<ShapeFunction, GlobalDim>::pressure_size;
244 using HTFEM<ShapeFunction, GlobalDim>::temperature_index;
245 using HTFEM<ShapeFunction, GlobalDim>::temperature_size;
246};
247
248} // namespace HT
249} // namespace ProcessLib
std::size_t getID() const
Returns the ID of the element.
Definition Element.h:89
std::vector< double > const & getIntPtDarcyVelocityLocal(const double t, std::vector< double > const &local_x, std::vector< double > &cache) const
Definition HTFEM.h:239
NumLib::GenericIntegrationMethod const & _integration_method
Definition HTFEM.h:171
static const int temperature_index
Definition HTFEM.h:323
static const int temperature_size
Definition HTFEM.h:324
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:174
static const int pressure_size
Definition HTFEM.h:322
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:198
MeshLib::Element const & _element
Definition HTFEM.h:168
HTProcessData const & _process_data
Definition HTFEM.h:169
std::vector< IntegrationPointData< GlobalDimNodalMatrixType > > _ip_data
Definition HTFEM.h:172
static const int pressure_index
Definition HTFEM.h:321
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
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
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