1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//! Cell type metadata for mesh points.
/// Common cell types for mesh elements.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Default)]
pub enum CellType {
/// 0D vertex.
#[default]
Vertex,
/// 1D segment/edge.
Segment,
/// 2D simplex (triangle).
Triangle,
/// 2D tensor-product cell (quad).
Quadrilateral,
/// 3D simplex (tet).
Tetrahedron,
/// 3D tensor-product cell (hex).
Hexahedron,
/// 3D wedge/prism.
Prism,
/// 3D pyramid.
Pyramid,
/// 2D polygon with `n` vertices.
Polygon(u8),
/// Generic simplex with dimension `d`.
Simplex(u8),
/// Generic polyhedron.
Polyhedron,
}
impl CellType {
/// Returns the topological dimension of the cell, when well-defined.
pub fn dimension(self) -> u8 {
match self {
CellType::Vertex => 0,
CellType::Segment => 1,
CellType::Triangle | CellType::Quadrilateral | CellType::Polygon(_) => 2,
CellType::Tetrahedron
| CellType::Hexahedron
| CellType::Prism
| CellType::Pyramid
| CellType::Polyhedron => 3,
CellType::Simplex(d) => d,
}
}
}