OGS
VariableDependentNeumannBoundaryConditionLocalAssembler.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
11
12namespace ProcessLib
13{
21
32
33template <typename ShapeFunction, int GlobalDim>
36 GlobalDim>
37{
38 using Base =
42
43public:
47 MeshLib::Element const& e,
48 std::size_t const local_matrix_size,
49 NumLib::GenericIntegrationMethod const& integration_method,
50 bool const is_axially_symmetric,
52 : Base(e, is_axially_symmetric, integration_method),
53 _data(data),
54 _local_matrix_size(local_matrix_size)
55 {
56 }
57
58 void assemble(std::size_t const mesh_item_id,
59 NumLib::LocalToGlobalIndexMap const& dof_table_boundary,
60 double const t, std::vector<GlobalVector*> const& x,
61 int const process_id, GlobalMatrix* /*K*/, GlobalVector& b,
62 GlobalMatrix* /*Jac*/) override
63 {
65 _local_rhs.setZero();
66 // Get element nodes for the interpolation from nodes to
67 // integration point.
68 NodalVectorType const constant_node_values =
69 _data.constant.getNodalValuesOnElement(Base::_element, t)
70 .template topRows<ShapeFunction::MeshElement::n_all_nodes>();
71 NodalVectorType const coefficient_current_variable_node_values =
72 _data.current_variable.getNodalValuesOnElement(Base::_element, t)
73 .template topRows<ShapeFunction::MeshElement::n_all_nodes>();
74 NodalVectorType const coefficient_other_variable_node_values =
75 _data.other_variable.getNodalValuesOnElement(Base::_element, t)
76 .template topRows<ShapeFunction::MeshElement::n_all_nodes>();
77 NodalVectorType const coefficient_mixed_variables_node_values =
78 _data.mixed_variables.getNodalValuesOnElement(Base::_element, t)
79 .template topRows<ShapeFunction::MeshElement::n_all_nodes>();
80 unsigned const n_integration_points =
81 Base::_integration_method.getNumberOfPoints();
82
83 auto const indices_current_variable =
84 NumLib::getIndices(mesh_item_id, dof_table_boundary);
85 auto const indices_other_variable = NumLib::getIndices(
86 mesh_item_id, *_data.dof_table_boundary_other_variable);
87 std::vector<double> const local_current_variable =
88 x[process_id]->get(indices_current_variable);
89 std::vector<double> const local_other_variable =
90 x[process_id]->get(indices_other_variable);
91
92 for (unsigned ip = 0; ip < n_integration_points; ip++)
93 {
94 auto const& n_and_weight = Base::_ns_and_weights[ip];
95 auto const& N = n_and_weight.N;
96 auto const& w = n_and_weight.weight;
97
98 double current_variable_int_pt = 0.0;
99 double other_variable_int_pt = 0.0;
100
101 NumLib::shapeFunctionInterpolate(local_current_variable, N,
102 current_variable_int_pt);
103 NumLib::shapeFunctionInterpolate(local_other_variable, N,
104 other_variable_int_pt);
105 NodalVectorType const neumann_node_values =
106 constant_node_values +
107 coefficient_current_variable_node_values *
108 current_variable_int_pt +
109 coefficient_other_variable_node_values * other_variable_int_pt +
110 coefficient_mixed_variables_node_values *
111 current_variable_int_pt * other_variable_int_pt;
112 _local_rhs.noalias() += N * neumann_node_values.dot(N) * w;
113 }
114
115 b.add(indices_current_variable, _local_rhs);
116 }
117
118private:
120 std::size_t const _local_matrix_size;
121};
122
123} // namespace ProcessLib
MathLib::EigenMatrix GlobalMatrix
MathLib::EigenVector GlobalVector
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
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
VariableDependentNeumannBoundaryConditionLocalAssembler(MeshLib::Element const &e, std::size_t const local_matrix_size, NumLib::GenericIntegrationMethod const &integration_method, bool const is_axially_symmetric, VariableDependentNeumannBoundaryConditionData const &data)
GenericNaturalBoundaryConditionLocalAssembler< ShapeFunction, GlobalDim > Base
void shapeFunctionInterpolate(const NodalValues &, const ShapeMatrix &)
std::vector< GlobalIndexType > getIndices(std::size_t const mesh_item_id, NumLib::LocalToGlobalIndexMap const &dof_table)