fn diffuse(array: &mut Array2<f32>, array_prev: &Array2<f32>, iter: usize, dt: f32, visc: f32) {
    let shape = array_prev.shape();
    let multiplier = dt * visc * shape[0] as f32 * shape[1] as f32;
    for _ in 0..iter {
        for x in 1..(shape[0] - 1) {
            for y in 1..(shape[1] - 1) {
                let ns = neighbours((x, y));

                let sum: f32 = ns.iter().map(|n| array[(n.0, n.1)]).sum();

                array[(x, y)] = (array_prev[(x, y)] + multiplier * sum)
                    * (1.0 / (1.0 + ns.len() as f32 * multiplier));
            }
        }
        set_boundries(array);
    }
}
/// Diffuses the array by making it the average sum of it's neighbours.
/// Using Gauss-Seidel relaxation to solve a system of linear equations of
/// form
/// x0[IX(i,j)] = x[IX(i,j)] - a*(x[IX(i-1,j)]+x[IX(i+1,j)]+x[IX(i,j-1)]+x[IX(i,j+1)]-4*x[IX(i,j)])
///
Diffuses the array by making it the average sum of it's neighbours.
Diffuses the array by making it the average sum of it ' s neighbours .
fn diffuse(array: &mut Array2<f32>, array_prev: &Array2<f32>, iter: usize, dt: f32, visc: f32) {
    let shape = array_prev.shape();
    let multiplier = dt * visc * shape[0] as f32 * shape[1] as f32;
    for _ in 0..iter {
        for x in 1..(shape[0] - 1) {
            for y in 1..(shape[1] - 1) {
                let ns = neighbours((x, y));
                let sum: f32 = ns.iter().map(|n| array[(n.0, n.1)]).sum();
                array[(x, y)] = (array_prev[(x, y)] + multiplier * sum)
                    * (1.0 / (1.0 + ns.len() as f32 * multiplier));
            }
        }
        set_boundries(array);
    }
}
fn diffuse ( array : & mut Array2 < f32 > , array_prev : & Array2 < f32 > , iter : usize , dt : f32 , visc : f32 ) { let shape = array_prev . shape ( ) ; let multiplier = dt * visc * shape [ 0 ] as f32 * shape [ 1 ] as f32 ; for _ in 0 .. iter { for x in 1 .. ( shape [ 0 ] - 1 ) { for y in 1 .. ( shape [ 1 ] - 1 ) { let ns = neighbours ( ( x , y ) ) ; let sum : f32 = ns . iter ( ) . map ( | n | array [ ( n . 0 , n . 1 ) ] ) . sum ( ) ; array [ ( x , y ) ] = ( array_prev [ ( x , y ) ] + multiplier * sum ) * ( 1.0 / ( 1.0 + ns . len ( ) as f32 * multiplier ) ) ; } } set_boundries ( array ) ; } }
Diffuses the array by making it the average sum of it's neighbours.
Diffuses the array by making it the average sum of it ' s neighbours .
array
&mut Array2<f32>
array_prev
&Array2<f32>
iter
usize
dt
f32
visc
f32
array
&mut Array2<f32>
array_prev
&Array2<f32>
iter
usize
dt
f32
visc
f32