OGS
LiquidFlowLocalAssembler.h
Go to the documentation of this file.
1 
13 #pragma once
14 
15 #include <Eigen/Dense>
16 #include <vector>
17 
18 #include "LiquidFlowData.h"
19 #include "MaterialLib/MPL/Medium.h"
27 #include "ParameterLib/Parameter.h"
30 
31 namespace ProcessLib
32 {
33 namespace LiquidFlow
34 {
35 template <typename NodalRowVectorType, typename GlobalDimNodalMatrixType>
37 {
38  explicit IntegrationPointData(NodalRowVectorType const& N_,
39  GlobalDimNodalMatrixType const& dNdx_,
40  double const& integration_weight_)
41  : N(N_), dNdx(dNdx_), integration_weight(integration_weight_)
42  {
43  }
44 
45  NodalRowVectorType const N;
46  GlobalDimNodalMatrixType const dNdx;
47  double const integration_weight;
48 
50 };
51 
52 const unsigned NUM_NODAL_DOF = 1;
53 
57 {
58 public:
59  virtual std::vector<double> const& getIntPtDarcyVelocity(
60  const double t,
61  std::vector<GlobalVector*> const& x,
62  std::vector<NumLib::LocalToGlobalIndexMap const*> const& dof_table,
63  std::vector<double>& cache) const = 0;
64 };
65 
66 template <typename ShapeFunction, typename IntegrationMethod, int GlobalDim>
68 {
71 
74  ShapeFunction::NPOINTS, NUM_NODAL_DOF,
75  ShapeFunction::DIM>;
76 
84 
85 public:
87  std::size_t const /*local_matrix_size*/,
88  bool const is_axially_symmetric,
89  unsigned const integration_order,
90  LiquidFlowData const& process_data)
91  : _element(element),
92  _integration_method(integration_order),
93  _process_data(process_data)
94  {
95  unsigned const n_integration_points =
96  _integration_method.getNumberOfPoints();
97  _ip_data.reserve(n_integration_points);
98 
99  auto const& shape_matrices =
101  GlobalDim>(element, is_axially_symmetric,
103 
104  for (unsigned ip = 0; ip < n_integration_points; ip++)
105  {
106  _ip_data.emplace_back(
107  shape_matrices[ip].N, shape_matrices[ip].dNdx,
108  _integration_method.getWeightedPoint(ip).getWeight() *
109  shape_matrices[ip].integralMeasure *
110  shape_matrices[ip].detJ);
111  }
112  }
113 
114  void assemble(double const t, double const dt,
115  std::vector<double> const& local_x,
116  std::vector<double> const& /*local_xdot*/,
117  std::vector<double>& local_M_data,
118  std::vector<double>& local_K_data,
119  std::vector<double>& local_b_data) override;
120 
123  Eigen::Vector3d getFlux(MathLib::Point3d const& p_local_coords,
124  double const t,
125  std::vector<double> const& local_x) const override;
126 
127  Eigen::Map<const Eigen::RowVectorXd> getShapeMatrix(
128  const unsigned integration_point) const override
129  {
130  auto const& N = _ip_data[integration_point].N;
131 
132  // assumes N is stored contiguously in memory
133  return Eigen::Map<const Eigen::RowVectorXd>(N.data(), N.size());
134  }
135 
136  std::vector<double> const& getIntPtDarcyVelocity(
137  const double t,
138  std::vector<GlobalVector*> const& x,
139  std::vector<NumLib::LocalToGlobalIndexMap const*> const& dof_table,
140  std::vector<double>& velocity_cache) const override;
141 
142 private:
144 
145  IntegrationMethod const _integration_method;
146  std::vector<
148  Eigen::aligned_allocator<
151 
157  {
159  Eigen::Map<NodalMatrixType>& local_K,
160  Eigen::Map<NodalVectorType>& local_b,
162  GlobalDimNodalMatrixType> const& ip_data,
163  DimMatrixType const& permeability, double const mu,
164  double const rho_L, DimVectorType const& specific_body_force,
165  bool const has_gravity);
166 
167  static Eigen::Matrix<double, ShapeFunction::DIM, 1> calculateVelocity(
168  Eigen::Map<const NodalVectorType> const& local_p,
170  GlobalDimNodalMatrixType> const& ip_data,
171  DimMatrixType const& permeability, double const mu,
172  double const rho_L, DimVectorType const& specific_body_force,
173  bool const has_gravity);
174  };
175 
181  {
183  Eigen::Map<NodalMatrixType>& local_K,
184  Eigen::Map<NodalVectorType>& local_b,
186  GlobalDimNodalMatrixType> const& ip_data,
187  DimMatrixType const& permeability, double const mu,
188  double const rho_L, DimVectorType const& specific_body_force,
189  bool const has_gravity);
190 
191  static Eigen::Matrix<double, ShapeFunction::DIM, 1> calculateVelocity(
192  Eigen::Map<const NodalVectorType> const& local_p,
194  GlobalDimNodalMatrixType> const& ip_data,
195  DimMatrixType const& permeability, double const mu,
196  double const rho_L, DimVectorType const& specific_body_force,
197  bool const has_gravity);
198  };
199 
200  template <typename LaplacianGravityVelocityCalculator>
201  void assembleMatrixAndVector(double const t, double const dt,
202  std::vector<double> const& local_x,
203  std::vector<double>& local_M_data,
204  std::vector<double>& local_K_data,
205  std::vector<double>& local_b_data);
206 
207  template <typename LaplacianGravityVelocityCalculator,
208  typename VelocityCacheType>
210  const double t, const double dt, std::vector<double> const& local_x,
212  VelocityCacheType& darcy_velocity_at_ips) const;
213 
214  template <typename VelocityCacheType>
215  void computeDarcyVelocity(bool const is_scalar_permeability, const double t,
216  const double dt,
217  std::vector<double> const& local_x,
219  VelocityCacheType& darcy_velocity_at_ips) const;
220 
222 };
223 
224 } // namespace LiquidFlow
225 } // namespace ProcessLib
226 
virtual 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 =0
std::vector< IntegrationPointData< NodalRowVectorType, GlobalDimNodalMatrixType >, Eigen::aligned_allocator< IntegrationPointData< NodalRowVectorType, GlobalDimNodalMatrixType > > > _ip_data
void assembleMatrixAndVector(double const t, double const dt, std::vector< double > const &local_x, std::vector< double > &local_M_data, std::vector< double > &local_K_data, std::vector< double > &local_b_data)
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 LocalAssemblerTraits::LocalMatrix NodalMatrixType
typename ShapeMatricesType::DimVectorType DimVectorType
Eigen::Map< const Eigen::RowVectorXd > getShapeMatrix(const unsigned integration_point) const override
Provides the shape matrix at the given integration point.
std::vector< double > const & getIntPtDarcyVelocity(const double t, std::vector< GlobalVector * > const &x, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_table, std::vector< double > &velocity_cache) const override
typename ShapeMatricesType::NodalRowVectorType NodalRowVectorType
typename ShapeMatricesType::ShapeMatrices ShapeMatrices
ShapeMatrixPolicyType< ShapeFunction > ShapeMatricesType
typename ShapeMatricesType::GlobalDimNodalMatrixType GlobalDimNodalMatrixType
Eigen::Vector3d getFlux(MathLib::Point3d const &p_local_coords, double const t, std::vector< double > const &local_x) const override
LiquidFlowLocalAssembler(MeshLib::Element const &element, std::size_t const, bool const is_axially_symmetric, unsigned const integration_order, LiquidFlowData const &process_data)
void computeDarcyVelocity(bool const is_scalar_permeability, const double t, const double dt, std::vector< double > const &local_x, ParameterLib::SpatialPosition const &pos, VelocityCacheType &darcy_velocity_at_ips) const
typename ShapeMatricesType::DimMatrixType DimMatrixType
typename LocalAssemblerTraits::LocalVector NodalVectorType
void computeProjectedDarcyVelocity(const double t, const double dt, std::vector< double > const &local_x, ParameterLib::SpatialPosition const &pos, VelocityCacheType &darcy_velocity_at_ips) const
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)
VectorType< ShapeFunction::DIM > DimVectorType
NumLib::ShapeMatrices< NodalRowVectorType, DimNodalMatrixType, DimMatrixType, GlobalDimNodalMatrixType > ShapeMatrices
MatrixType< ShapeFunction::DIM, ShapeFunction::DIM > DimMatrixType
MatrixType< GlobalDim, ShapeFunction::NPOINTS > GlobalDimNodalMatrixType
RowVectorType< ShapeFunction::NPOINTS > NodalRowVectorType
IntegrationPointData(NodalRowVectorType const &N_, GlobalDimNodalMatrixType const &dNdx_, double const &integration_weight_)
static void calculateLaplacianAndGravityTerm(Eigen::Map< NodalMatrixType > &local_K, Eigen::Map< NodalVectorType > &local_b, IntegrationPointData< NodalRowVectorType, GlobalDimNodalMatrixType > const &ip_data, DimMatrixType const &permeability, double const mu, double const rho_L, DimVectorType const &specific_body_force, bool const has_gravity)
static Eigen::Matrix< double, ShapeFunction::DIM, 1 > calculateVelocity(Eigen::Map< const NodalVectorType > const &local_p, IntegrationPointData< NodalRowVectorType, GlobalDimNodalMatrixType > const &ip_data, DimMatrixType const &permeability, double const mu, double const rho_L, DimVectorType const &specific_body_force, bool const has_gravity)
static void calculateLaplacianAndGravityTerm(Eigen::Map< NodalMatrixType > &local_K, Eigen::Map< NodalVectorType > &local_b, IntegrationPointData< NodalRowVectorType, GlobalDimNodalMatrixType > const &ip_data, DimMatrixType const &permeability, double const mu, double const rho_L, DimVectorType const &specific_body_force, bool const has_gravity)
static Eigen::Matrix< double, ShapeFunction::DIM, 1 > calculateVelocity(Eigen::Map< const NodalVectorType > const &local_p, IntegrationPointData< NodalRowVectorType, GlobalDimNodalMatrixType > const &ip_data, DimMatrixType const &permeability, double const mu, double const rho_L, DimVectorType const &specific_body_force, bool const has_gravity)
Matrix< NNodes *NodalDOF, NNodes *NodalDOF > LocalMatrix