hydromodpy.solver.boussinesq.jacobian.fd#

Finite-difference Jacobian helpers for Boussinesq runtimes.

At the moment the Boussinesq backends share a deliberately simple strategy:

  • keep the nonlinear unknown equal to the cell-centered head vector;

  • evaluate the residual as a black-box function of that vector;

  • approximate the Jacobian by forward finite differences.

This module now exposes both:

  • a dense builder used by the historical local and scipy runtimes;

  • sparse-oriented helpers that derive a cell-coupling stencil from mesh connectivity and keep only those entries in the assembled Jacobian.

The sparse path also supports a simple greedy column coloring so structurally independent columns can be perturbed together. That keeps the physics black-box while reducing the number of residual evaluations needed for one sparse FD Jacobian build.

Functions

build_cell_coupling_rows_by_column(*, ...)

Return the residual rows that can depend on each head unknown.

build_colored_sparse_fd_jacobian_triplets(...)

Build sparse Jacobian triplets using graph-colored FD perturbations.

build_dense_fd_jacobian(residual_fn, head_m, ...)

Build a dense Jacobian by perturbing one head component at a time.

build_sparse_fd_jacobian_triplets(...)

Build sparse Jacobian triplets using a precomputed coupling stencil.

color_columns_by_row_overlap(rows_by_col)

Group columns whose structural row supports do not overlap.