OGS
HCNonAdvectiveFreeComponentFlowBoundaryConditionLocalAssembler.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
12#include "ProcessLib/Process.h"
13
14namespace ProcessLib
15{
23
24template <typename ShapeFunction, int GlobalDim>
27 GlobalDim>
28{
29 using Base =
33
34public:
38 MeshLib::Element const& e,
39 std::size_t const local_matrix_size,
40 NumLib::GenericIntegrationMethod const& integration_method,
41 bool const is_axially_symmetric,
43 : Base(e, is_axially_symmetric, integration_method),
44 _data(data),
45 _local_matrix_size(local_matrix_size),
47 {
48 }
49
50 void assemble(std::size_t const mesh_item_id,
51 NumLib::LocalToGlobalIndexMap const& dof_table_boundary,
52 double const t, std::vector<GlobalVector*> const& x,
53 int const process_id, GlobalMatrix* /*K*/, GlobalVector& b,
54 GlobalMatrix* /*Jac*/) override
55 {
56 NodalVectorType _local_rhs = NodalVectorType::Zero(_local_matrix_size);
57 // Get element nodes for the interpolation from nodes to
58 // integration point.
59 NodalVectorType const boundary_permeability_node_values =
60 _data.boundary_permeability.getNodalValuesOnElement(Base::_element,
61 t);
62 unsigned const n_integration_points =
63 Base::_integration_method.getNumberOfPoints();
64
65 auto const indices =
66 NumLib::getIndices(mesh_item_id, dof_table_boundary);
67 std::vector<double> const local_values = x[process_id]->get(indices);
68 std::size_t const bulk_element_id =
69 _data.bulk_element_ids[Base::_element.getID()];
70 std::size_t const bulk_face_id =
71 _data.bulk_face_ids[Base::_element.getID()];
72 auto const& bulk_element =
73 *_data.process.getMesh().getElement(bulk_element_id);
74
75 for (unsigned ip = 0; ip < n_integration_points; ip++)
76 {
77 auto const& n_and_weight = Base::_ns_and_weights[ip];
78 auto const& N = n_and_weight.N;
79 auto const& w = n_and_weight.weight;
80 auto const& wp = Base::_integration_method.getWeightedPoint(ip);
81
82 auto const bulk_element_point =
83 MeshLib::getBulkElementPoint(bulk_element, bulk_face_id, wp);
84
85 double int_pt_value = 0.0;
86 NumLib::shapeFunctionInterpolate(local_values, N, int_pt_value);
87
88 NodalVectorType const neumann_node_values =
89 -boundary_permeability_node_values * int_pt_value *
90 _data.process.getFlux(bulk_element_id, bulk_element_point, t, x)
91 .dot(_surface_normal);
92 _local_rhs.noalias() += N * neumann_node_values.dot(N) * w;
93 }
94
95 b.add(indices, _local_rhs);
96 }
97
98private:
99 Eigen::Vector3d getOrientedSurfaceNormal(MeshLib::Element const& e) const
100 {
101 // At the moment (2016-09-28) the surface normal is not oriented
102 // according to the right hand rule
103 // for correct results it is necessary to multiply the normal with -1
104 Eigen::Vector3d surface_normal =
106 auto const zeros_size = 3 - _data.process.getMesh().getDimension();
107 surface_normal.tail(zeros_size).setZero();
108 return surface_normal;
109 }
110
112 std::size_t const _local_matrix_size;
113 Eigen::Vector3d const _surface_normal;
114};
115
116} // namespace ProcessLib
MathLib::EigenMatrix GlobalMatrix
MathLib::EigenVector GlobalVector
void add(IndexType rowId, double v)
add entry
Definition EigenVector.h:70
static Eigen::Vector3d getSurfaceNormal(Element const &e)
Returns the surface normal of a 2D element.
Definition FaceRule.cpp:33
GenericNaturalBoundaryConditionLocalAssembler(MeshLib::Element const &e, bool is_axially_symmetric, NumLib::GenericIntegrationMethod const &integration_method)
std::vector< NAndWeight, Eigen::aligned_allocator< NAndWeight > > const _ns_and_weights
HCNonAdvectiveFreeComponentFlowBoundaryConditionLocalAssembler(MeshLib::Element const &e, std::size_t const local_matrix_size, NumLib::GenericIntegrationMethod const &integration_method, bool const is_axially_symmetric, HCNonAdvectiveFreeComponentFlowBoundaryConditionData const &data)
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
MathLib::Point3d getBulkElementPoint(MeshLib::CellType const bulk_element_cell_type, std::size_t const bulk_face_id, MathLib::WeightedPoint const &point_on_face)
void shapeFunctionInterpolate(const NodalValues &, const ShapeMatrix &)
std::vector< GlobalIndexType > getIndices(std::size_t const mesh_item_id, NumLib::LocalToGlobalIndexMap const &dof_table)