OGS
NormalTractionBoundaryConditionLocalAssembler.h
Go to the documentation of this file.
1 
11 #pragma once
12 
17 #include "ParameterLib/Parameter.h"
18 
19 namespace ProcessLib
20 {
21 namespace NormalTractionBoundaryCondition
22 {
23 template <typename ShapeMatricesType>
25 {
27  typename ShapeMatricesType::ShapeMatrices::ShapeType const N_,
28  typename ShapeMatricesType::GlobalDimVectorType const n_,
29  double const integration_weight_)
30  : N(N_), n(n_), integration_weight(integration_weight_)
31  {
32  }
33 
34  typename ShapeMatricesType::ShapeMatrices::ShapeType const N;
35  typename ShapeMatricesType::GlobalDimVectorType const n;
36  double const integration_weight;
37 };
38 
40 {
41 public:
42  virtual void assemble(
43  std::size_t const id,
44  NumLib::LocalToGlobalIndexMap const& dof_table_boundary, double const t,
45  std::vector<GlobalVector*> const& /*x*/, GlobalMatrix& /*K*/,
46  GlobalVector& b, GlobalMatrix* /*Jac*/) = 0;
48 };
49 
50 template <typename ShapeFunctionDisplacement, typename IntegrationMethod,
51  int GlobalDim>
54 {
55 public:
60 
62  MeshLib::Element const& e,
63  std::size_t const local_matrix_size,
64  bool const is_axially_symmetric,
65  unsigned const integration_order,
66  ParameterLib::Parameter<double> const& pressure)
67  : _integration_method(integration_order),
68  _pressure(pressure),
69  _element(e)
70  {
71  _local_rhs.setZero(local_matrix_size);
72 
73  unsigned const n_integration_points =
74  _integration_method.getNumberOfPoints();
75 
76  _ip_data.reserve(n_integration_points);
77 
78  auto const shape_matrices_u =
79  NumLib::initShapeMatrices<ShapeFunctionDisplacement,
80  ShapeMatricesType, GlobalDim>(
81  e, is_axially_symmetric, _integration_method);
82 
83  GlobalDimVectorType element_normal(GlobalDim);
84 
85  // TODO Extend to rotated 2d meshes and line elements.
87  {
88  Eigen::Vector3d const v1 =
89  Eigen::Map<Eigen::Vector3d const>(e.getNode(1)->getCoords()) -
90  Eigen::Map<Eigen::Vector3d const>(e.getNode(0)->getCoords());
91  element_normal[0] = -v1[1];
92  element_normal[1] = v1[0];
93  element_normal.normalize();
94  }
95  else
96  {
97  auto const n = MeshLib::FaceRule::getSurfaceNormal(e).normalized();
98  for (int i = 0; i < GlobalDim; ++i)
99  {
100  element_normal[i] = n[i];
101  }
102  }
103 
104  for (unsigned ip = 0; ip < n_integration_points; ip++)
105  {
106  double const integration_weight =
107  _integration_method.getWeightedPoint(ip).getWeight() *
108  shape_matrices_u[ip].integralMeasure *
109  shape_matrices_u[ip].detJ;
110 
111  _ip_data.emplace_back(shape_matrices_u[ip].N, element_normal,
112  integration_weight);
113  }
114  }
115 
116  void assemble(std::size_t const id,
117  NumLib::LocalToGlobalIndexMap const& dof_table_boundary,
118  double const t, std::vector<GlobalVector*> const& /*x*/,
119  GlobalMatrix& /*K*/, GlobalVector& local_rhs,
120  GlobalMatrix* /*Jac*/) override
121  {
122  _local_rhs.setZero();
123 
124  unsigned const n_integration_points =
125  _integration_method.getNumberOfPoints();
126 
127  NodalVectorType pressure =
129 
130  for (unsigned ip = 0; ip < n_integration_points; ip++)
131  {
132  auto const& w = _ip_data[ip].integration_weight;
133  auto const& N = _ip_data[ip].N;
134  auto const& n = _ip_data[ip].n;
135 
136  typename ShapeMatricesType::template MatrixType<GlobalDim,
138  N_u = ShapeMatricesType::template MatrixType<
139  GlobalDim, displacement_size>::Zero(GlobalDim,
141  for (int i = 0; i < GlobalDim; ++i)
142  {
143  N_u.template block<1, displacement_size / GlobalDim>(
144  i, i * displacement_size / GlobalDim)
145  .noalias() = N;
146  }
147 
148  _local_rhs.noalias() -= n.transpose() * N_u * pressure.dot(N) * w;
149  }
150 
151  auto const indices = NumLib::getIndices(id, dof_table_boundary);
152  local_rhs.add(indices, _local_rhs);
153  }
154 
155 private:
156  IntegrationMethod const _integration_method;
158 
159  static const int displacement_size =
160  ShapeFunctionDisplacement::NPOINTS * GlobalDim;
161  std::vector<
163  Eigen::aligned_allocator<IntegrationPointData<ShapeMatricesType>>>
165 
166  typename ShapeMatricesType::template VectorType<displacement_size>
168 
170 
171 public:
173 };
174 
175 } // namespace NormalTractionBoundaryCondition
176 } // namespace ProcessLib
Global vector based on Eigen vector.
Definition: EigenVector.h:26
void add(IndexType rowId, double v)
add entry
Definition: EigenVector.h:80
const T * getCoords() const
Definition: TemplatePoint.h:75
virtual MeshElemType getGeomType() const =0
virtual const Node * getNode(unsigned idx) const =0
static Eigen::Vector3d getSurfaceNormal(Element const &e)
Returns the surface normal of a 2D element.
Definition: FaceRule.cpp:40
virtual void assemble(std::size_t const id, NumLib::LocalToGlobalIndexMap const &dof_table_boundary, double const t, std::vector< GlobalVector * > const &, GlobalMatrix &, GlobalVector &b, GlobalMatrix *)=0
std::vector< IntegrationPointData< ShapeMatricesType >, Eigen::aligned_allocator< IntegrationPointData< ShapeMatricesType > > > _ip_data
NormalTractionBoundaryConditionLocalAssembler(MeshLib::Element const &e, std::size_t const local_matrix_size, bool const is_axially_symmetric, unsigned const integration_order, ParameterLib::Parameter< double > const &pressure)
void assemble(std::size_t const id, NumLib::LocalToGlobalIndexMap const &dof_table_boundary, double const t, std::vector< GlobalVector * > const &, GlobalMatrix &, GlobalVector &local_rhs, GlobalMatrix *) override
std::vector< GlobalIndexType > getIndices(std::size_t const mesh_item_id, NumLib::LocalToGlobalIndexMap const &dof_table)
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< GlobalDim > GlobalDimVectorType
VectorType< ShapeFunction::NPOINTS > NodalVectorType
virtual Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > getNodalValuesOnElement(MeshLib::Element const &element, double const t) const
Returns a matrix of values for all nodes of the given element.
Definition: Parameter.h:163
IntegrationPointData(typename ShapeMatricesType::ShapeMatrices::ShapeType const N_, typename ShapeMatricesType::GlobalDimVectorType const n_, double const integration_weight_)