OGS
VolumetricSourceTermFEM.h
Go to the documentation of this file.
1 
11 #pragma once
12 
13 #include <vector>
14 
19 #include "ParameterLib/Parameter.h"
22 
23 namespace ProcessLib
24 {
26 {
27 public:
28  virtual void integrate(
29  std::size_t const id,
30  NumLib::LocalToGlobalIndexMap const& source_term_dof_table,
31  double const t, GlobalVector& b) = 0;
33 };
34 
35 template <typename ShapeFunction, typename IntegrationMethod, int GlobalDim>
38 {
39  static const unsigned NUM_NODAL_DOF = 1;
40 
42 
44  ShapeMatricesType, ShapeFunction::NPOINTS, NUM_NODAL_DOF, GlobalDim>;
45 
48 
49 public:
51  MeshLib::Element const& element,
52  std::size_t const local_matrix_size,
53  bool const is_axially_symmetric,
54  unsigned const integration_order,
55  ParameterLib::Parameter<double> const& volumetric_source_term)
56  : _volumetric_source_term(volumetric_source_term),
57  _integration_method(integration_order),
58  _element(element),
59  _local_rhs(local_matrix_size)
60  {
61  unsigned const n_integration_points =
62  _integration_method.getNumberOfPoints();
63 
64  auto const shape_matrices =
66  GlobalDim>(_element, is_axially_symmetric,
68 
69  for (unsigned ip = 0; ip < n_integration_points; ip++)
70  {
71  _ip_data.emplace_back(
72  shape_matrices[ip].N,
73  _integration_method.getWeightedPoint(ip).getWeight() *
74  shape_matrices[ip].integralMeasure *
75  shape_matrices[ip].detJ);
76  }
77  }
78 
79  void integrate(std::size_t const id,
80  NumLib::LocalToGlobalIndexMap const& source_term_dof_table,
81  double const t, GlobalVector& b) override
82  {
83  _local_rhs.setZero();
84 
85  unsigned const n_integration_points =
86  _integration_method.getNumberOfPoints();
87 
88  for (unsigned ip = 0; ip < n_integration_points; ip++)
89  {
90  auto const& N = _ip_data[ip].N;
91  auto const& w = _ip_data[ip].integration_weight;
92 
94  std::nullopt, _element.getID(), ip,
96  NumLib::interpolateCoordinates<ShapeFunction,
98  N))};
99  auto const st_val = _volumetric_source_term(t, pos)[0];
100 
101  _local_rhs.noalias() += N.transpose() * st_val * w;
102  }
103  auto const indices = NumLib::getIndices(id, source_term_dof_table);
104  b.add(indices, _local_rhs);
105  }
106 
107 private:
109 
110  IntegrationMethod const _integration_method;
111  std::vector<SourceTermIntegrationPointData<NodalRowVectorType>,
112  Eigen::aligned_allocator<
117 };
118 
119 } // namespace ProcessLib
Global vector based on Eigen vector.
Definition: EigenVector.h:26
void add(IndexType rowId, double v)
add entry
Definition: EigenVector.h:80
virtual std::size_t getID() const final
Returns the ID of the element.
Definition: Element.h:82
virtual void integrate(std::size_t const id, NumLib::LocalToGlobalIndexMap const &source_term_dof_table, double const t, GlobalVector &b)=0
typename LocalAssemblerTraits::LocalVector NodalVectorType
std::vector< SourceTermIntegrationPointData< NodalRowVectorType >, Eigen::aligned_allocator< SourceTermIntegrationPointData< NodalRowVectorType > > > _ip_data
VolumetricSourceTermLocalAssembler(MeshLib::Element const &element, std::size_t const local_matrix_size, bool const is_axially_symmetric, unsigned const integration_order, ParameterLib::Parameter< double > const &volumetric_source_term)
ShapeMatrixPolicyType< ShapeFunction, GlobalDim > ShapeMatricesType
void integrate(std::size_t const id, NumLib::LocalToGlobalIndexMap const &source_term_dof_table, double const t, GlobalVector &b) override
typename ShapeMatricesType::NodalRowVectorType NodalRowVectorType
ParameterLib::Parameter< double > const & _volumetric_source_term
MathLib::TemplatePoint< double, 3 > Point3d
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)
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)
RowVectorType< ShapeFunction::NPOINTS > NodalRowVectorType