OGS
NeumannBoundaryConditionLocalAssembler.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
6#include <typeinfo>
7
14
15namespace ProcessLib
16{
22
23template <typename ShapeFunction, int GlobalDim>
26 GlobalDim>
27{
28 using Base =
32
33public:
37 MeshLib::Element const& e,
38 std::size_t const local_matrix_size,
39 NumLib::GenericIntegrationMethod const& integration_method,
40 bool const is_axially_symmetric,
42 : Base(e, is_axially_symmetric, integration_method),
43 _data(data),
44 _local_rhs(local_matrix_size)
45 {
46 }
47
48 void assemble(std::size_t const id,
49 NumLib::LocalToGlobalIndexMap const& dof_table_boundary,
50 double const t, std::vector<GlobalVector*> const& /*x*/,
51 int const /*process_id*/, GlobalMatrix* /*K*/,
52 GlobalVector& b, GlobalMatrix* /*Jac*/) override
53 {
54 _local_rhs.setZero();
55
56 unsigned const n_integration_points =
57 Base::_integration_method.getNumberOfPoints();
58
59 NodalVectorType parameter_node_values;
61 typeid(_data.neumann_bc_parameter))
62 {
63 // Get element nodes for the interpolation from nodes to integration
64 // point.
65 parameter_node_values =
66 _data.neumann_bc_parameter
67 .getNodalValuesOnElement(Base::_element, t)
68 .template topRows<
69 ShapeFunction::MeshElement::n_all_nodes>();
70 }
71
72 double integral_measure = 1.0;
73 for (unsigned ip = 0; ip < n_integration_points; ip++)
74 {
75 auto const& ip_data = Base::_ns_and_weights[ip];
76 auto const& N = ip_data.N;
77 auto const& w = ip_data.weight;
78
79 ParameterLib::SpatialPosition const position{
80 std::nullopt, Base::_element.getID(),
84 Base::_element, N))};
85
86 if (_data.integral_measure)
87 {
88 integral_measure = (*_data.integral_measure)(t, position)[0];
89 }
91 typeid(_data.neumann_bc_parameter))
92 {
93 _local_rhs.noalias() +=
94 N * parameter_node_values.dot(N) * w * integral_measure;
95 }
96 else
97 {
98 auto const value = _data.neumann_bc_parameter(t, position)[0];
99 _local_rhs.noalias() += N * value * w * integral_measure;
100 }
101 }
102
103 auto const indices = NumLib::getIndices(id, dof_table_boundary);
104 b.add(indices, _local_rhs);
105 }
106
107private:
109
111
112public:
114};
115
116} // namespace ProcessLib
MathLib::EigenMatrix GlobalMatrix
MathLib::EigenVector GlobalVector
EigenFixedShapeMatrixPolicy< ShapeFunction, GlobalDim > ShapeMatrixPolicyType
void add(IndexType rowId, double v)
add entry
Definition EigenVector.h:70
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
NeumannBoundaryConditionLocalAssembler(MeshLib::Element const &e, std::size_t const local_matrix_size, NumLib::GenericIntegrationMethod const &integration_method, bool const is_axially_symmetric, NeumannBoundaryConditionData const &data)
GenericNaturalBoundaryConditionLocalAssembler< ShapeFunction, GlobalDim > Base
void assemble(std::size_t const id, NumLib::LocalToGlobalIndexMap const &dof_table_boundary, double const t, std::vector< GlobalVector * > const &, int const, GlobalMatrix *, GlobalVector &b, GlobalMatrix *) override
ShapeMatrixPolicyType< ShapeFunction, GlobalDim > ShapeMatricesType
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)
A parameter represented by a mesh property vector.
ParameterLib::Parameter< double > const & neumann_bc_parameter
ParameterLib::Parameter< double > const *const integral_measure