rs_isl

rs_isl is an implementation of Iterative Stencil Loops in Rust.
ISLs can be used in a variety of scenarios such as image processing, fluid simulation and the calculation of PDEs.
For more information see Wikipedia.
Example
This animation was created with Paraview from the data created by the example two_waves.
Output
rs_isl writes .vtk output files to a specified path. Their contents may be defined by the user.
To create those files rs_isl uses the vtkio crate.
Usage
General
use core::f64;
use std::{cmp::max, path::PathBuf};
use rs_isl::*;
fn main() {
let dim = (200, 100)
let neighbours = vec![(-1, 0)];
let op = |num: &f32, nb: Vec<Option<&f32>>| {
if nb.first().unwrap().is_some() {
let f = *nb[0].unwrap();
return f;
}
return max(*num as i32 - 3, 0) as f32;
};
let init = |x: usize, _y: usize| {
if x < DIM.0 / 10 {
let fac = x as f64 / (DIM.0 / 10) as f64 * f64::consts::FRAC_PI_2;
return (250.0 - 250.0 * fac.sin()) as f32;
}
0.0
};
let params = IslParams::new(
dim,
op,
10,
init,
200,
100,
neighbours,
PathBuf::from("raw"),
);
run_isl(params).unwrap();
}
Setting output values for a custom data type
struct Point {
x: u32,
y: u32,
}
impl VtkOutput for Point {
fn value_names() -> Vec<String> {
vec!["x_coord".into(), "y_coord".into()]
}
fn cellvalue(&self) -> Vec<f32> {
vec![self.x as f32, self.y as f32]
}
}