OGS
HCNonAdvectiveFreeComponentFlowBoundaryConditionLocalAssembler.h
Go to the documentation of this file.
1 
11 #pragma once
12 
15 #include "MeshLib/PropertyVector.h"
19 #include "ProcessLib/Process.h"
20 
21 namespace ProcessLib
22 {
24 {
28  Process const& process;
29 };
30 
31 template <typename ShapeFunction, typename IntegrationMethod, int GlobalDim>
34  ShapeFunction, IntegrationMethod, GlobalDim>
35 {
37  ShapeFunction, IntegrationMethod, GlobalDim>;
40 
41 public:
45  MeshLib::Element const& e,
46  std::size_t const local_matrix_size,
47  bool const is_axially_symmetric,
48  unsigned const integration_order,
50  : Base(e, is_axially_symmetric, integration_order),
51  _data(data),
52  _local_matrix_size(local_matrix_size),
54  {
55  }
56 
57  void assemble(std::size_t const mesh_item_id,
58  NumLib::LocalToGlobalIndexMap const& dof_table_boundary,
59  double const t, std::vector<GlobalVector*> const& x,
60  int const process_id, GlobalMatrix& /*K*/, GlobalVector& b,
61  GlobalMatrix* /*Jac*/) override
62  {
63  NodalVectorType _local_rhs = NodalVectorType::Zero(_local_matrix_size);
64  // Get element nodes for the interpolation from nodes to
65  // integration point.
66  NodalVectorType const boundary_permeability_node_values =
68  t);
69  unsigned const n_integration_points =
70  Base::_integration_method.getNumberOfPoints();
71 
72  auto const indices =
73  NumLib::getIndices(mesh_item_id, dof_table_boundary);
74  std::vector<double> const local_values = x[process_id]->get(indices);
75  std::size_t const bulk_element_id =
77  std::size_t const bulk_face_id =
79  for (unsigned ip = 0; ip < n_integration_points; ip++)
80  {
81  auto const& n_and_weight = Base::_ns_and_weights[ip];
82  auto const& N = n_and_weight.N;
83  auto const& w = n_and_weight.weight;
84  auto const& wp = Base::_integration_method.getWeightedPoint(ip);
85 
86  auto const bulk_element_point = MeshLib::getBulkElementPoint(
87  _data.process.getMesh(), bulk_element_id, bulk_face_id, wp);
88 
89  double int_pt_value = 0.0;
90  NumLib::shapeFunctionInterpolate(local_values, N, int_pt_value);
91 
92  NodalVectorType const neumann_node_values =
93  -boundary_permeability_node_values * int_pt_value *
94  _data.process.getFlux(bulk_element_id, bulk_element_point, t, x)
95  .dot(_surface_normal);
96  _local_rhs.noalias() += N * neumann_node_values.dot(N) * w;
97  }
98 
99  b.add(indices, _local_rhs);
100  }
101 
102 private:
103  Eigen::Vector3d getOrientedSurfaceNormal(MeshLib::Element const& e) const
104  {
105  // At the moment (2016-09-28) the surface normal is not oriented
106  // according to the right hand rule
107  // for correct results it is necessary to multiply the normal with -1
108  Eigen::Vector3d surface_normal =
109  -MeshLib::FaceRule::getSurfaceNormal(e).normalized();
110  auto const zeros_size = 3 - _data.process.getMesh().getDimension();
111  surface_normal.tail(zeros_size).setZero();
112  return surface_normal;
113  }
114 
116  std::size_t const _local_matrix_size;
117  Eigen::Vector3d const _surface_normal;
118 };
119 
120 } // 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
static Eigen::Vector3d getSurfaceNormal(Element const &e)
Returns the surface normal of a 2D element.
Definition: FaceRule.cpp:40
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Definition: Mesh.h:71
std::vector< NAndWeight, Eigen::aligned_allocator< NAndWeight > > const _ns_and_weights
void assemble(std::size_t const mesh_item_id, NumLib::LocalToGlobalIndexMap const &dof_table_boundary, double const t, std::vector< GlobalVector * > const &x, int const process_id, GlobalMatrix &, GlobalVector &b, GlobalMatrix *) override
HCNonAdvectiveFreeComponentFlowBoundaryConditionLocalAssembler(MeshLib::Element const &e, std::size_t const local_matrix_size, bool const is_axially_symmetric, unsigned const integration_order, HCNonAdvectiveFreeComponentFlowBoundaryConditionData const &data)
virtual Eigen::Vector3d getFlux(std::size_t, MathLib::Point3d const &, double const, std::vector< GlobalVector * > const &) const
Definition: Process.h:167
MeshLib::Mesh & getMesh() const
Definition: Process.h:143
MathLib::Point3d getBulkElementPoint(Tri const &, std::size_t const face_id, MathLib::WeightedPoint1D const &wp)
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)
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