Trait SubDomain

pub trait SubDomain {
    type VoxelIndex;

    // Required methods
    fn get_neighbor_voxel_indices(
        &self,
        voxel_index: &Self::VoxelIndex,
    ) -> Vec<Self::VoxelIndex>;
    fn get_all_indices(&self) -> Vec<Self::VoxelIndex>;
}
Expand description

Subdomains are produced by decomposing a Domain into multiple physical regions.

§Derivation

struct MySubDomain {
    x_min: f32,
    x_max: f32,
    n: usize,
}

impl SubDomain for MySubDomain {
    type VoxelIndex = usize;

    fn get_neighbor_voxel_indices(
        &self,
        voxel_index: &Self::VoxelIndex
    ) -> Vec<Self::VoxelIndex> {
        (voxel_index.saturating_sub(1)..voxel_index.saturating_add(1).min(self.n)+1)
            .filter(|k| k!=voxel_index)
            .collect()
    }

    fn get_all_indices(&self) -> Vec<Self::VoxelIndex> {
        (0..self.n).collect()
    }
}

#[derive(SubDomain)]
struct MyNewSubDomain {
    #[Base]
    base: MySubDomain,
}

Required Associated Types§

type VoxelIndex

Individual Voxels inside each subdomain can be accessed by this index.

Required Methods§

fn get_neighbor_voxel_indices( &self, voxel_index: &Self::VoxelIndex, ) -> Vec<Self::VoxelIndex>

Obtains the neighbor voxels of the specified voxel index. This function behaves similarly to SortCells::get_voxel_index_of in that it also has to return indices which are in other SubDomains.

fn get_all_indices(&self) -> Vec<Self::VoxelIndex>

Get all voxel indices of this SubDomain.

Implementors§