zoomy_core.symsolver.numpy_backend.assembly

zoomy_core.symsolver.numpy_backend.assembly#

Assembly of a cell operator by colouring and the host AMG solve, shared by the numpy and JAX runtimes (pure numpy / scipy / pyamg).

References

Module Contents#

Functions#

cell_pattern

Sparsity of a cell operator on k = n / nc cell-major unknowns: each couples to those of the cells in its LSQ stencil.

operator_neighbors

Per cell the cells an operator of the derivative aux couples it to, the sparsity cell_pattern assembles: the samples of its LSQ fit, i.e. the topology’s stencil (topo.lsq_neighbors, which wraps a periodic seam; the mesh’s lsq_neighbors ends there) and the cell behind each boundary-face sample’s ghost (boundary_face_cells: the inner cell, or the partner across a periodic seam). With the mesh’s stencil alone the assembled matrix lacked the cross-seam entries: the AMG solve of a periodic pressure system converged to the wrong matrix (true relative residual 0.78 on a periodic VAM(3) channel). Rows padded with -1.

cell_colors

Distance-2 colouring of the stencil pairs (c, d) by speculative parallel greedy (a clash with a heavier random-weight neighbour retries).

host_amg_solve

GMRES preconditioned by a smoothed-aggregation AMG hierarchy of the cell-block-scaled matrix; the hierarchy in cache is lagged: rebuilt every ls['amg_rebuild'] solves, or once the iterations exceed ls['amg_growth'] times those after the last rebuild.

API#

zoomy_core.symsolver.numpy_backend.assembly.cell_pattern(n, nc, nbrs, n_rows=None)#

Sparsity of a cell operator on k = n / nc cell-major unknowns: each couples to those of the cells in its LSQ stencil.

Returns

rows, cols in CSR order and a colour per column such that columns sharing a row differ.

zoomy_core.symsolver.numpy_backend.assembly.operator_neighbors(topo, mesh_np)#

Per cell the cells an operator of the derivative aux couples it to, the sparsity cell_pattern assembles: the samples of its LSQ fit, i.e. the topology’s stencil (topo.lsq_neighbors, which wraps a periodic seam; the mesh’s lsq_neighbors ends there) and the cell behind each boundary-face sample’s ghost (boundary_face_cells: the inner cell, or the partner across a periodic seam). With the mesh’s stencil alone the assembled matrix lacked the cross-seam entries: the AMG solve of a periodic pressure system converged to the wrong matrix (true relative residual 0.78 on a periodic VAM(3) channel). Rows padded with -1.

zoomy_core.symsolver.numpy_backend.assembly.cell_colors(c, d, nc, seed=0)#

Distance-2 colouring of the stencil pairs (c, d) by speculative parallel greedy (a clash with a heavier random-weight neighbour retries).

zoomy_core.symsolver.numpy_backend.assembly.host_amg_solve(vals, rhs, rows, cols, n, k, ls, pyamg, cache, transpose=False)#

GMRES preconditioned by a smoothed-aggregation AMG hierarchy of the cell-block-scaled matrix; the hierarchy in cache is lagged: rebuilt every ls['amg_rebuild'] solves, or once the iterations exceed ls['amg_growth'] times those after the last rebuild.

Args

  • vals, rows, cols: the (n, n) matrix in COO form, k x k blocks per cell

  • ls: tol, restart, maxiter, amg_rebuild, amg_growth

  • cache: a dict kept between the solves of one operator

Returns

the solution, rhs’s dtype

References