porepy.models.geometry module
Geometry definition for simulation setup.
- class ModelGeometry[source]
Bases:
object
This class provides geometry related methods and information for a simulation model.
- basis(grids, dim)[source]
Return a cell-wise basis for all subdomains.
The basis is represented as a list of matrices, each of which represents a basis function. The individual matrices have shape
Nc * dim, Nc
whereNc
is the total number of cells in the subdomains.Examples
To extend a cell-wise scalar to a vector field, use
sum([e_i for e_i in basis(subdomains)])
. To restrict to a vector in the tangential direction only, usesum([e_i for e_i in basis(subdomains, dim=nd-1)])
See also
e_i()
for the construction of a single basis function.normal_component()
for the construction of a restriction to thenormal component of a vector only.
tangential_component()
for the construction of a restriction to thetangential component of a vector only.
- domain_boundary_sides(sd, tol=1e-10)[source]
Obtain indices of the faces lying on the sides of the domain boundaries.
The method is primarily intended for box-shaped domains. However, it can also be applied to non-box-shaped domains (e.g., domains with perturbed boundary nodes) provided tol is tuned accordingly.
- Parameters:
- Returns:
all_bf (np.ndarray of int): indices of the boundary faces.
east (np.ndarray of bool): flags of the faces lying on the East side.
west (np.ndarray of bool): flags of the faces lying on the West side.
north (np.ndarray of bool): flags of the faces lying on the North side.
south (np.ndarray of bool): flags of the faces lying on the South side.
top (np.ndarray of bool): flags of the faces lying on the Top side.
bottom (np.ndarray of bool): flags of the faces lying on Bottom side.
- Return type:
NamedTuple containing the domain boundary sides. Available attributes are
Examples
model = pp.SinglePhaseFlow({}) model.prepare_simulation() sd = model.mdg.subdomains()[0] sides = model.domain_boundary_sides(sd) # Access north faces using index or name is equivalent: north_by_index = sides[3] north_by_name = sides.north assert all(north_by_index == north_by_name)
- e_i(grids, *, i, dim)[source]
Return a cell-wise basis function in a specified dimension.
It is assumed that the grids are embedded in a space of dimension dim and aligned with the coordinate axes, that is, the reference space of the grid. Moreover, the grid is assumed to be planar.
Example
For a grid with two cells, and with i=1 and dim=3, the returned basis will be (aftert conversion to a numpy array) .. code-block:: python
- array([[0., 0.],
[1., 0.], [0., 0.], [0., 0.], [0., 1.], [0., 0.]])
See also
basis()
for the construction of a full basis.- Parameters:
grids (Sequence[Grid | MortarGrid]) – List of grids on which the basis vector is defined.
dim (int) – Dimension of the functions.
i (int) – Index of the basis function. Note: Counts from 0.
- Returns:
- Ad representation of a matrix with the basis functions as
columns.
- Return type:
pp.ad.Matrix
- Raises:
ValueError – If dim is smaller than the dimension of the mixed-dimensional.
ValueError – If i is larger than dim.
- interfaces_to_subdomains(interfaces)[source]
Subdomain neighbours of interfaces.
- Parameters:
interfaces (list[MortarGrid]) – List of interfaces for which to find subdomains.
- Returns:
Unique list of all subdomains neighbouring any of the interfaces. The subdomains are sorted according to their index as defined by the mixed-dimensional grid.
- Return type:
- internal_boundary_normal_to_outwards(subdomains, *, dim)[source]
Obtain a vector for flipping normal vectors on internal boundaries.
For a list of subdomains, check if the normal vector on internal boundaries point into the internal interface (e.g., into the fracture), and if so, flip the normal vector. The flipping takes the form of an operator that multiplies the normal vectors of all faces on fractures, leaves internal faces (internal to the subdomain proper, that is) unchanged, but flips the relevant normal vectors on subdomain faces that are part of an internal boundary.
Currently, this is a helper method for the computation of outward normals in
outwards_internal_boundary_normals()
. Other usage is allowed, but one is adviced to carefully consider subdomain lists when combining this with other operators.
- local_coordinates(subdomains)[source]
Ad wrapper around tangential_normal_projections for fractures.
- mesh_arguments()[source]
Mesh arguments for md-grid creation.
- Returns:
- Dictionary of meshing arguments compatible with
FractureNetwork.mesh() method.
- Return type:
mesh_args
- normal_component(subdomains)[source]
Compute the normal component of a vector field.
The normal space is defined according to the local coordinates of the subdomains, with the normal space defined by final component, e.g., number self.nd-1 (zero offset). of the cell-wise vector. It is assumed that the components of a vector are stored with a dimension-major ordering (the dimension varies fastest).
See also
e_i()
for the definition of the basis functions.tangential_component()
for the definition of the tangential space.- Parameters:
subdomains (list[Grid]) – List of grids on which the vector field is defined.
- Returns:
Matrix extracting normal component of the vector field and expressing it in normal basis. The size of the matrix is (Nc, Nc * self.nd), where Nc is the total number of cells in the subdomains.
- Return type:
- outwards_internal_boundary_normals(interfaces, *, unitary)[source]
Compute outward normal vectors on internal boundaries.
- Parameters:
interfaces (list[MortarGrid]) – List of interfaces.
unitary (bool) – If True, return unit vectors, i.e. normalize by face area.
- Returns:
Operator computing outward normal vectors on internal boundaries. Evaluated shape (num_intf_cells * dim, num_intf_cells * dim).
- Return type:
- set_md_grid()[source]
Create the mixed-dimensional grid.
A unit square grid with no fractures is assigned by default if self.fracture_network contains no fractures. Otherwise, the network’s mesh method is used.
- The method assigns the following attributes to self:
mdg (pp.MixedDimensionalGrid): The produced grid bucket. box (dict): The bounding box of the domain, defined through minimum and
maximum values in each dimension.
- Return type:
None
- subdomain_projections(dim)[source]
Return the projection operators for all subdomains in md-grid.
The projection operators restrict or prolong a dim-dimensional quantity from the full set of subdomains to any subset. Projection operators are constructed once and then stored. If you need to use projection operators based on a different set of subdomains, please construct them yourself. Alternatively, compose a projection from subset A to subset B as
P_A_to_B = P_full_to_B * P_A_to_full.
- Parameters:
dim (int) – Dimension of the quantities to be projected.
- Returns:
Projection operator.
- Return type:
proj
- subdomains_to_interfaces(subdomains, codims)[source]
Interfaces neighbouring any of the subdomains.
- Parameters:
- Returns:
Unique list of all interfaces neighboring any of the subdomains. Interfaces are sorted according to their index, as defined by the mixed-dimensional grid.
- Return type:
- tangential_component(subdomains)[source]
Compute the tangential component of a vector field.
The tangential space is defined according to the local coordinates of the subdomains, with the tangential space defined by the first self.nd components of the cell-wise vector. It is assumed that the components of the vector are stored with a dimension-major ordering (the dimension varies fastest).
- wrap_grid_attribute(grids, attr, *, dim, inverse=False)[source]
Wrap a grid attribute as an ad matrix.
- Parameters:
grids (Sequence[Grid | MortarGrid]) – List of grids on which the property is defined.
attr (str) – Grid attribute to wrap. The attribute should be a ndarray and will be flattened if it is not already one dimensional.
dim (int) – Dimensions to include for vector attributes. Intended use is to limit the number of dimensions for a vector attribute, e.g. to exclude the z-component of a vector attribute in 2d, to acieve compatibility with code which is explicitly 2d (e.g. fv discretizations).
inverse (bool) – If True, the inverse of the attribute will be wrapped. This is a hack around the fact that the Ad framework does not support division. FIXME: Remove when ad supports division.
- Returns:
The property wrapped as an ad matrix, with the wrapped attribute on the diagonal.
- Raises:
ValueError – If one of the grids does not have the attribute.
ValueError – If the attribute is not a ndarray.
- Return type:
- domain_bounds: dict[str, float]
Box-shaped domain. Set by the method
set_md_grid()
.
- fracture_network: FractureNetwork2d | FractureNetwork3d
Representation of fracture network including intersections.
- mdg: MixedDimensionalGrid
Mixed-dimensional grid. Set by the method
set_md_grid()
.
- nd: int
Ambient dimension of the problem. Set by the method
set_geometry()
- well_network: WellNetwork3d
Well network.