fips_md/runtime/
domain.rs

1//! Structures related to defining a simulation domain
2
3#[derive(Clone)]
4pub enum Domain {
5    Dim2{x: Axis, y:Axis}, Dim3{x: Axis, y:Axis, z:Axis}
6}
7
8impl Domain {
9    pub fn get_dim(&self) -> usize {
10        match self {
11            Domain::Dim2{..} => 2,
12            Domain::Dim3{..} => 3,
13        }
14    }
15}
16
17/// Definition of a single coordinate axis (i.e. bounds and out-of-bounds behavior)
18#[derive(Clone)]
19pub struct Axis {
20    pub low: f64,
21    pub high: f64,
22    pub oob: OutOfBoundsBehavior
23}
24
25/// Definition of the out-of-bounds behavior
26#[derive(Clone)]
27pub enum OutOfBoundsBehavior {
28    Periodic
29}
30
31impl Axis {
32    pub(crate) fn size(&self) -> f64 {
33        self.high - self.low
34    }
35
36    #[inline(always)]
37    pub(crate) fn is_on_axis(&self, x: f64) -> bool {
38        x >= self.low && x <= self.high
39    }
40}