Chi-Tech
LagrangeBaseMapping.h
Go to the documentation of this file.
1#ifndef CHITECH_LAGRANGEBASEMAPPING_H
2#define CHITECH_LAGRANGEBASEMAPPING_H
3
4#include "CellMapping.h"
6
7#include "mesh/chi_mesh.h"
8
9namespace chi_math
10{
11class Quadrature;
12}
13
15{
16
17/**Base class for finite elements using Lagrange basis functions.
18 *\ingroup doc_CellMappings*/
20{
21public:
22 double ShapeValue(int i, const chi_mesh::Vector3& xyz) const override;
23 void ShapeValues(const chi_mesh::Vector3& xyz,
24 std::vector<double>& shape_values) const override;
26 const chi_mesh::Vector3& xyz) const override;
27 void GradShapeValues(
28 const chi_mesh::Vector3& xyz,
29 std::vector<chi_mesh::Vector3>& gradshape_values) const override;
30
32 MakeVolumetricQuadraturePointData() const override;
33
35 MakeSurfaceQuadraturePointData(size_t face_index) const override;
36
37protected:
40 typedef std::vector<double> VecDbl;
41 typedef std::vector<VecDbl> MatDbl;
42
44 const chi_mesh::Cell& cell,
45 size_t num_nodes,
46 std::vector<std::vector<int>> face_node_mappings,
47 const Quadrature& volume_quadrature,
48 const Quadrature& surface_quadrature);
49
50 /**Function using newton iteration to convert a world_xyz coordinate to
51 * a quadrature point coordinate.*/
52 Vec3 MapWorldXYZToNaturalXYZ(const Vec3& world_xyz) const;
53
54 /**Used in the constructor this method simply collects the cell vertices.*/
55 static std::vector<chi_mesh::Vector3>
57 const chi_mesh::Cell& cell);
58
59 /**Used in the constructor this method maps face node ids to cell ids.*/
60 static std::vector<std::vector<int>>
62
63 /**Reference element shape function evaluation. Meant to be overridden by
64 * a specific element mapping.*/
65 virtual double RefShape(uint32_t i, const Vec3& qpoint) const = 0;
66
67 /**Reference element shape function gradient evaluation. Meant to be
68 * overridden by a specific element mapping.*/
69 virtual Vec3 RefGradShape(uint32_t i, const Vec3& qpoint) const = 0;
70
71 /**Reference element Jacobian evaluation. Meant to be overridden by
72 * a specific element mapping.*/
73 virtual MatDbl RefJacobian(const Vec3& qpoint) const = 0;
74
75 /**Computes the determinant of the surface Jacobian and the surface normal
76 * at the face quadrature point.*/
77 virtual std::pair<double, Vec3>
79 const Vec3& qpoint_face) const;
80
81 /**Converts a face quadrature point to a reference element position allowing
82 * the reuse of the reference element shape functions. Meant to be overridden
83 * by a specific element mapping.*/
84 virtual Vec3 FaceToElementQPointConversion(size_t face_index,
85 const Vec3& qpoint_face) const = 0;
86
87 /**Overrideable method to return the appropriate face quadrature. Default
88 * returns surface_quadrature. Some mappings might change quadrature based
89 * on the face index.*/
90 virtual const Quadrature& GetSurfaceQuadrature(size_t face_index) const;
91
94};
95
96/**Helper class to apply Newton's method to map world coordinates to
97 * reference element coordinates.*/
99{
100public:
103 const LagrangeBaseMapping& cell_mapping, const Vec3& world_x);
104
105 VecDbl F(const VecDbl& x) const override;
106 MatDbl J(const VecDbl& x) const override;
107
108private:
112};
113
114} // namespace chi_math::cell_mapping
115
116#endif // CHITECH_LAGRANGEBASEMAPPING_H
std::vector< VecDbl > MatDbl
Definition: chi_math.h:13
std::vector< double > VecDbl
Definition: chi_math.h:12
virtual Vec3 RefGradShape(uint32_t i, const Vec3 &qpoint) const =0
static std::vector< chi_mesh::Vector3 > GetVertexLocations(const chi_mesh::MeshContinuum &grid, const chi_mesh::Cell &cell)
virtual double RefShape(uint32_t i, const Vec3 &qpoint) const =0
void GradShapeValues(const chi_mesh::Vector3 &xyz, std::vector< chi_mesh::Vector3 > &gradshape_values) const override
LagrangeBaseMapping(const chi_mesh::MeshContinuum &grid, const chi_mesh::Cell &cell, size_t num_nodes, std::vector< std::vector< int > > face_node_mappings, const Quadrature &volume_quadrature, const Quadrature &surface_quadrature)
finite_element::SurfaceQuadraturePointData MakeSurfaceQuadraturePointData(size_t face_index) const override
virtual const Quadrature & GetSurfaceQuadrature(size_t face_index) const
virtual std::pair< double, Vec3 > RefFaceJacobianDeterminantAndNormal(size_t face_index, const Vec3 &qpoint_face) const
static std::vector< std::vector< int > > MakeFaceNodeMapping(const chi_mesh::Cell &cell)
finite_element::VolumetricQuadraturePointData MakeVolumetricQuadraturePointData() const override
virtual MatDbl RefJacobian(const Vec3 &qpoint) const =0
void ShapeValues(const chi_mesh::Vector3 &xyz, std::vector< double > &shape_values) const override
double ShapeValue(int i, const chi_mesh::Vector3 &xyz) const override
chi_mesh::Vector3 GradShapeValue(int i, const chi_mesh::Vector3 &xyz) const override
virtual Vec3 FaceToElementQPointConversion(size_t face_index, const Vec3 &qpoint_face) const =0
Vec3 MapWorldXYZToNaturalXYZ(const Vec3 &world_xyz) const
WorldXYZToNaturalMappingHelper(const LagrangeBaseMapping &cell_mapping, const Vec3 &world_x)