reservoirflow.grids.RegularCartesian.get_cell_neighbors#

RegularCartesian.get_cell_neighbors(id=None, coords=None, boundary: bool = False, fmt='dict')#

Returns cell neighbors.

This method returns cell neighbors by id or coords. If neighbors are desired by id, then id argument should be used. The same applies coords argument. This method will raise ValueError if none of id or coords arguments were defined or if undefined fmt argument was used. Boundary cells are not allowed.

Warning: passing ndarray of len(shape) > 1 (e.g. coords ndarray) causes a TypeError due to the cache decorator used in this method since multi-dim ndarray is unhashable.

Parameters:
  • id (int, iterable of int) – cell id based on natural order as int. For multiple cells, list of int [id,id,..] or tuple of int (id,id,…).

  • coords (iterable of int, iterable of tuples of int, by default) – None cell coordinates (i,j,k) as a tuple of int. For multiple cells, tuple of tuples of int as ((i,j,k),(i,j,k),..).

  • boundary (bool, optional) – include boundary cells.

  • fmt (str, optional) – output format as str from [‘array’, ‘list’, ‘tuple’, ‘set’, ‘dict’]. Use ‘dict’ to output neighbors in x,y,z directions as keys. Use ‘tuple’ or ‘list’ for list of neighbors when directions are not needed.

Returns:

cell neighbors.

Return type:

iterable

Raises:
  • ValueError – None of id or coords arguments are not defined.

  • ValueError – Unknown str value was used for fmt argument.