Finite difference Laplacian with five-point stencil

Ghost cells. See also: Arrays with periodic boundaries - #4 by stevengj

(You’ll need an explicit loop anyway to update the ghost cells on each iteration. But the whole approach is so much more flexible because it separates the boundary conditions from the stencil.)

3 Likes