Trait SubDomainReactions

Source
pub trait SubDomainReactions<Pos, Re, Float> {
    type NeighborValue;
    type BorderInfo;

    // Required methods
    fn treat_increments<I, J>(
        &mut self,
        neighbors: I,
        sources: J,
    ) -> Result<(), CalcError>
       where I: IntoIterator<Item = Self::NeighborValue>,
             J: IntoIterator<Item = (Pos, Re)>;
    fn update_fluid_dynamics(&mut self, dt: Float) -> Result<(), CalcError>;
    fn get_extracellular_at_pos(&self, pos: &Pos) -> Result<Re, CalcError>;
    fn get_neighbor_value(
        &self,
        border_info: Self::BorderInfo,
    ) -> Self::NeighborValue;
    fn get_border_info(&self) -> Self::BorderInfo;
}
Expand description

Describes extracellular reactions and fluid dynamics

§Derivation


#[derive(Clone, Debug)]
struct MyReactions<const N: usize> {
    values: Vec<f32>,
    pos: [f32; N],
}

impl<const N: usize> SubDomainReactions<[f32; N], Vec<f32>, f32> for MyReactions<N> {
    type NeighborValue = Vec<f32>;
    type BorderInfo = Self;

    fn treat_increments<I, J>(
        &mut self,
        neighbors: I,
        sources: J,
    ) -> Result<(), CalcError>
    where
        I: IntoIterator<Item = Self::NeighborValue>,
        J: IntoIterator<Item = ([f32; N], Vec<f32>)>,
    {
        Ok(())
    }

    fn update_fluid_dynamics(&mut self, dt: f32) -> Result<(), CalcError> {
        Ok(())
    }

    fn get_extracellular_at_pos(&self, pos: &[f32; N]) -> Result<Vec<f32>, CalcError> {
        Ok(self.values.clone())
    }

    fn get_neighbor_value(&self, border_info: Self::BorderInfo) -> Self::NeighborValue {
        self.values.clone()
    }

    fn get_border_info(&self) -> Self::BorderInfo {
        self.clone()
    }
}

#[derive(SubDomain)]
struct DerivedSubDomain<const N: usize> {
    #[Reactions]
    reactions: MyReactions<N>,
}

Required Associated Types§

Source

type NeighborValue

Extracellular value of neighbor

Source

type BorderInfo

Exchanged information to locate neighboring subdomains.

Required Methods§

Source

fn treat_increments<I, J>( &mut self, neighbors: I, sources: J, ) -> Result<(), CalcError>
where I: IntoIterator<Item = Self::NeighborValue>, J: IntoIterator<Item = (Pos, Re)>,

Combines increments which have been obtained by neighbors and cell-sources

Source

fn update_fluid_dynamics(&mut self, dt: Float) -> Result<(), CalcError>

Main update function to calculate new values of extracellular concentrations.

Source

fn get_extracellular_at_pos(&self, pos: &Pos) -> Result<Re, CalcError>

Obtain extracellular concentrations at given point.

Source

fn get_neighbor_value( &self, border_info: Self::BorderInfo, ) -> Self::NeighborValue

Obtains the SubDomainReactions::NeighborValue which should be sent to the neighbor which has exposed the given SubDomainReactions::BorderInfo.

Source

fn get_border_info(&self) -> Self::BorderInfo

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§