pygeon.grids.create_grid module

Create grids from various sources.

pygeon.grids.create_grid.grid_from_domain(domain, mesh_size, as_mdg=True, **kwargs)[source]

Create a grid from a domain with a specified mesh size.

Parameters:
  • domain (pp.Domain) – The domain of the grid.

  • mesh_size (float) – The desired mesh size for the grid.

  • as_mdg (bool) – Return the grid as a mixed-dimensional grid. Default True.

  • **kwargs

    Additional options for creating the grid:

    • mesh_size_min (float): The minimum mesh size. Default is mesh_size / 10.

Returns:

Either a pg.MixedDimensionalGrid or a pg.Grid, depending on the value of as_mdg.

pygeon.grids.create_grid.grid_from_boundary_pts(pts, mesh_size, as_mdg=True, **kwargs)[source]

Create a 2D grid from a set of nodes, where portions of the boundary of the grid are constructed from subsequent nodes, with a given mesh size.

Parameters:
  • pts (np.ndarray) – The ordered points representing the boundary.

  • mesh_size (float) – The desired mesh size.

  • as_mdg (bool) – Return the grid as a mixed-dimensional grid. Default True.

  • **kwargs

    Additional options:

    • mesh_size_min (float): The minimum mesh size. Default is mesh_size.

Returns:

Either a pg.MixedDimensionalGrid or a pg.Grid.

pygeon.grids.create_grid.unit_grid(dim, mesh_size, as_mdg=True, **kwargs)[source]

Create a unit square or cube grid with a given mesh size.

Parameters:
  • dim (int) – The dimension of the grid.

  • mesh_size (float) – The desired mesh size.

  • as_mdg (bool) – Return the grid as a mixed-dimensional grid. Default True.

  • kwargs

    Additional options:

    • mesh_size_min (float): The minimum mesh size. Default is the same as mesh_size.

    • structured (bool): If True, create a structured grid.

Returns:

Either a pg.MixedDimensionalGrid or a pg.Grid.

pygeon.grids.create_grid.reference_element(dim)[source]

Create a reference element of a given dimension.

Parameters:

dim (int) – The dimension of the reference element.

Returns:

The reference element.

Return type:

pg.Grid