porepy.grids.structured module

Module containing classes for structured grids.

Acknowledgement

The implementation of structured grids is in practice a translation of the corresponding functions found in the Matlab Reservoir Simulation Toolbox (MRST) developed by SINTEF ICT.

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

Bases: TensorGrid

Representation of a 2D or 3D Cartesian grid.

The name 'CartGrid' is assigned to each instance.

Parameters
  • nx

    Number of cells in each direction (x, y or z).

    Should be 1d, 2d or 3d. 1d grids can also be specified by a scalar.

  • physdims

    default=None

    Physical dimensions in each direction.

    Can be given as an array with up to 3 entries (for each dimension).

    Can also be given as a dictionary with keys

    • 'xmin', 'xmax',

    • 'ymin', 'ymax' (optional if 1D),

    • 'zmin', 'zmax' (optional if 1D or 2D).

    If None, the number of cells in each direction is used, i.e. the cells will be of unit size.

Return type

Grid

cell_centers: ndarray

An array containing column-wise the centers of all cells with shape=(ambient_dimension, num_cells).

Available after calling compute_geometry().

cell_faces: csc_matrix

An array with shape=(num_faces, num_cells) representing the map from cells to faces bordering respective cell.

Matrix elements have value +-1, where + corresponds to the face normal vector being outwards.

cell_volumes: ndarray

An array containing column-wise the volumes per cell with shape=(num_cells,).

Available after calling compute_geometry().

dim: int

Grid dimension. Should be in {0, 1, 2, 3}.

face_areas: ndarray

Areas of all faces (shape=(num_cells,)). Available after calling compute_geometry().

face_centers: ndarray

Centers of all faces. (shape=(ambient_dimension, num_faces)). Available after calling compute_geometry().

face_nodes: csc_matrix

An array with shape=(num_nodes, num_faces) representing the map from faces to nodes spanning respective face.

Assumes the nodes of each face are ordered according to the right-hand rule.

Note

To use compute_geometry() later, the field face_nodes.indices should store the nodes of each face sorted. face_nodes.indices[face_nodes.indptr[i]:face_nodes.indptr[i+1]] are the nodes of face i, which should be ordered counter-clockwise.

By counter-clockwise we mean as seen from cell cell_faces[i,:] == -1.

Equivalently the nodes will be clockwise as seen from cell cell_faces[i,:] == 1.

Note that operations on the face_nodes matrix (such as converting it to a csr-matrix) may change the ordering of the nodes (face_nodes.indices), which will break compute_geometry().

face_normals: ndarray

An array containing column-wise normal vectors of all faces with shape=(ambient_dimenaion, num_faces).

See also cell_faces.

Available after calling compute_geometry().

frac_num: int

Index of the fracture the grid corresponds to. Take value (0, 1, ...) if the grid corresponds to a fracture, -1 if not.

frac_pairs: ndarray

Indices of faces that are geometrically coinciding, but lay on different side of a lower-dimensional grid.

global_point_ind: ndarray

An array with shape=(num_nodes,) containing indices of each point, assigned during processing of mixed-dimensional grids created by gmsh.

Used to identify points that are geometrically equal, though on different grids.

Could potentially be used to identify such geometrically equal points at a later stage, but there is no guarantee that this will work.

history: list[str]

Information on the formation of the grid, such as the constructor, computations of geometry etc.

name: str

Name assigned to this grid.

nodes: ndarray

An array with shape=(ambient_dimension, num_nodes) containing node coordinates column-wise.

num_cells: int

Number of cells in the grid.

num_faces: int

Number of faces in the grid.

num_nodes: int

Number of nodes in the grid.

parent_cell_ind: ndarray

Index of parent the cell in the parent grid for grids that have refined sub-grids or are sub-grids of larger grids.

Defaults to a mapping to its own index with shape=(num_cells,).

periodic_face_map: ndarray

Index of periodic boundary faces, (shape=(2, num_periodic_faces), dtype=int).

Face index periodic_face_map[0, i] is periodic with face index periodic_face_map[1, i]. This attribute is set with set_periodic_map().

tags: dict[str, numpy.ndarray]

Tags allow to mark subdomains of interest.

The default tags are used to mark fractures, tips and domain boundaries. Tags are used for nodes, as well as faces. User tags can be provided in the constructor.

well_num: int

Index of the well associated to the grid. Takes a value in (0, 1, ..) if the grid corresponds to a well, -1 if not.

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

Bases: Grid

Representation of a grid formed by a tensor product of line point distributions.

For information on attributes and methods, see the documentation of the parent class.

The resulting grid is 1D or 2D or 3D, depending on the number of coordinate lines are provided.

Parameters
  • x – Node coordinates in x-direction.

  • y

    default=None

    Node coordinates in y-direction. If None, the created grid will be 1D.

  • z

    default=None

    Node coordinates in z-direction. If None, the created grid will be 2D.

  • name

    default=None

    Name for the grid. If None, the grid will be called 'TensorGrid'.

Return type

Grid

cart_dims: ndarray

The resulting dimensions of the of the underlying Cartesian grid.

cell_centers: ndarray

An array containing column-wise the centers of all cells with shape=(ambient_dimension, num_cells).

Available after calling compute_geometry().

cell_faces: csc_matrix

An array with shape=(num_faces, num_cells) representing the map from cells to faces bordering respective cell.

Matrix elements have value +-1, where + corresponds to the face normal vector being outwards.

cell_volumes: ndarray

An array containing column-wise the volumes per cell with shape=(num_cells,).

Available after calling compute_geometry().

dim: int

Grid dimension. Should be in {0, 1, 2, 3}.

face_areas: ndarray

Areas of all faces (shape=(num_cells,)). Available after calling compute_geometry().

face_centers: ndarray

Centers of all faces. (shape=(ambient_dimension, num_faces)). Available after calling compute_geometry().

face_nodes: csc_matrix

An array with shape=(num_nodes, num_faces) representing the map from faces to nodes spanning respective face.

Assumes the nodes of each face are ordered according to the right-hand rule.

Note

To use compute_geometry() later, the field face_nodes.indices should store the nodes of each face sorted. face_nodes.indices[face_nodes.indptr[i]:face_nodes.indptr[i+1]] are the nodes of face i, which should be ordered counter-clockwise.

By counter-clockwise we mean as seen from cell cell_faces[i,:] == -1.

Equivalently the nodes will be clockwise as seen from cell cell_faces[i,:] == 1.

Note that operations on the face_nodes matrix (such as converting it to a csr-matrix) may change the ordering of the nodes (face_nodes.indices), which will break compute_geometry().

face_normals: ndarray

An array containing column-wise normal vectors of all faces with shape=(ambient_dimenaion, num_faces).

See also cell_faces.

Available after calling compute_geometry().

frac_num: int

Index of the fracture the grid corresponds to. Take value (0, 1, ...) if the grid corresponds to a fracture, -1 if not.

frac_pairs: ndarray

Indices of faces that are geometrically coinciding, but lay on different side of a lower-dimensional grid.

global_point_ind: ndarray

An array with shape=(num_nodes,) containing indices of each point, assigned during processing of mixed-dimensional grids created by gmsh.

Used to identify points that are geometrically equal, though on different grids.

Could potentially be used to identify such geometrically equal points at a later stage, but there is no guarantee that this will work.

history: list[str]

Information on the formation of the grid, such as the constructor, computations of geometry etc.

name: str

Name assigned to this grid.

nodes: ndarray

An array with shape=(ambient_dimension, num_nodes) containing node coordinates column-wise.

num_cells: int

Number of cells in the grid.

num_faces: int

Number of faces in the grid.

num_nodes: int

Number of nodes in the grid.

parent_cell_ind: ndarray

Index of parent the cell in the parent grid for grids that have refined sub-grids or are sub-grids of larger grids.

Defaults to a mapping to its own index with shape=(num_cells,).

periodic_face_map: ndarray

Index of periodic boundary faces, (shape=(2, num_periodic_faces), dtype=int).

Face index periodic_face_map[0, i] is periodic with face index periodic_face_map[1, i]. This attribute is set with set_periodic_map().

tags: dict[str, numpy.ndarray]

Tags allow to mark subdomains of interest.

The default tags are used to mark fractures, tips and domain boundaries. Tags are used for nodes, as well as faces. User tags can be provided in the constructor.

well_num: int

Index of the well associated to the grid. Takes a value in (0, 1, ..) if the grid corresponds to a well, -1 if not.