Loading [MathJax]/extensions/tex2jax.js
OGS
InitShapeMatrices.h
Go to the documentation of this file.
1
10#pragma once
11
12#include <Eigen/Core>
13#include <vector>
14
18
19namespace NumLib
20{
21template <typename ShapeFunction, typename ShapeMatricesType, int GlobalDim,
22 ShapeMatrixType SelectedShapeMatrixType = ShapeMatrixType::ALL,
23 typename PointContainer>
24std::vector<typename ShapeMatricesType::ShapeMatrices,
25 Eigen::aligned_allocator<typename ShapeMatricesType::ShapeMatrices>>
26computeShapeMatrices(MeshLib::Element const& e, bool const is_axially_symmetric,
27 PointContainer const& points)
28{
29 std::vector<
30 typename ShapeMatricesType::ShapeMatrices,
31 Eigen::aligned_allocator<typename ShapeMatricesType::ShapeMatrices>>
32 shape_matrices;
33
34 auto const fe =
36
37 shape_matrices.reserve(points.size());
38 for (auto const& p : points)
39 {
40 shape_matrices.emplace_back(ShapeFunction::DIM, GlobalDim,
41 ShapeFunction::NPOINTS);
42 fe.template computeShapeFunctions<SelectedShapeMatrixType>(
43 p.data(), shape_matrices.back(), GlobalDim, is_axially_symmetric);
44 }
45
46 return shape_matrices;
47}
48
49template <typename ShapeFunction, typename ShapeMatricesType, int GlobalDim,
50 ShapeMatrixType SelectedShapeMatrixType = ShapeMatrixType::ALL,
51 typename IntegrationMethod>
52std::vector<typename ShapeMatricesType::ShapeMatrices,
53 Eigen::aligned_allocator<typename ShapeMatricesType::ShapeMatrices>>
54initShapeMatrices(MeshLib::Element const& e, bool const is_axially_symmetric,
55 IntegrationMethod const& integration_method)
56{
57 int const n_integration_points = integration_method.getNumberOfPoints();
58
59 std::vector<MathLib::WeightedPoint> points;
60 points.reserve(n_integration_points);
61 for (int ip = 0; ip < n_integration_points; ++ip)
62 {
63 points.push_back(integration_method.getWeightedPoint(ip));
64 }
65
66 return computeShapeMatrices<ShapeFunction, ShapeMatricesType, GlobalDim,
67 SelectedShapeMatrixType>(
68 e, is_axially_symmetric, points);
69}
70
71// Returned vector only contains one element.
72template <typename ShapeFunction, typename ShapeMatricesType, int GlobalDim,
73 ShapeMatrixType SelectedShapeMatrixType = ShapeMatrixType::ALL>
74typename ShapeMatricesType::ShapeMatrices initShapeMatricesAtElementCenter(
75 MeshLib::Element const& e, bool const is_axially_symmetric)
76{
77 static constexpr std::array<double, ShapeFunction::DIM> centre =
78 ShapeFunction::reference_element_centre;
79
80 static constexpr std::array integration_points = {
81 MathLib::WeightedPoint{centre, 1.0}};
82
83 auto const shape_matrices =
84 computeShapeMatrices<ShapeFunction, ShapeMatricesType, GlobalDim,
85 SelectedShapeMatrixType>(e, is_axially_symmetric,
86 integration_points);
87 return shape_matrices[0];
88}
89
90template <typename ShapeFunction, typename ShapeMatricesType>
92 MeshLib::Element const& e,
93 typename ShapeMatricesType::ShapeMatrices::ShapeType const& N)
94{
95 auto const fe =
97
98 return fe.interpolateZerothCoordinate(N);
99}
100
101template <typename ShapeFunction, typename ShapeMatricesType>
102std::array<double, 3> interpolateCoordinates(
103 MeshLib::Element const& e,
104 typename ShapeMatricesType::ShapeMatrices::ShapeType const& N)
105{
106 auto const fe =
108
109 return fe.interpolateCoordinates(N);
110}
111
112} // namespace NumLib
Definition of the Element class.
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.
@ ALL
calculates all
std::array< double, 3 > interpolateCoordinates(MeshLib::Element const &e, typename ShapeMatricesType::ShapeMatrices::ShapeType const &N)
NumLib::TemplateIsoparametric< ShapeFunction, ShapeMatricesType > createIsoparametricFiniteElement(MeshLib::Element const &e)