OGS
MonolithicHTFEM.h
Go to the documentation of this file.
1 
12 #pragma once
13 
14 #include <Eigen/Dense>
15 #include <vector>
16 
17 #include "HTFEM.h"
18 #include "HTProcessData.h"
19 #include "MaterialLib/MPL/Medium.h"
26 #include "ParameterLib/Parameter.h"
27 
28 namespace ProcessLib
29 {
30 namespace HT
31 {
32 const unsigned NUM_NODAL_DOF = 2;
33 
34 template <typename ShapeFunction, typename IntegrationMethod, int GlobalDim>
36  : public HTFEM<ShapeFunction, IntegrationMethod, GlobalDim>
37 {
40 
41  using LocalMatrixType = typename ShapeMatricesType::template MatrixType<
42  NUM_NODAL_DOF * ShapeFunction::NPOINTS,
43  NUM_NODAL_DOF * ShapeFunction::NPOINTS>;
45  typename ShapeMatricesType::template VectorType<NUM_NODAL_DOF *
46  ShapeFunction::NPOINTS>;
47 
50 
53 
54 public:
56  std::size_t const local_matrix_size,
57  bool is_axially_symmetric,
58  unsigned const integration_order,
59  HTProcessData const& process_data)
60  : HTFEM<ShapeFunction, IntegrationMethod, GlobalDim>(
61  element, local_matrix_size, is_axially_symmetric,
62  integration_order, process_data, NUM_NODAL_DOF)
63  {
64  }
65 
66  void assemble(double const t, double const dt,
67  std::vector<double> const& local_x,
68  std::vector<double> const& /*local_xdot*/,
69  std::vector<double>& local_M_data,
70  std::vector<double>& local_K_data,
71  std::vector<double>& local_b_data) override
72  {
73  auto const local_matrix_size = local_x.size();
74  // This assertion is valid only if all nodal d.o.f. use the same shape
75  // matrices.
76  assert(local_matrix_size == ShapeFunction::NPOINTS * NUM_NODAL_DOF);
77 
78  auto local_M = MathLib::createZeroedMatrix<LocalMatrixType>(
79  local_M_data, local_matrix_size, local_matrix_size);
80  auto local_K = MathLib::createZeroedMatrix<LocalMatrixType>(
81  local_K_data, local_matrix_size, local_matrix_size);
82  auto local_b = MathLib::createZeroedVector<LocalVectorType>(
83  local_b_data, local_matrix_size);
84 
85  auto KTT = local_K.template block<temperature_size, temperature_size>(
87  auto MTT = local_M.template block<temperature_size, temperature_size>(
89  auto Kpp = local_K.template block<pressure_size, pressure_size>(
91  auto Mpp = local_M.template block<pressure_size, pressure_size>(
93  auto Bp = local_b.template block<pressure_size, 1>(pressure_index, 0);
94 
96  pos.setElementID(this->_element.getID());
97 
98  auto p_nodal_values = Eigen::Map<const NodalVectorType>(
99  &local_x[pressure_index], pressure_size);
100 
101  auto const& process_data = this->_process_data;
102  auto const& medium =
103  *process_data.media_map->getMedium(this->_element.getID());
104  auto const& liquid_phase = medium.phase("AqueousLiquid");
105  auto const& solid_phase = medium.phase("Solid");
106 
107  auto const& b = process_data.specific_body_force;
108 
109  GlobalDimMatrixType const& I(
110  GlobalDimMatrixType::Identity(GlobalDim, GlobalDim));
111 
113 
114  unsigned const n_integration_points =
115  this->_integration_method.getNumberOfPoints();
116 
117  for (unsigned ip(0); ip < n_integration_points; ip++)
118  {
119  pos.setIntegrationPoint(ip);
120 
121  auto const& ip_data = this->_ip_data[ip];
122  auto const& N = ip_data.N;
123  auto const& dNdx = ip_data.dNdx;
124  auto const& w = ip_data.integration_weight;
125 
126  double T_int_pt = 0.0;
127  double p_int_pt = 0.0;
128  // Order matters: First T, then P!
129  NumLib::shapeFunctionInterpolate(local_x, N, T_int_pt, p_int_pt);
130 
131  vars[static_cast<int>(MaterialPropertyLib::Variable::temperature)] =
132  T_int_pt;
133  vars[static_cast<int>(
135 
136  vars[static_cast<int>(
138  // \todo the argument to getValue() has to be changed for non
139  // constant storage model
140  auto const specific_storage =
141  solid_phase.property(MaterialPropertyLib::PropertyType::storage)
142  .template value<double>(vars, pos, t, dt);
143 
144  auto const porosity =
146  .template value<double>(vars, pos, t, dt);
147  vars[static_cast<int>(MaterialPropertyLib::Variable::porosity)] =
148  porosity;
149 
150  auto const intrinsic_permeability =
151  MaterialPropertyLib::formEigenTensor<GlobalDim>(
152  medium
153  .property(
155  .value(vars, pos, t, dt));
156 
157  auto const specific_heat_capacity_fluid =
158  liquid_phase
160  .template value<double>(vars, pos, t, dt);
161 
162  // Use the fluid density model to compute the density
163  auto const fluid_density =
164  liquid_phase
166  .template value<double>(vars, pos, t, dt);
167 
168  // Use the viscosity model to compute the viscosity
169  auto const viscosity =
170  liquid_phase
172  .template value<double>(vars, pos, t, dt);
173  GlobalDimMatrixType K_over_mu = intrinsic_permeability / viscosity;
174 
175  GlobalDimVectorType const velocity =
176  process_data.has_gravity
177  ? GlobalDimVectorType(-K_over_mu * (dNdx * p_nodal_values -
178  fluid_density * b))
179  : GlobalDimVectorType(-K_over_mu * dNdx * p_nodal_values);
180 
181  // matrix assembly
182  GlobalDimMatrixType const thermal_conductivity_dispersivity =
184  vars, fluid_density, specific_heat_capacity_fluid, velocity,
185  I, pos, t, dt);
186  KTT.noalias() +=
187  (dNdx.transpose() * thermal_conductivity_dispersivity * dNdx +
188  N.transpose() * velocity.transpose() * dNdx * fluid_density *
189  specific_heat_capacity_fluid) *
190  w;
191  Kpp.noalias() += w * dNdx.transpose() * K_over_mu * dNdx;
192  MTT.noalias() += w *
194  vars, porosity, fluid_density,
195  specific_heat_capacity_fluid, pos, t, dt) *
196  N.transpose() * N;
197  Mpp.noalias() += w * N.transpose() * specific_storage * N;
198  if (process_data.has_gravity)
199  {
200  Bp += w * fluid_density * dNdx.transpose() * K_over_mu * b;
201  }
202  /* with Oberbeck-Boussing assumption density difference only exists
203  * in buoyancy effects */
204  }
205  }
206 
207  std::vector<double> const& getIntPtDarcyVelocity(
208  const double t,
209  std::vector<GlobalVector*> const& x,
210  std::vector<NumLib::LocalToGlobalIndexMap const*> const& dof_table,
211  std::vector<double>& cache) const override
212  {
213  int const process_id = 0; // monolithic case.
214  auto const indices =
215  NumLib::getIndices(this->_element.getID(), *dof_table[process_id]);
216  assert(!indices.empty());
217  auto const& local_x = x[process_id]->get(indices);
218 
219  return this->getIntPtDarcyVelocityLocal(t, local_x, cache);
220  }
221 
222 private:
227 };
228 
229 } // namespace HT
230 } // namespace ProcessLib
virtual std::size_t getID() const final
Returns the ID of the element.
Definition: Element.h:82
void setElementID(std::size_t element_id)
void setIntegrationPoint(unsigned integration_point)
IntegrationMethod const _integration_method
Definition: HTFEM.h:163
typename ShapeMatricesType::NodalVectorType NodalVectorType
Definition: HTFEM.h:37
static const int pressure_index
Definition: HTFEM.h:319
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:170
MeshLib::Element const & _element
Definition: HTFEM.h:160
static const int pressure_size
Definition: HTFEM.h:320
typename ShapeMatricesType::GlobalDimVectorType GlobalDimVectorType
Definition: HTFEM.h:40
HTProcessData const & _process_data
Definition: HTFEM.h:161
typename ShapeMatricesType::ShapeMatrices ShapeMatrices
Definition: HTFEM.h:35
static const int temperature_index
Definition: HTFEM.h:321
std::vector< IntegrationPointData< NodalRowVectorType, GlobalDimNodalMatrixType >, Eigen::aligned_allocator< IntegrationPointData< NodalRowVectorType, GlobalDimNodalMatrixType > > > _ip_data
Definition: HTFEM.h:168
typename ShapeMatricesType::GlobalDimMatrixType GlobalDimMatrixType
Definition: HTFEM.h:43
typename ShapeMatricesType::NodalRowVectorType NodalRowVectorType
Definition: HTFEM.h:38
std::vector< double > const & getIntPtDarcyVelocityLocal(const double t, std::vector< double > const &local_x, std::vector< double > &cache) const
Definition: HTFEM.h:239
GlobalDimMatrixType getThermalConductivityDispersivity(MaterialPropertyLib::VariableArray const &vars, const double fluid_density, const double specific_heat_capacity_fluid, const GlobalDimVectorType &velocity, const GlobalDimMatrixType &I, ParameterLib::SpatialPosition const &pos, double const t, double const dt)
Definition: HTFEM.h:194
MonolithicHTFEM(MeshLib::Element const &element, std::size_t const local_matrix_size, bool is_axially_symmetric, unsigned const integration_order, HTProcessData const &process_data)
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
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::GlobalDimVectorType GlobalDimVectorType
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
std::array< VariableType, static_cast< int >(Variable::number_of_variables)> VariableArray
Definition: VariableType.h:108
void shapeFunctionInterpolate(const NodalValues &nodal_values, const ShapeMatrix &shape_matrix_N, double &interpolated_value, ScalarTypes &... interpolated_values)
Definition: Interpolation.h:79
std::vector< GlobalIndexType > getIndices(std::size_t const mesh_item_id, NumLib::LocalToGlobalIndexMap const &dof_table)
const unsigned NUM_NODAL_DOF
double fluid_density(const double p, const double T, const double x)
NumLib::ShapeMatrices< NodalRowVectorType, DimNodalMatrixType, DimMatrixType, GlobalDimNodalMatrixType > ShapeMatrices
MatrixType< GlobalDim, GlobalDim > GlobalDimMatrixType
VectorType< GlobalDim > GlobalDimVectorType
VectorType< ShapeFunction::NPOINTS > NodalVectorType
RowVectorType< ShapeFunction::NPOINTS > NodalRowVectorType
std::unique_ptr< MaterialPropertyLib::MaterialSpatialDistributionMap > media_map
Definition: HTProcessData.h:28