OGS
InitShapeMatrices.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 <Eigen/Core>
7#include <vector>
8
12
13namespace NumLib
14{
15template <typename ShapeFunction, typename ShapeMatricesType, int GlobalDim,
16 ShapeMatrixType SelectedShapeMatrixType = ShapeMatrixType::ALL,
17 typename PointContainer>
18std::vector<typename ShapeMatricesType::ShapeMatrices,
19 Eigen::aligned_allocator<typename ShapeMatricesType::ShapeMatrices>>
20computeShapeMatrices(MeshLib::Element const& e, bool const is_axially_symmetric,
21 PointContainer const& points)
22{
23 std::vector<
24 typename ShapeMatricesType::ShapeMatrices,
25 Eigen::aligned_allocator<typename ShapeMatricesType::ShapeMatrices>>
26 shape_matrices;
27
28 auto const fe =
30
31 shape_matrices.reserve(points.size());
32 for (auto const& p : points)
33 {
34 shape_matrices.emplace_back(ShapeFunction::DIM, GlobalDim,
35 ShapeFunction::NPOINTS);
36 fe.template computeShapeFunctions<SelectedShapeMatrixType>(
37 p.data(), shape_matrices.back(), GlobalDim, is_axially_symmetric);
38 }
39
40 return shape_matrices;
41}
42
43template <typename ShapeFunction, typename ShapeMatricesType, int GlobalDim,
44 ShapeMatrixType SelectedShapeMatrixType = ShapeMatrixType::ALL,
45 typename IntegrationMethod>
46std::vector<typename ShapeMatricesType::ShapeMatrices,
47 Eigen::aligned_allocator<typename ShapeMatricesType::ShapeMatrices>>
48initShapeMatrices(MeshLib::Element const& e, bool const is_axially_symmetric,
49 IntegrationMethod const& integration_method)
50{
51 int const n_integration_points = integration_method.getNumberOfPoints();
52
53 std::vector<MathLib::WeightedPoint> points;
54 points.reserve(n_integration_points);
55 for (int ip = 0; ip < n_integration_points; ++ip)
56 {
57 points.push_back(integration_method.getWeightedPoint(ip));
58 }
59
60 return computeShapeMatrices<ShapeFunction, ShapeMatricesType, GlobalDim,
61 SelectedShapeMatrixType>(
62 e, is_axially_symmetric, points);
63}
64
65// Returned vector only contains one element.
66template <typename ShapeFunction, typename ShapeMatricesType, int GlobalDim,
67 ShapeMatrixType SelectedShapeMatrixType = ShapeMatrixType::ALL>
68typename ShapeMatricesType::ShapeMatrices initShapeMatricesAtElementCenter(
69 MeshLib::Element const& e, bool const is_axially_symmetric)
70{
71 static constexpr std::array integration_points = {
72 MathLib::WeightedPoint{ShapeFunction::reference_element_centre, 1.0}};
73
74 auto const shape_matrices =
75 computeShapeMatrices<ShapeFunction, ShapeMatricesType, GlobalDim,
76 SelectedShapeMatrixType>(e, is_axially_symmetric,
77 integration_points);
78 return shape_matrices[0];
79}
80
81template <typename ShapeFunction, typename ShapeMatricesType>
83 MeshLib::Element const& e,
84 typename ShapeMatricesType::ShapeMatrices::ShapeType const& N)
85{
86 auto const fe =
88
89 return fe.interpolateZerothCoordinate(N);
90}
91
92template <typename ShapeFunction, typename ShapeMatricesType>
93std::array<double, 3> interpolateCoordinates(
94 MeshLib::Element const& e,
95 typename ShapeMatricesType::ShapeMatrices::ShapeType const& N)
96{
97 auto const fe =
99
100 return fe.interpolateCoordinates(N);
101}
102
103} // namespace NumLib
double interpolateXCoordinate(MeshLib::Element const &e, typename ShapeMatricesType::ShapeMatrices::ShapeType const &N)
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)
ShapeMatricesType::ShapeMatrices initShapeMatricesAtElementCenter(MeshLib::Element const &e, bool const is_axially_symmetric)
std::vector< typename ShapeMatricesType::ShapeMatrices, Eigen::aligned_allocator< typename ShapeMatricesType::ShapeMatrices > > computeShapeMatrices(MeshLib::Element const &e, bool const is_axially_symmetric, PointContainer const &points)
ShapeMatrixType
Shape matrix type to be calculated.
std::array< double, 3 > interpolateCoordinates(MeshLib::Element const &e, typename ShapeMatricesType::ShapeMatrices::ShapeType const &N)
NumLib::TemplateIsoparametric< ShapeFunction, ShapeMatricesType > createIsoparametricFiniteElement(MeshLib::Element const &e)