ndgrid/
types.rs

1//! Types
2#[cfg(feature = "mpi")]
3use mpi::traits::Equivalence;
4use rlst::{
5    RlstScalar,
6    dense::linalg::lapack::interface::{getrf::Getrf, getri::Getri},
7};
8
9/// A scalar.
10pub trait Scalar: RlstScalar + Getrf + Getri {}
11
12impl<T: RlstScalar + Getrf + Getri> Scalar for T {}
13
14/// A (cell, local index) pair
15///
16/// The local index is the index of a subentity (eg vertex, edge) within the cell as it is numbered in the reference cell
17#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
18#[derive(Debug, Clone)]
19pub struct CellLocalIndexPair<IndexType: std::fmt::Debug + Eq + Copy> {
20    /// The cell's index
21    pub cell: IndexType,
22    /// The local index of the subentity
23    pub local_index: usize,
24}
25
26impl<IndexType: std::fmt::Debug + Eq + Copy> CellLocalIndexPair<IndexType> {
27    /// Create a (cell, local index) pair
28    pub fn new(cell: IndexType, local_index: usize) -> Self {
29        Self { cell, local_index }
30    }
31}
32
33/// Ownership
34#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
35#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
36#[repr(u8)]
37pub enum Ownership {
38    /// Undefined ownership. This should only be used as a placeholder value
39    Undefined,
40    /// Owned by the current process
41    Owned,
42    /// Not owned on the current process. The two values are the process that owns it
43    /// and its local index on that process
44    Ghost(usize, usize),
45}
46
47#[cfg(feature = "mpi")]
48unsafe impl Equivalence for Ownership {
49    type Out = <u8 as Equivalence>::Out;
50    fn equivalent_datatype() -> <u8 as Equivalence>::Out {
51        <u8 as Equivalence>::equivalent_datatype()
52    }
53}
54
55/// Graph partitioner
56#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
57#[derive(Debug, PartialEq, Eq, Clone, Hash)]
58#[repr(u8)]
59pub enum GraphPartitioner {
60    /// No partioner: cells are split into approximately equal sized lists by index
61    None,
62    /// A manual partition
63    Manual(Vec<usize>),
64    #[cfg(feature = "coupe")]
65    /// Use Coupe's KMeans implementation to generate a partition
66    Coupe,
67    #[cfg(feature = "scotch")]
68    /// Use Scotch to generate a partition
69    Scotch,
70}