8.4. pyafv.ParallelFiniteVoronoiSimulator

class ParallelFiniteVoronoiSimulator(pts, phys, grid_shape=(2, 2), n_workers=None, *, halo_width=None, backend=None, domain_bounds=None, decomposition_method='dense')[source]

Python multiprocessing domain-decomposed simulator for the AFV model.

This class decomposes the full point set into rectangular domains with halo regions, then composes FiniteVoronoiSimulator on each local subdomain. The returned diagnostics are merged back into global cell indexing for owned cells. When n_workers > 1, local subdomain builds use Python worker processes.

Parameters:
  • pts (ndarray) – (N,2) array of initial cell center positions.

  • phys (PhysicalParams) – Physical parameters used within this simulator.

  • grid_shape (tuple[int, int]) – Number of domains in the x and y directions.

  • n_workers (int | None) – Number of worker processes. If None, use os.cpu_count().

  • halo_width (float | None) – Width of the halo region added to each domain. If None, use 4.01 * phys.r.

  • backend (Literal['cython', 'python'] | None) – Optional, specify “python” to force the use of the pure Python fallback implementation inside each local finite Voronoi simulator. Otherwise, the “cython” backend is used.

  • domain_bounds (tuple[tuple[float, float], tuple[float, float]] | None) – Optional domain bounds as ((xmin, xmax), (ymin, ymax)). If None, bounds are inferred from the current point positions.

  • decomposition_method (Literal['dense', 'binned', 'sorted_x']) – Method used to collect halo points. "dense" is usually faster for moderate systems. "binned" can be faster for many domains. "sorted_x" uses less temporary memory.

Raises:

Note

For repeated calls with n_workers > 1, put the loop inside the context manager so worker processes are created once and reused across build steps:

with sim:       # sim is an instance of ParallelFiniteVoronoiSimulator
    for step in range(num_steps):
        diag = sim.build()

Attributes

preferred_areas

Return a copy of the preferred area array.

Methods

build([connect, plot_mode])

Build local finite Voronoi structures and merge global diagnostics.

update_params(phys)

Update physical parameters.

update_positions(pts[, A0])

Update cell center positions.

update_preferred_areas(A0)

Update the preferred areas for all cells.