IPPL (Independent Parallel Particle Layer)
IPPL
Loading...
Searching...
No Matches
HexahedralElement.hpp
Go to the documentation of this file.
1namespace ippl {
2 template <typename T>
3 KOKKOS_FUNCTION typename HexahedralElement<T>::vertex_points_t
5 // For the ordering of local vertices, see section 3.3.1:
6 // https://amas.web.psi.ch/people/aadelmann/ETH-Accel-Lecture-1/projectscompleted/phys/bachelor_thesis_buehlluk.pdf
8 {0.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, {1.0, 1.0, 0.0}, {0.0, 1.0, 0.0},
9 {0.0, 0.0, 1.0}, {1.0, 0.0, 1.0}, {1.0, 1.0, 1.0}, {0.0, 1.0, 1.0}};
10
11 return vertices;
12 }
13
14 template <typename T>
15 KOKKOS_FUNCTION typename HexahedralElement<T>::point_t
17 const HexahedralElement<T>::vertex_points_t& global_vertices) const {
19
20 jacobian[0] = (global_vertices[1][0] - global_vertices[0][0]);
21 jacobian[1] = (global_vertices[2][1] - global_vertices[0][1]);
22 jacobian[2] = (global_vertices[4][2] - global_vertices[0][2]);
23
24 return jacobian;
25 }
26
27 template <typename T>
28 KOKKOS_FUNCTION typename HexahedralElement<T>::point_t
30 const HexahedralElement<T>::vertex_points_t& global_vertices) const {
31 HexahedralElement::point_t inv_jacobian;
32
33 inv_jacobian[0] = 1.0 / (global_vertices[1][0] - global_vertices[0][0]);
34 inv_jacobian[1] = 1.0 / (global_vertices[2][1] - global_vertices[0][1]);
35 inv_jacobian[2] = 1.0 / (global_vertices[4][2] - global_vertices[0][2]);
36
37 return inv_jacobian;
38 }
39
40 template <typename T>
42 const HexahedralElement<T>::vertex_points_t& global_vertices,
43 const HexahedralElement<T>::point_t& global_point) const {
44 // This is actually not a matrix, but an IPPL vector that represents a diagonal matrix
45 const HexahedralElement<T>::point_t glob2loc_matrix =
46 getInverseTransformationJacobian(global_vertices);
47
49 glob2loc_matrix * (global_point - global_vertices[0]);
50
51 return local_point;
52 }
53
54 template <typename T>
56 const HexahedralElement<T>::vertex_points_t& global_vertices,
57 const HexahedralElement<T>::point_t& local_point) const {
58 // This is actually not a matrix but an IPPL vector that represents a diagonal matrix
59 const HexahedralElement<T>::point_t loc2glob_matrix =
60 getTransformationJacobian(global_vertices);
61
63 (loc2glob_matrix * local_point) + global_vertices[0];
64
65 return global_point;
66 }
67
68 template <typename T>
70 const HexahedralElement<T>::vertex_points_t& global_vertices) const {
71 T determinant = 1.0;
72
73 // Since the jacobian is a diagonal matrix in our case the determinant is the product of the
74 // diagonal elements
75 for (const T& jacobian_val : getTransformationJacobian(global_vertices)) {
76 determinant *= jacobian_val;
77 }
78
79 return determinant;
80 }
81
82 template <typename T>
83 KOKKOS_FUNCTION typename HexahedralElement<T>::point_t
85 const HexahedralElement<T>::vertex_points_t& global_vertices) const {
86 // Simply return the inverse transformation jacobian since it is a diagonal matrix
87 return getInverseTransformationJacobian(global_vertices);
88 }
89
90 template <typename T>
92 const Vector<T, 3>& point) const {
93 // check if the local coordinates are inside the reference element
94
95 for (size_t d = 0; d < 3; d++) {
96 if (point[d] > 1.0 || point[d] < 0.0) {
97 // The global coordinates are outside of the support.
98 return false;
99 }
100 }
101
102 return true;
103 }
104
105} // namespace ippl
Definition Archive.h:20
Element3D< T, NumVertices >::vertex_points_t vertex_points_t
KOKKOS_FUNCTION point_t getTransformationJacobian(const vertex_points_t &global_vertices) const
Returns the Jacobian of the transformation matrix.
Element3D< T, NumVertices >::point_t point_t
KOKKOS_FUNCTION point_t getInverseTransposeTransformationJacobian(const vertex_points_t &global_vertices) const
Returns the inverse of the transpose of the transformation Jacobian.
KOKKOS_FUNCTION vertex_points_t getLocalVertices() const
Returns the coordinates of the vertices of the reference element.
KOKKOS_FUNCTION T getDeterminantOfTransformationJacobian(const vertex_points_t &global_vertices) const
Returns the determinant of the transformation Jacobian.
KOKKOS_FUNCTION bool isPointInRefElement(const Vector< T, 3 > &point) const
Returns whether a point in local coordinates ([0, 1]^3) is inside the reference element.
KOKKOS_FUNCTION point_t globalToLocal(const vertex_points_t &, const point_t &) const
Transforms a point from global to local coordinates.
KOKKOS_FUNCTION point_t getInverseTransformationJacobian(const vertex_points_t &global_vertices) const
Returns the inverse of the Jacobian of the transformation matrix.
KOKKOS_FUNCTION point_t localToGlobal(const vertex_points_t &global_vertices, const point_t &point) const
Transforms a point from local to global coordinates.