OGS
RobinBoundaryConditionLocalAssembler.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
10
11namespace ProcessLib
12{
19
20template <typename ShapeFunction, int GlobalDim>
23 GlobalDim>
24{
25 using Base =
28
29public:
31 MeshLib::Element const& e,
32 std::size_t const local_matrix_size,
33 NumLib::GenericIntegrationMethod const& integration_method,
34 bool is_axially_symmetric,
36 : Base(e, is_axially_symmetric, integration_method),
37 _data(data),
38 _local_K(local_matrix_size, local_matrix_size),
39 _local_rhs(local_matrix_size)
40 {
41 }
42
43 void assemble(std::size_t const id,
44 NumLib::LocalToGlobalIndexMap const& dof_table_boundary,
45 double const t, std::vector<GlobalVector*> const& xs,
46 int const process_id, GlobalMatrix* K, GlobalVector& b,
47 GlobalMatrix* Jac) override
48 {
49 _local_K.setZero();
50 _local_rhs.setZero();
51
52 auto& x = *xs[process_id];
53
54 auto const indices = NumLib::getIndices(id, dof_table_boundary);
55 auto const local_x = x.get(indices);
56 auto const u =
58 local_x, ShapeFunction::NPOINTS);
59
60 unsigned const n_integration_points =
61 Base::_integration_method.getNumberOfPoints();
62
63 typename Base::NodalVectorType const alpha =
64 _data.alpha.getNodalValuesOnElement(Base::_element, t)
65 .template topRows<ShapeFunction::MeshElement::n_all_nodes>();
66 typename Base::NodalVectorType const u_0 =
67 _data.u_0.getNodalValuesOnElement(Base::_element, t)
68 .template topRows<ShapeFunction::MeshElement::n_all_nodes>();
69
70 for (unsigned ip = 0; ip < n_integration_points; ++ip)
71 {
72 auto const& ip_data = Base::_ns_and_weights[ip];
73 auto const& N = ip_data.N;
74 auto const& w = ip_data.weight;
75
76 ParameterLib::SpatialPosition const position{
77 std::nullopt, Base::_element.getID(),
81 Base::_element, N))};
82
83 double integral_measure = 1.0;
84 if (_data.integral_measure)
85 {
86 integral_measure = (*_data.integral_measure)(t, position)[0];
87 }
88
89 double const a = alpha.dot(N) * w * integral_measure;
90
91 // The local K matrix is used for both, the Newton and Picard
92 // methods.
93 _local_K.noalias() += N.transpose() * N * a;
94
95 if (Jac != nullptr)
96 {
97 _local_rhs.noalias() -= N.transpose() * (u - u_0).dot(N) * a;
98 }
99 else
100 {
101 _local_rhs.noalias() += N.transpose() * (u_0.dot(N) * a);
102 }
103 }
104
105 b.add(indices, _local_rhs);
106 if (Jac != nullptr)
107 {
109 indices),
110 _local_K);
111 }
112 else if (K != nullptr)
113 {
115 indices),
116 _local_K);
117 }
118 else
119 {
120 OGS_FATAL(
121 "In Robin boundary condition assembler, both, the Jacobian and "
122 "the K-matrices are null, but one matrix must be provided.");
123 }
124 }
125
126private:
128
131
132public:
134};
135
136} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:19
MathLib::EigenMatrix GlobalMatrix
MathLib::EigenVector GlobalVector
EigenFixedShapeMatrixPolicy< ShapeFunction, GlobalDim > ShapeMatrixPolicyType
int add(IndexType row, IndexType col, double val)
Definition EigenMatrix.h:80
void add(IndexType rowId, double v)
add entry
Definition EigenVector.h:70
MathLib::RowColumnIndices< GlobalIndexType > RowColumnIndices
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
ShapeMatrixPolicyType< ShapeFunction, GlobalDim > ShapeMatricesType
GenericNaturalBoundaryConditionLocalAssembler< ShapeFunction, GlobalDim > Base
RobinBoundaryConditionLocalAssembler(MeshLib::Element const &e, std::size_t const local_matrix_size, NumLib::GenericIntegrationMethod const &integration_method, bool is_axially_symmetric, RobinBoundaryConditionData const &data)
void assemble(std::size_t const id, NumLib::LocalToGlobalIndexMap const &dof_table_boundary, double const t, std::vector< GlobalVector * > const &xs, int const process_id, GlobalMatrix *K, GlobalVector &b, GlobalMatrix *Jac) override
Eigen::Map< const Vector > toVector(std::vector< double > const &data, Eigen::VectorXd::Index size)
Creates an Eigen mapped vector from the given data vector.
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)
ParameterLib::Parameter< double > const *const integral_measure
ParameterLib::Parameter< double > const & alpha
ParameterLib::Parameter< double > const & u_0