pygeon.grids.voronoi module

Module for the Voronoi grid generation.

class pygeon.grids.voronoi.VoronoiGrid(*args, **kwargs)[source]

Bases: Grid

Voronoi grid implementation.

__init__(num_pts=None, vrt=None, **kwargs)[source]

Initialize a VoronoiGrid object.

Parameters:
  • num_pts (int, optional) – The number of internal seed points. Defaults to None.

  • pts (ndarray, optional) – The internal seed points, to be in the unit square. Defaults to None.

  • **kwargs – Additional keyword arguments, like the seed for the random number and a parameter to fit the grid to a bounding box in case the standard value does not work as expected. The former with key “seed” and the latter with key “factor”.

Returns:

None

generate_internal_pts(num_pts, **kwargs)[source]

Generate internal points within the Voronoi grid.

Parameters:
  • num_pts (int) – The number of points to generate.

  • **kwargs – Additional keyword arguments. seed (int, optional): The seed for the random number generator.

Returns:

An array of generated internal points.

Return type:

np.ndarray

grid_topology(vor, nodes)[source]

Computes the grid topology for a given Voronoi diagram.

Parameters:
  • vor (scipy.spatial.Voronoi) – The Voronoi diagram.

  • nodes (np.ndarray) – The array of node coordinates.

Returns:

A tuple containing the face-node connectivity matrix and the cell-face connectivity matrix.

Return type:

Tuple[sps.csc_array, sps.csc_array]