porepy.utils.grid_utils module
Module contains various utility functions for working with grids.
- star_shape_cell_centers(g, as_nan=False)[source]
For a given grid compute the star shape center for each cell. The algorithm computes the half space intersections of the spaces defined by the cell faces and the face normals by using the method half_space_interior_point. half_space_pt, of the spaces defined by the cell faces and the face normals. This is a wrapper method that operates on a grid.
Parameters
- g: pp.Grid
the grid
- as_nan: bool, optional
- Decide whether to return nan as the new center for cells which are not
star-shaped. Otherwise, an exception is raised (default behaviour).
Returns
- np.ndarray
The new cell centers.
- switch_sign_if_inwards_normal(g, nd, faces)[source]
Construct a matrix that changes sign of quantities on faces with a normal that points into the grid.
- Parameters
g (
pp.Grid
) – Grid.nd (
int
) – Number of quantities per face; this will for instance be the number of components in a face-vector.faces (
np.array-like of ints
) – Index for which faces to be considered. Should only contain boundary faces.
- Returns
- Diagonal matrix which switches the sign of faces if the
normal vector of the face points into the grid g. Faces not considered will have a 0 diagonal term. If nd > 1, the first nd rows are associated with the first face, then nd elements of the second face etc.
- Return type
sps.dia_matrix