pub trait SubDomainMechanics<Pos, Vel> {
// Required method
fn apply_boundary(
&self,
pos: &mut Pos,
vel: &mut Vel
) -> Result<(), BoundaryError>;
}
Expand description
Apply boundary conditions to a cells position and velocity.
Derivation
struct MyMechanics {
x_min: f64,
x_max: f64,
}
impl SubDomainMechanics<f64, f64> for MyMechanics {
fn apply_boundary(&self, pos: &mut f64, vel: &mut f64) -> Result<(), BoundaryError> {
if *pos < self.x_min {
*vel = vel.abs();
}
if *pos > self.x_max {
*vel = -vel.abs();
}
*pos = pos.clamp(self.x_min, self.x_max);
Ok(())
}
}
#[derive(SubDomain)]
struct MySubDomain {
#[Mechanics]
mechanics: MyMechanics,
}
Required Methods§
sourcefn apply_boundary(
&self,
pos: &mut Pos,
vel: &mut Vel
) -> Result<(), BoundaryError>
fn apply_boundary( &self, pos: &mut Pos, vel: &mut Vel ) -> Result<(), BoundaryError>
If the subdomain has boundary conditions, this function will enforce them onto the cells. For the future, we plan to replace this function to additionally obtain information about the previous and current location of the cell.