Grids

Grid

class Grid(*args, **kwargs)[source]

Bases: SpatialComponent

Basic grid class.

apply_minpv()[source]

Apply MINPV threshold to ACTNUM.

property as_corner_point

Corner-point representation of the grid.

bounding_box

Pair of diagonal corner points for grid’s bounding box.

calculate_neighbours_distances(connectivity=1, fill_value=-1, neighbours_matrix=None)[source]

Calculate distances between neighbors for all active cells.

Parameters:
  • connectivity (int, optional) – Maximum number of orthogonal hops to consider a cell is as a neighbor., by default 1.

  • fill_value (int, optional) – Value to fill indices of inactive or absent neighbors, by default -1.

  • neighbours_matrix (numpy.ndarray, optional) – Matrix with indices of neighbors in unraveled form.

Returns:

Matrix of distances.

Return type:

numpy.ndarray

property cell_centroids

Centroids of cells.

property cell_volumes

Volumes of cells.

create_vtk_grid(use_only_active=True, scaling=True, **kwargs)[source]

Creates pyvista unstructured grid object.

Returns:

grid

Return type:

pyvista.core.pointset.UnstructuredGrid object

crop_minimal_cube()[source]

Crop to minimal cube containing active cells.

property ex

Unit vector along grid X axis.

property ey

Unit vector along grid Y axis.

get_neighbors_matrix(connectivity=1, fill_value=-1, ravel_index=False)[source]

Get indices of neighbors for all active cells.

Parameters:
  • connectivity (int, optional) – Maximum number of orthogonal hops to consider a cell is as a neighbor, by default 1.

  • fill_value (int, optional) – Value to fill indices of inactive or absent neighbors, by default -1.

  • ravel_index (bool, optional) – Indices in raveled form, by default False.

Returns:

res – Matrix of active neighbors and matrix of distances if ‘calculate_distances’.

Return type:

misc

minimal_active_slices()[source]

Get minimal cube slice that contains all active cells.

property origin

Grid axes origin relative to the map coordinates.

to_corner_point()[source]

Corner-point representation of the grid.

property xyz

Cell vertices coordinates.

Orthogonal uniform grid

Corner-point grid

class CornerPointGrid(*args, **kwargs)[source]

Bases: Grid

Corner point grid.

property as_corner_point

Returns itself.

cell_bases(cell_indices)[source]

Calculate basis vectors of coordinate systems connected to cells.

Parameters:

cells_indices (List[np.ndarray]) – Indices of the cells.

Returns:

Basis vectors of coordinate systems connected to cells.

Return type:

np.ndarray

cell_sizes(cell_indices)[source]

Calculate approximate sizes of cells.

Parameters:

cells_indices (List[np.ndarray]) – Indices of the cells.

Returns:

Sizes of cells.

Return type:

np.ndarray

property cell_volumes

Volumes of cells.

crop_minimal_cube()[source]

Crop to minimal cube containing active cells.

Returns:

(grid, min_slices) – New grid and slices for active cube.

Return type:

tuple

crop_minimal_grid(nz, fillna=None)[source]

Create a new grid in a region between upper and bottom surfaces enclosing active cells. Actnum transfer should be made separately.

Parameters:
  • nz (int) – Third dimension of the cunstructed grid.

  • fillna (scalar) – Filling value for nan coordinates.

Returns:

(grid, grid_mask, z_top, z_bottom)

Return type:

tuple

faces_centers(cells_indices)[source]

Calculate coordinates of cell faces centers.

Parameters:

cells_indices (List[np.ndarray]) – Indices of the cells.

Returns:

coordinates of cell faces centers.

Return type:

np.ndarray

map_grid()[source]

Map pillars (COORD) to axis defined by `MAPAXES’.

Returns:

Grid with updated COORD and MAPAXES fields.

Return type:

CornerPointGrid

minimal_active_bounds()[source]

Get z coordinates of top and bottom bounds of active cells.

property origin

Grid axes origin relative to the map coordinates.

orthogonalize(dimens, only_active=False)[source]

Construct orthogonal grid. Actnum tranfer should be made separately.

Parameters:
  • dimens (tuple, int) – Dimensions of the output orthogonal grid.

  • only_active (bool) – Limits the new grid to active cells.

Returns:

grid – Orthogonal grid.

Return type:

OrthogonalGrid

to_corner_point()[source]

Returns itself.

upscale(factors=(2, 2, 2), actnum_upscale='vote')[source]

Upscale grid according to factors given.

Parameters:
  • factors (tuple, int) – Scale factors along each axis. If int, factors are the same for each axis.

  • actnum_upscale (str) – Method to actnum upscaling. If ‘vote’, upscaled cell is active if majority of finer cells are active. If ‘any’, upscaled cell is active if any of finer cells is active. Default to ‘vote’.

Returns:

grid – Upscaled grid.

Return type:

CornerPointGrid

property xyz

x, y, z coordinates of cells vertices.