OGS
NormalTractionBoundaryConditionLocalAssembler.h
Go to the documentation of this file.
1
11#pragma once
12
18
19namespace ProcessLib
20{
21namespace NormalTractionBoundaryCondition
22{
23template <typename ShapeMatricesType>
25{
27 typename ShapeMatricesType::ShapeMatrices::ShapeType const N_,
28 typename ShapeMatricesType::GlobalDimVectorType const n_,
29 double const integration_weight_)
30 : N(N_), n(n_), integration_weight(integration_weight_)
31 {
32 }
33
34 typename ShapeMatricesType::ShapeMatrices::ShapeType const N;
35 typename ShapeMatricesType::GlobalDimVectorType const n;
36 double const integration_weight;
37};
38
40{
41public:
42 virtual void assemble(
43 std::size_t const id,
44 NumLib::LocalToGlobalIndexMap const& dof_table_boundary, double const t,
45 std::vector<GlobalVector*> const& /*x*/, GlobalMatrix& /*K*/,
46 GlobalVector& b, GlobalMatrix* /*Jac*/) = 0;
48};
49
50template <typename ShapeFunctionDisplacement, typename IntegrationMethod,
51 int GlobalDim>
54{
55public:
60
62 MeshLib::Element const& e,
63 std::size_t const local_matrix_size,
64 bool const is_axially_symmetric,
65 unsigned const integration_order,
66 ParameterLib::Parameter<double> const& pressure)
67 : _integration_method(integration_order),
68 _pressure(pressure),
69 _element(e)
70 {
71 _local_rhs.setZero(local_matrix_size);
72
73 unsigned const n_integration_points =
74 _integration_method.getNumberOfPoints();
75
76 _ip_data.reserve(n_integration_points);
77
78 auto const shape_matrices_u =
79 NumLib::initShapeMatrices<ShapeFunctionDisplacement,
80 ShapeMatricesType, GlobalDim>(
81 e, is_axially_symmetric, _integration_method);
82
83 GlobalDimVectorType element_normal(GlobalDim);
84
85 // TODO Extend to rotated 2d meshes and line elements.
87 {
88 Eigen::Vector3d const v1 = e.getNode(1)->asEigenVector3d() -
90 element_normal[0] = -v1[1];
91 element_normal[1] = v1[0];
92 element_normal.normalize();
93 }
94 else
95 {
96 auto const n = MeshLib::FaceRule::getSurfaceNormal(e).normalized();
97 for (int i = 0; i < GlobalDim; ++i)
98 {
99 element_normal[i] = n[i];
100 }
101 }
102
103 for (unsigned ip = 0; ip < n_integration_points; ip++)
104 {
105 double const integration_weight =
106 _integration_method.getWeightedPoint(ip).getWeight() *
107 shape_matrices_u[ip].integralMeasure *
108 shape_matrices_u[ip].detJ;
109
110 _ip_data.emplace_back(shape_matrices_u[ip].N, element_normal,
111 integration_weight);
112 }
113 }
114
115 void assemble(std::size_t const id,
116 NumLib::LocalToGlobalIndexMap const& dof_table_boundary,
117 double const t, std::vector<GlobalVector*> const& /*x*/,
118 GlobalMatrix& /*K*/, GlobalVector& local_rhs,
119 GlobalMatrix* /*Jac*/) override
120 {
121 _local_rhs.setZero();
122
123 unsigned const n_integration_points =
124 _integration_method.getNumberOfPoints();
125
126 NodalVectorType pressure =
128
129 for (unsigned ip = 0; ip < n_integration_points; ip++)
130 {
131 auto const& w = _ip_data[ip].integration_weight;
132 auto const& N = _ip_data[ip].N;
133 auto const& n = _ip_data[ip].n;
134
135 typename ShapeMatricesType::template MatrixType<GlobalDim,
137 N_u = ShapeMatricesType::template MatrixType<
138 GlobalDim, displacement_size>::Zero(GlobalDim,
140 for (int i = 0; i < GlobalDim; ++i)
141 {
142 N_u.template block<1, displacement_size / GlobalDim>(
143 i, i * displacement_size / GlobalDim)
144 .noalias() = N;
145 }
146
147 _local_rhs.noalias() -= n.transpose() * N_u * pressure.dot(N) * w;
148 }
149
150 auto const indices = NumLib::getIndices(id, dof_table_boundary);
151 local_rhs.add(indices, _local_rhs);
152 }
153
154private:
155 IntegrationMethod const _integration_method;
157
158 static const int displacement_size =
159 ShapeFunctionDisplacement::NPOINTS * GlobalDim;
160 std::vector<
162 Eigen::aligned_allocator<IntegrationPointData<ShapeMatricesType>>>
164
165 typename ShapeMatricesType::template VectorType<displacement_size>
167
169
170public:
172};
173
174} // namespace NormalTractionBoundaryCondition
175} // namespace ProcessLib
Global vector based on Eigen vector.
Definition: EigenVector.h:28
void add(IndexType rowId, double v)
add entry
Definition: EigenVector.h:79
Eigen::Vector3d const & asEigenVector3d() const
Definition: Point3d.h:67
virtual MeshElemType getGeomType() const =0
virtual const Node * getNode(unsigned idx) const =0
static Eigen::Vector3d getSurfaceNormal(Element const &e)
Returns the surface normal of a 2D element.
Definition: FaceRule.cpp:38
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
std::vector< IntegrationPointData< ShapeMatricesType >, Eigen::aligned_allocator< IntegrationPointData< ShapeMatricesType > > > _ip_data
NormalTractionBoundaryConditionLocalAssembler(MeshLib::Element const &e, std::size_t const local_matrix_size, bool const is_axially_symmetric, unsigned const integration_order, ParameterLib::Parameter< double > const &pressure)
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
static const double t
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
virtual Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > getNodalValuesOnElement(MeshLib::Element const &element, double const t) const
Returns a matrix of values for all nodes of the given element.
Definition: Parameter.h:163
IntegrationPointData(typename ShapeMatricesType::ShapeMatrices::ShapeType const N_, typename ShapeMatricesType::GlobalDimVectorType const n_, double const integration_weight_)