Skip to main content

poisson_2d

Function poisson_2d 

Source
pub fn poisson_2d<F, G>(
    f: F,
    boundary: G,
    width: f64,
    height: f64,
    nx: usize,
    ny: usize,
) -> Result<Vec<Vec<f64>>, ErrorsJSL>
where F: Fn(f64, f64) -> f64, G: Fn(f64, f64) -> f64,
Expand description

Solves −∇²u = f on [0, width] × [0, height] with u = g on the boundary, on an nx × ny grid of points including the boundary. Returns u[j][i] at (i Δx, j Δy). The five-point system is symmetric positive definite and is solved by conjugate gradients to a relative residual of 1e-12.