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
- 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()
.
- face_areas: ndarray
Areas of all faces
(shape=(num_cells,))
. Available after callingcompute_geometry()
.
- face_centers: ndarray
Centers of all faces.
(shape=(ambient_dimension, num_faces))
. Available after callingcompute_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 fieldface_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 breakcompute_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.
- nodes: ndarray
An array with
shape=(ambient_dimension, num_nodes)
containing node coordinates column-wise.
- 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 indexperiodic_face_map[1, i]
. This attribute is set withset_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.
- 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
- 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()
.
- face_areas: ndarray
Areas of all faces
(shape=(num_cells,))
. Available after callingcompute_geometry()
.
- face_centers: ndarray
Centers of all faces.
(shape=(ambient_dimension, num_faces))
. Available after callingcompute_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 fieldface_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 breakcompute_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.
- nodes: ndarray
An array with
shape=(ambient_dimension, num_nodes)
containing node coordinates column-wise.
- 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 indexperiodic_face_map[1, i]
. This attribute is set withset_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.