Trait Domain

pub trait Domain<C, I, V>:
    Send
    + Sync
    + Serialize
    + for<'a> Deserialize<'a> {
    // Required methods
    fn apply_boundary(&self, cell: &mut C) -> Result<(), BoundaryError>;
    fn get_neighbor_voxel_indices(&self, index: &I) -> Vec<I>;
    fn get_voxel_index(&self, cell: &C) -> I;
    fn get_all_indices(&self) -> Vec<I>;
    fn generate_contiguous_multi_voxel_regions(
        &self,
        n_regions: usize,
    ) -> Result<Vec<Vec<(I, V)>>, CalcError>;
}
Expand description

Describes the physical simulation domain.

This trait is responsible for the overall physical setup of our simulation. Simple domains can be thought of as rectangular cuboids in 2D or 3D and such examples are being implemented in domains. Most of the functions you will see are required by the backend to make sense of the whole simulation domain and send cells to the correct subdomains and give correct boundary conditions. cellular_raza uses domain decomposition to parallelize over different regions of space and thus efficiently utilize hardware resources although the exact details do depend on the backend. The simulation domain is split into many voxels which interact only with their next neighbors. By increasing the size of these voxels, we can allow for longer interaction ranges or vice versa.

Required Methods§

fn apply_boundary(&self, cell: &mut C) -> Result<(), BoundaryError>

Applies boundary conditions to a cell in order to keep it inside the simulation. For the future, we aim to apply boundary conditions to the position of the cell rather than itself. In addition, we would like to be able to invoke events such as Remove to maximize flexibility.

fn get_neighbor_voxel_indices(&self, index: &I) -> Vec<I>

Retrieves the neighboring voxels of the one specified.

fn get_voxel_index(&self, cell: &C) -> I

Provided a cell, gives the corresponding Index and thus which voxel to sort into.

fn get_all_indices(&self) -> Vec<I>

Get all indices that are present in the simulation. Required for initial configuration of the simulation domain.

fn generate_contiguous_multi_voxel_regions( &self, n_regions: usize, ) -> Result<Vec<Vec<(I, V)>>, CalcError>

Allows the backend to split the domain into continuous regions which contain voxels. These regions can then be used for parallelization.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

§

impl<Cel, Ind, Vox, Dom> Domain<CellAgentBox<Cel>, Ind, Vox> for DomainBox<Dom>
where Dom: Domain<Cel, Ind, Vox>, Vox: Send + Sync, Cel: Send + Sync,

§

impl<Cel, const D: usize, const N: usize> Domain<Cel, [i64; 2], CartesianCuboidVoxel2Vertex<D, N>> for CartesianCuboid2Vertex
where Cel: Position<Matrix<f64, Const<D>, Const<2>, ArrayStorage<f64, D, 2>>> + Velocity<Matrix<f64, Const<D>, Const<2>, ArrayStorage<f64, D, 2>>>,

§

impl<Cel, const N: usize> Domain<Cel, [i64; 1], CartesianCuboidVoxel1<N>> for CartesianCuboid1
where Cel: Position<Matrix<f64, Const<1>, Const<1>, ArrayStorage<f64, 1, 1>>> + Velocity<Matrix<f64, Const<1>, Const<1>, ArrayStorage<f64, 1, 1>>>,

§

impl<Cel, const N: usize> Domain<Cel, [i64; 2], CartesianCuboidVoxel2<N>> for CartesianCuboid2
where Cel: Position<Matrix<f64, Const<2>, Const<1>, ArrayStorage<f64, 2, 1>>> + Velocity<Matrix<f64, Const<2>, Const<1>, ArrayStorage<f64, 2, 1>>>,

§

impl<Cel, const N: usize> Domain<Cel, [i64; 3], CartesianCuboidVoxel3<N>> for CartesianCuboid3
where Cel: Position<Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>> + Velocity<Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>>,