buildDirichletLaplacian

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

Grid points outside mask act as a zero (Dirichlet) boundary condition: a stencil neighbor that falls outside the grid, or lands on a false cell, is simply omitted rather than wrapped or reflected, which is what pins the field to zero there. The resulting matrix is indexed by a compact "degree of freedom" numbering over only the interior points, in row-major order among true cells, and is always symmetric positive-definite for a non-empty, bounded domain.

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.