Chi-Tech
LagrangeTetMapping.cc
Go to the documentation of this file.
2
3#include "mesh/Cell/cell.h"
4
6
8{
9
11 const chi_mesh::Cell& cell,
12 const Quadrature& volume_quadrature,
13 const Quadrature& surface_quadrature)
15 cell,
16 4,
17 MakeFaceNodeMapping(cell),
18 volume_quadrature,
19 surface_quadrature)
20{
21}
22
23double LagrangeTetMapping::RefShape(uint32_t i, const Vec3& qpoint) const
24{
25 const double x = qpoint.x;
26 const double y = qpoint.y;
27 const double z = qpoint.z;
28
29 // clang-format off
30 if (i == 0) return 1.0 - x - y - z;
31 if (i == 1) return x;
32 if (i == 2) return y;
33 if (i == 3) return z;
34 // clang-format on
35
36 ChiLogicalError("Invalid shapefunction index " + std::to_string(i));
37}
38
40 const Vec3& qpoint) const
41{
42 // clang-format off
43 if (i == 0) return Vec3( -1.0, -1.0, -1.0);
44 if (i == 1) return Vec3( 1.0, 0.0, 0.0);
45 if (i == 2) return Vec3( 0.0, 1.0, 0.0);
46 if (i == 3) return Vec3( 0.0, 0.0, 1.0);
47 // clang-format on
48
49 ChiLogicalError("Invalid shapefunction index " + std::to_string(i));
50}
51
54{
55 MatDbl J(3, VecDbl(3, 0.0));
56 for (size_t i = 0; i < num_nodes_; ++i)
57 {
58 const Vec3 grad_shape_i = RefGradShape(i, qpoint);
59 const auto& node_i = node_locations_[i];
60 const double x_i = node_i.x;
61 const double y_i = node_i.y;
62 const double z_i = node_i.z;
63
64 // Loops unrolled for performance
65 J[0][0] += grad_shape_i.x * x_i;
66 J[0][1] += grad_shape_i.y * x_i;
67 J[0][2] += grad_shape_i.z * x_i;
68
69 J[1][0] += grad_shape_i.x * y_i;
70 J[1][1] += grad_shape_i.y * y_i;
71 J[1][2] += grad_shape_i.z * y_i;
72
73 J[2][0] += grad_shape_i.x * z_i;
74 J[2][1] += grad_shape_i.y * z_i;
75 J[2][2] += grad_shape_i.z * z_i;
76 }
77
78 return J;
79}
80
81std::pair<double, LagrangeBaseMapping::Vec3>
83 size_t face_index, const Vec3& qpoint_face) const
84{
85 const auto& x0 = node_locations_[face_node_mappings_[face_index][0]];
86 const auto& x1 = node_locations_[face_node_mappings_[face_index][1]];
87 const auto& x2 = node_locations_[face_node_mappings_[face_index][2]];
88
89 Vec3 dx_dxbar;
90 Vec3 dx_dybar;
91 for (size_t i = 0; i < 3; ++i)
92 {
93 double dN_dxbar = 0.0, dN_dybar = 0.0;
94 Vec3 xi;
95 // clang-format off
96 if (i == 0) {dN_dxbar = -1.0; dN_dybar=-1.0; xi = x0;}
97 if (i == 1) {dN_dxbar = 1.0; dN_dybar= 0.0; xi = x1;}
98 if (i == 2) {dN_dxbar = 0.0; dN_dybar= 1.0; xi = x2;}
99 // clang-format on
100
101 dx_dxbar += dN_dxbar * xi;
102 dx_dybar += dN_dybar * xi;
103 }
104
105 const auto cross = dx_dxbar.Cross(dx_dybar);
106 const double detJ = cross.Norm();
107
108 return {detJ, cross/detJ};
109}
110
113 const Vec3& qpoint_face) const
114{
115 const double x = qpoint_face.x;
116 const double y = qpoint_face.y;
117
118 // clang-format off
119 if (face_index == 0/*Base*/) return Vec3(x, y, 0);
120 if (face_index == 1/*XZ*/) return Vec3(x, 0, y);
121 if (face_index == 2/*YZ*/) return Vec3(0, x, y);
122 if (face_index == 3/*Slanted*/) return Vec3(x, y, 1.0 - x - y);
123 // clang-format on
124
125 ChiLogicalError("Invalid face index " + std::to_string(face_index));
126}
127
128} // namespace chi_math::cell_mapping
#define ChiLogicalError(message)
const std::vector< std::vector< int > > face_node_mappings_
Definition: CellMapping.h:130
const std::vector< chi_mesh::Vector3 > node_locations_
Definition: CellMapping.h:121
const size_t num_nodes_
Definition: CellMapping.h:120
Vec3 FaceToElementQPointConversion(size_t face_index, const Vec3 &qpoint_face) const override
std::pair< double, Vec3 > RefFaceJacobianDeterminantAndNormal(size_t face_index, const Vec3 &qpoint_face) const override
LagrangeTetMapping(const chi_mesh::MeshContinuum &grid, const chi_mesh::Cell &cell, const Quadrature &volume_quadrature, const Quadrature &surface_quadrature)
Vec3 RefGradShape(uint32_t i, const Vec3 &qpoint) const override
MatDbl RefJacobian(const Vec3 &qpoint) const override
double RefShape(uint32_t i, const Vec3 &qpoint) const override
double x
Element-0.
Vector3 Cross(const Vector3 &that) const
double y
Element-1.
double z
Element-2.
double Norm() const