ndelement/
types.rs

1//! Types.
2#[cfg(feature = "mpi")]
3use mpi::traits::Equivalence;
4use rlst::{DynArray, RlstScalar};
5use strum_macros::EnumIter;
6
7/// Continuity type
8#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
10#[repr(u8)]
11pub enum Continuity {
12    /// The element has standard continuity between cells
13    ///
14    /// For some element, this option does not indicate that the values are fully continuous.
15    /// For example, for Raviart-Thomas elements it only indicates that the normal components
16    /// are continuous across edges
17    Standard,
18    /// The element is discontinuous betweeen cells
19    Discontinuous,
20}
21
22/// The map type used by an element
23#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
24#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
25#[repr(u8)]
26pub enum MapType {
27    /// Identity map
28    Identity,
29    /// Covariant Piola map
30    ///
31    /// This map is used by H(curl) elements
32    CovariantPiola,
33    /// Contravariant Piola map
34    ///
35    /// This map is used by H(div) elements
36    ContravariantPiola,
37    /// L2 Piola map
38    L2Piola,
39}
40
41/// The type of a reference cell
42#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
43#[derive(EnumIter, Debug, PartialEq, Eq, Clone, Copy, Hash)]
44#[repr(u8)]
45pub enum ReferenceCellType {
46    /// A point
47    Point,
48    /// A line interval
49    Interval,
50    /// A triangle
51    Triangle,
52    /// A quadrilateral
53    Quadrilateral,
54    /// A tetrahedron (whose faces are all triangles)
55    Tetrahedron,
56    /// A hexahedron (whose faces are all quadrilaterals)
57    Hexahedron,
58    /// A triangular prism
59    Prism,
60    /// A square-based pyramid
61    Pyramid,
62}
63
64#[cfg(feature = "mpi")]
65unsafe impl Equivalence for Continuity {
66    type Out = <u8 as Equivalence>::Out;
67    fn equivalent_datatype() -> <u8 as Equivalence>::Out {
68        <u8 as Equivalence>::equivalent_datatype()
69    }
70}
71#[cfg(feature = "mpi")]
72unsafe impl Equivalence for MapType {
73    type Out = <u8 as Equivalence>::Out;
74    fn equivalent_datatype() -> <u8 as Equivalence>::Out {
75        <u8 as Equivalence>::equivalent_datatype()
76    }
77}
78#[cfg(feature = "mpi")]
79unsafe impl Equivalence for ReferenceCellType {
80    type Out = <u8 as Equivalence>::Out;
81    fn equivalent_datatype() -> <u8 as Equivalence>::Out {
82        <u8 as Equivalence>::equivalent_datatype()
83    }
84}
85
86/// A DOF transformation
87#[derive(Debug)]
88#[repr(u8)]
89pub enum DofTransformation<T: RlstScalar> {
90    /// An identity transformation
91    Identity,
92    /// A permutation
93    Permutation(Vec<usize>),
94    /// A linear transformation
95    Transformation(DynArray<T, 2>, Vec<usize>),
96}
97
98/// A transformation of a sub-entity
99#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
100#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
101#[repr(u8)]
102pub enum Transformation {
103    /// A reflection
104    Reflection,
105    /// A rotation
106    Rotation,
107}