buildNeumannLaplacian

Builds the discrete Neumann ("free edge") Laplacian for the interior grid points marked true in mask, a width x height grid stored row-major (index = y * width + x).

Unlike buildDirichletLaplacian, a stencil neighbor that falls outside the grid or lands on a false cell isn't treated as pinned to zero -- it's simply dropped from the stencil, which is the standard way to encode a zero-derivative (reflecting) boundary. Each interior point's diagonal is therefore its number of in-domain neighbors rather than a fixed 4. This makes the matrix exactly the combinatorial graph Laplacian of the mask's grid-adjacency graph: symmetric positive semi-definite, with the constant vector as its null (zero-eigenvalue) eigenvector for a connected domain -- see extractNeumannEigenModes.

Return

The Laplacian as a sparse matrix, and the compact per-cell degree-of-freedom index (-1 for cells outside the mask) used to interpret its rows/columns.

Parameters

mask

Interior/exterior flag per grid cell, size width * height.