OGS
NormalTractionBoundaryConditionLocalAssembler.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{
15{
16template <typename ShapeMatricesType>
18{
20 typename ShapeMatricesType::ShapeMatrices::ShapeType const N_,
21 typename ShapeMatricesType::GlobalDimVectorType const n_,
22 double const integration_weight_)
23 : N(N_), n(n_), integration_weight(integration_weight_)
24 {
25 }
26
27 typename ShapeMatricesType::ShapeMatrices::ShapeType const N;
28 typename ShapeMatricesType::GlobalDimVectorType const n;
29 double const integration_weight;
30};
31
33{
34public:
35 virtual void assemble(
36 std::size_t const id,
37 NumLib::LocalToGlobalIndexMap const& dof_table_boundary, double const t,
38 std::vector<GlobalVector*> const& /*x*/, GlobalMatrix* /*K*/,
39 GlobalVector& b, GlobalMatrix* /*Jac*/) = 0;
41};
42
43template <typename ShapeFunctionDisplacement, int GlobalDim>
46{
47public:
52
54 MeshLib::Element const& e,
55 std::size_t const local_matrix_size,
56 NumLib::GenericIntegrationMethod const& integration_method,
57 bool const is_axially_symmetric,
58 ParameterLib::Parameter<double> const& pressure,
59 std::vector<Eigen::Vector3d> const& element_normals)
60 : _integration_method(integration_method),
61 _pressure(pressure),
62 _element(e)
63 {
64 _local_rhs.setZero(local_matrix_size);
65
66 unsigned const n_integration_points =
67 _integration_method.getNumberOfPoints();
68
69 _ip_data.reserve(n_integration_points);
70
71 auto const shape_matrices_u =
72 NumLib::initShapeMatrices<ShapeFunctionDisplacement,
73 ShapeMatricesType, GlobalDim>(
74 e, is_axially_symmetric, _integration_method);
75
76 for (unsigned ip = 0; ip < n_integration_points; ip++)
77 {
78 double const integration_weight =
79 _integration_method.getWeightedPoint(ip).getWeight() *
80 shape_matrices_u[ip].integralMeasure *
81 shape_matrices_u[ip].detJ;
82
83 _ip_data.emplace_back(shape_matrices_u[ip].N,
84 element_normals[e.getID()].head<GlobalDim>(),
85 integration_weight);
86 }
87 }
88
89 void assemble(std::size_t const id,
90 NumLib::LocalToGlobalIndexMap const& dof_table_boundary,
91 double const t, std::vector<GlobalVector*> const& /*x*/,
92 GlobalMatrix* /*K*/, GlobalVector& local_rhs,
93 GlobalMatrix* /*Jac*/) override
94 {
95 _local_rhs.setZero();
96
97 unsigned const n_integration_points =
98 _integration_method.getNumberOfPoints();
99
100 NodalVectorType pressure =
101 _pressure.getNodalValuesOnElement(_element, t);
102
103 for (unsigned ip = 0; ip < n_integration_points; ip++)
104 {
105 auto const& w = _ip_data[ip].integration_weight;
106 auto const& N = _ip_data[ip].N;
107 auto const& n = _ip_data[ip].n;
108
109 typename ShapeMatricesType::template MatrixType<GlobalDim,
111 N_u = ShapeMatricesType::template MatrixType<
112 GlobalDim, displacement_size>::Zero(GlobalDim,
114 for (int i = 0; i < GlobalDim; ++i)
115 {
116 N_u.template block<1, displacement_size / GlobalDim>(
117 i, i * displacement_size / GlobalDim)
118 .noalias() = N;
119 }
120
121 _local_rhs.noalias() -= n.transpose() * N_u * pressure.dot(N) * w;
122 }
123
124 auto const indices = NumLib::getIndices(id, dof_table_boundary);
125 local_rhs.add(indices, _local_rhs);
126 }
127
128private:
131
132 static const int displacement_size =
133 ShapeFunctionDisplacement::NPOINTS * GlobalDim;
134 std::vector<
136 Eigen::aligned_allocator<IntegrationPointData<ShapeMatricesType>>>
138
139 typename ShapeMatricesType::template VectorType<displacement_size>
141
143
144public:
146};
147
148} // namespace NormalTractionBoundaryCondition
149} // namespace ProcessLib
MathLib::EigenMatrix GlobalMatrix
MathLib::EigenVector GlobalVector
EigenFixedShapeMatrixPolicy< ShapeFunction, GlobalDim > ShapeMatrixPolicyType
void add(IndexType rowId, double v)
add entry
Definition EigenVector.h:70
std::size_t getID() const
Returns the ID of the element.
Definition Element.h:80
virtual void assemble(std::size_t const id, NumLib::LocalToGlobalIndexMap const &dof_table_boundary, double const t, std::vector< GlobalVector * > const &, GlobalMatrix *, GlobalVector &b, GlobalMatrix *)=0
NormalTractionBoundaryConditionLocalAssembler(MeshLib::Element const &e, std::size_t const local_matrix_size, NumLib::GenericIntegrationMethod const &integration_method, bool const is_axially_symmetric, ParameterLib::Parameter< double > const &pressure, std::vector< Eigen::Vector3d > const &element_normals)
void assemble(std::size_t const id, NumLib::LocalToGlobalIndexMap const &dof_table_boundary, double const t, std::vector< GlobalVector * > const &, GlobalMatrix *, GlobalVector &local_rhs, GlobalMatrix *) override
std::vector< IntegrationPointData< ShapeMatricesType >, Eigen::aligned_allocator< IntegrationPointData< ShapeMatricesType > > > _ip_data
std::vector< GlobalIndexType > getIndices(std::size_t const mesh_item_id, NumLib::LocalToGlobalIndexMap const &dof_table)
std::vector< typename ShapeMatricesType::ShapeMatrices, Eigen::aligned_allocator< typename ShapeMatricesType::ShapeMatrices > > initShapeMatrices(MeshLib::Element const &e, bool const is_axially_symmetric, IntegrationMethod const &integration_method)
VectorType< GlobalDim > GlobalDimVectorType
VectorType< ShapeFunction::NPOINTS > NodalVectorType
IntegrationPointData(typename ShapeMatricesType::ShapeMatrices::ShapeType const N_, typename ShapeMatricesType::GlobalDimVectorType const n_, double const integration_weight_)