Chi-Tech
pwl_slab_02_x_shapefuncs.cc
Go to the documentation of this file.
3
5{
6
7/**Shape function i evaluated at given point for the slab.*/
8double
10 const chi_mesh::Vector3& xyz) const
11{
12 const auto& p0 = ref_grid_.vertices[v0i_];
13 const auto& p1 = ref_grid_.vertices[v1i_];
14 chi_mesh::Vector3 xyz_ref = xyz - p0;
15
16 chi_mesh::Vector3 v01 = p1 - p0;
17
18 double xi = v01.Dot(xyz_ref) / v01.Norm() / h_;
19
20 if ((xi >= -1.0e-6) and (xi <= 1.0 + 1.0e-6))
21 {
22 if (i == 0) return 1.0 - xi;
23 else
24 return xi;
25 } // if in cell
26
27 return 0.0;
28}
29
30// #################################################################
31/**Populates shape_values with the value of each shape function's
32 * value evaluate at the supplied point.*/
34 std::vector<double>& shape_values) const
35{
36 shape_values.resize(num_nodes_, 0.0);
37 const auto& p0 = ref_grid_.vertices[v0i_];
38 const auto& p1 = ref_grid_.vertices[v1i_];
39 chi_mesh::Vector3 xyz_ref = xyz - p0;
40
41 chi_mesh::Vector3 v01 = p1 - p0;
42
43 double xi = v01.Dot(xyz_ref) / v01.Norm() / h_;
44
45 if ((xi >= -1.0e-6) and (xi <= 1.0 + 1.0e-6))
46 {
47 for (int i = 0; i < num_nodes_; i++)
48 {
49 if (i == 0) shape_values[i] = 1.0 - xi;
50 else
51 shape_values[i] = xi;
52 } // for dof
53
54 return;
55 } // if in cell
56}
57
58// ###################################################################
59/**Returns the evaluation of grad-shape function i at the supplied point.*/
62 const chi_mesh::Vector3& xyz) const
63{
64 if (i == 0) return chi_mesh::Vector3(0.0, 0.0, -1.0 / h_);
65 else
66 return chi_mesh::Vector3(0.0, 0.0, 1.0 / h_);
67}
68
69// ###################################################################
70/**Populates shape_values with the value of each shape function's
71 * value evaluate at the supplied point.*/
73 const chi_mesh::Vector3& xyz,
74 std::vector<chi_mesh::Vector3>& gradshape_values) const
75{
76 gradshape_values.clear();
77 gradshape_values.emplace_back(GradShapeValue(0, xyz));
78 gradshape_values.emplace_back(GradShapeValue(1, xyz));
79}
80
81} // namespace chi_math::cell_mapping
const chi_mesh::MeshContinuum & ref_grid_
Definition: CellMapping.h:117
const size_t num_nodes_
Definition: CellMapping.h:120
double ShapeValue(int i, const chi_mesh::Vector3 &xyz) const override
void GradShapeValues(const chi_mesh::Vector3 &xyz, std::vector< chi_mesh::Vector3 > &gradshape_values) const override
void ShapeValues(const chi_mesh::Vector3 &xyz, std::vector< double > &shape_values) const override
chi_mesh::Vector3 GradShapeValue(int i, const chi_mesh::Vector3 &xyz) const override
VectorN< 3 > Vector3
Vector3 Dot(const chi_mesh::TensorRank2Dim3 &that) const
double Norm() const