Skip to content
Projects

patchwork.kernels.multigrid_vcycle.multigrid_vcycle_pyccel

One multigrid V-cycle with multicolour Gauss—Seidel smoothing, from zero, with OpenMP.

The Pyccel version (CPU) of the multigrid_vcycle kernel; multigrid_vcycle_numpy.py next to this file is the NumPy version, with the same arguments. Loaded by patchwork.kernels.multigrid_vcycle, compiled with Pyccel on first use; called by CompositeMultigrid.cycle with smoother="gauss-seidel".

The levels operators, interpolations P and restrictions R = P^T are CSR matrices concatenated level by level, the finest first: level l’s row pointers are *_ptr[*_start[l] : *_start[l] + rows + 1], holding absolute positions in the concatenated *_idx (columns within the level) and *_val. Level l’s vectors are [offsets[l], offsets[l + 1]) of the work arrays bs, xs and rs. coarse maps the coarsest right-hand side to its solution (a dense inverse).

Gauss—Seidel goes colour by colour: the rows of a colour do not couple, so each colour is updated in parallel over num_threads threads, and the result does not depend on their number. Every level’s unknowns are numbered colour by colour, so a colour is a range of rows: level l’s bounds are color_start[color_level[l] : color_level[l + 1]] (one more than its colours). Each level is smoothed by sweeps sweeps through the colours in order before the coarse correction and as many in reverse order after it (a symmetric cycle). x gets the cycle applied to b.

Functions

NameDescription
multigrid_vcycleApply one V-cycle to b into x (see the module).

multigrid_vcyclefunction#

def multigrid_vcycle(levels: int, offsets: int[:], a_ptr: int[:], a_start: int[:], a_idx: int[:], a_val: float[:], p_ptr: int[:], p_start: int[:], p_idx: int[:], p_val: float[:], r_ptr: int[:], r_start: int[:], r_idx: int[:], r_val: float[:], coarse: float[:, :], color_start: int[:], color_level: int[:], sweeps: int, num_threads: int, b: float[:], x: float[:], bs: float[:], xs: float[:], rs: float[:]) -> None

Apply one V-cycle to b into x (see the module).