Chi-Tech
CellMapping.h
Go to the documentation of this file.
1#ifndef CHITECH_CELLMAPPING_H
2#define CHITECH_CELLMAPPING_H
3
4#include <memory>
5#include <utility>
6#include <vector>
7#include <functional>
8
9// ################################################################### Fwd
10// Decls.
11namespace chi_mesh
12{
13class MeshContinuum;
14struct Vector3;
15class Cell;
16} // namespace chi_mesh
17
19{
22} // namespace chi_math::finite_element
23
24namespace chi_math
25{
26// ################################################################### Class def
27/**Base class for all cell mappings.
28* \ingroup doc_CellMappings*/
30{
31public:
32 // 00
33 /**Returns the cell this mapping is based on.*/
34 const chi_mesh::Cell& ReferenceCell() const;
35
36 /**Returns the grid on which the cell for this mapping lives.*/
38
39 /**Returns the number of nodes on this element.*/
40 size_t NumNodes() const;
41 /**Returns the number of nodes on the given face.*/
42 size_t NumFaceNodes(size_t face_index) const;
43
44 const std::vector<std::vector<int>>& GetFaceNodeMappings() const;
45
46 /**Returns the cell volume.*/
47 double CellVolume() const;
48 /**Returns the given face area.*/
49 double FaceArea(size_t face_index) const;
50
51 /**Given the face index and the face node index, returns the index
52 * of the cell node the face node corresponds to.*/
53 int MapFaceNode(size_t face_index, size_t face_node_index) const;
54
55 // 02 ShapeFuncs
56 /**Returns the value of the required shape function at the world xyz point.*/
57 virtual double ShapeValue(int i, const chi_mesh::Vector3& xyz) const = 0;
58
59 /**Populates all the shape function values at the given world xyz point. This
60 * method is optimized to minimize reallocation of shape_values.*/
61 virtual void ShapeValues(const chi_mesh::Vector3& xyz,
62 std::vector<double>& shape_values) const = 0;
63
64 /**Returns the value of the required shape function gradient at the world xyz
65 * point.*/
66 virtual chi_mesh::Vector3
67 GradShapeValue(int i, const chi_mesh::Vector3& xyz) const = 0;
68
69 /**Populates all the shape function gradient values at the given world xyz
70 * point. This method is optimized to minimize reallocation of
71 * gradshape_values.*/
72 virtual void
74 std::vector<chi_mesh::Vector3>& gradshape_values) const = 0;
75
76 /**Returns the node locations associated with this element.*/
77 const std::vector<chi_mesh::Vector3>& GetNodeLocations() const;
78
79 // 03 Quadrature
80 /**Makes the volumetric/internal quadrature point data for this element.*/
83
84 /**Makes the surface quadrature point data for this element, at the specified
85 * face.*/
87 MakeSurfaceQuadraturePointData(size_t face_index) const = 0;
88
89 virtual ~CellMapping() = default;
90
91protected:
92 /**This function gets called to compute the cell-volume and
93 * face-areas. If simple linear cells are used then the
94 * default CellMapping::ComputeCellVolumeAndAreas can be
95 * used as this function. Otherwise (i.e. for higher order
96 * elements, the child-class should
97 * bind a different function to this.*/
98 typedef std::function<void(const chi_mesh::MeshContinuum&,
99 const chi_mesh::Cell&,
100 double&,
101 std::vector<double>&)>
103
105 const chi_mesh::Cell& cell,
106 size_t num_nodes,
107 std::vector<chi_mesh::Vector3> node_locations,
108 std::vector<std::vector<int>> face_node_mappings,
109 const VandAFunction& volume_area_function);
110
111 /**Static method that all child elements can use as a default.*/
113 const chi_mesh::Cell& cell,
114 double& volume,
115 std::vector<double>& areas);
116
119
120 const size_t num_nodes_;
121 const std::vector<chi_mesh::Vector3> node_locations_;
122
123 double volume_ = 0.0;
124 std::vector<double> areas_;
125
126 /** For each cell face, map from the face node index to the corresponding
127 * cell node index. More specifically, \p face_dof_mappings[f][fi], with
128 * \p fi the face node index of the face identified by face index \p f,
129 * contains the corresponding cell node index. */
130 const std::vector<std::vector<int>> face_node_mappings_;
131};
132} // namespace chi_math
133
134#endif // CHITECH_CELLMAPPING_H
virtual ~CellMapping()=default
double CellVolume() const
Definition: CellMapping.cc:46
virtual void GradShapeValues(const chi_mesh::Vector3 &xyz, std::vector< chi_mesh::Vector3 > &gradshape_values) const =0
const std::vector< std::vector< int > > & GetFaceNodeMappings() const
Definition: CellMapping.cc:41
int MapFaceNode(size_t face_index, size_t face_node_index) const
Definition: CellMapping.cc:53
const chi_mesh::MeshContinuum & ReferenceGrid() const
Definition: CellMapping.cc:29
CellMapping(const chi_mesh::MeshContinuum &grid, const chi_mesh::Cell &cell, size_t num_nodes, std::vector< chi_mesh::Vector3 > node_locations, std::vector< std::vector< int > > face_node_mappings, const VandAFunction &volume_area_function)
Definition: CellMapping.cc:12
const std::vector< std::vector< int > > face_node_mappings_
Definition: CellMapping.h:130
virtual void ShapeValues(const chi_mesh::Vector3 &xyz, std::vector< double > &shape_values) const =0
static void ComputeCellVolumeAndAreas(const chi_mesh::MeshContinuum &grid, const chi_mesh::Cell &cell, double &volume, std::vector< double > &areas)
Definition: CellMapping.cc:67
virtual finite_element::VolumetricQuadraturePointData MakeVolumetricQuadraturePointData() const =0
size_t NumNodes() const
Definition: CellMapping.cc:34
std::function< void(const chi_mesh::MeshContinuum &, const chi_mesh::Cell &, double &, std::vector< double > &)> VandAFunction
Definition: CellMapping.h:102
const std::vector< chi_mesh::Vector3 > node_locations_
Definition: CellMapping.h:121
double FaceArea(size_t face_index) const
Definition: CellMapping.cc:48
virtual double ShapeValue(int i, const chi_mesh::Vector3 &xyz) const =0
const chi_mesh::MeshContinuum & ref_grid_
Definition: CellMapping.h:117
const size_t num_nodes_
Definition: CellMapping.h:120
virtual finite_element::SurfaceQuadraturePointData MakeSurfaceQuadraturePointData(size_t face_index) const =0
virtual chi_mesh::Vector3 GradShapeValue(int i, const chi_mesh::Vector3 &xyz) const =0
std::vector< double > areas_
Definition: CellMapping.h:124
size_t NumFaceNodes(size_t face_index) const
Definition: CellMapping.cc:36
const chi_mesh::Cell & ReferenceCell() const
Definition: CellMapping.cc:27
const std::vector< chi_mesh::Vector3 > & GetNodeLocations() const
Definition: CellMapping.cc:156
const chi_mesh::Cell & cell_
Definition: CellMapping.h:118
VectorN< 3 > Vector3