porepy.numerics.ad.grid_operators module
Ad representation of grid-related quantities needed to write equations. The classes defined here are mainly wrappers that constructs Ad matrices based on grid information.
- class BoundaryCondition(keyword, subdomains, name=None)[source]
Bases:
Operator
Wrapper class for Ad representations of boundary conditions for a given keyword.
- parse(mdg)[source]
Convert the Ad expression into numerical values for the boundary conditions, in the form of an np.ndarray concatenated for all subdomains.
- Parameters:
mdg (
pp.MixedDimensionalGrid
) – Mixed-dimensional grid. The boundary condition will be taken from the data dictionaries with the relevant keyword.- Returns:
Value of boundary conditions.
- Return type:
np.ndarray
- class Divergence(subdomains, dim=1, name=None)[source]
Bases:
Operator
Wrapper class for Ad representations of divergence operators.
- parse(mdg)[source]
Convert the Ad expression into a divergence operators on all relevant subdomains, represented as a sparse block matrix.
- Parameters:
mdg (
pp.MixedDimensionalGrid
) – Not used, but needed for compatibility with the general parsing method for Operators.- Returns:
- Block matrix representation of a divergence operator on
multiple subdomains.
- Return type:
sps.spmatrix
- class Geometry(subdomains, nd, name=None, matrix_names=None)[source]
Bases:
Operator
Wrapper class for Ad representations of grids.
- Parameters:
- cell_volumes
Diagonal ad matrix of cell volumes.
- Type:
pp.ad.Matrix
- face_areas
Diagonal ad matrix of face areas.
- Type:
pp.ad.Matrix
FIXME: Implement parse??
- class MortarProjections(mdg, subdomains, interfaces, dim=1)[source]
Bases:
Operator
Wrapper class to generate projections to and from MortarGrids.
- Parameters:
mdg (pp.MixedDimensionalGrid)
interfaces (list[MortarGrid])
dim (int)
- mortar_to_primary_int
Matrix of projections from the mortar grid to the primary grid. Intended for extensive quantities (so fluxes). Represented as an Ad Matrix operator.
- Type:
pp.ad.Matrix
- mortar_to_primary_avg
Matrix of projections from the mortar grid to the primary grid. Intended for intensive quantities (so pressures). Represented as an Ad Matrix operator.
- Type:
pp.ad.Matrix
- primary_to_mortar_int
Matrix of projections from the primary grid to the mortar grid. Intended for extensive quantities (so fluxes). Represented as an Ad Matrix operator.
- Type:
pp.ad.Matrix
- primary_to_mortar_avg
Matrix of projections from the primary grid to the mortar grid. Intended for intensive quantities (so pressures). Represented as an Ad Matrix operator.
- Type:
pp.ad.Matrix
- mortar_to_secondary_int
Matrix of projections from the mortar grid to the secondary grid. Intended for extensive quantities (so fluxes). Represented as an Ad Matrix operator.
- Type:
pp.ad.Matrix
- mortar_to_secondary_avg
Matrix of projections from the mortar grid to the secondary grid. Intended for intensive quantities (so pressures). Represented as an Ad Matrix operator.
- Type:
pp.ad.Matrix
- secondary_to_mortar_int
Matrix of projections from the secondary grid to the mortar grid. Intended for extensive quantities (so fluxes). Represented as an Ad Matrix operator.
- Type:
pp.ad.Matrix
- secondary_to_mortar_avg
Matrix of projections from the secondary grid to the mortar grid. Intended for intensive quantities (so pressures). Represented as an Ad Matrix operator.
- Type:
pp.ad.Matrix
- sign_of_mortar_sides
Matrix representation that assigns signs to two mortar sides. Needed to implement a jump operator in contact mechanics.
- Type:
pp.Ad.Matrix
- class ParameterArray(param_keyword, array_keyword, subdomains=None, interfaces=None, name=None)[source]
Bases:
Operator
Extract an array from the parameter dictionaries for a given set of subdomains.
Can be used to implement sources, and general arrays to be picked from the parameter array (and thereby could be changed during the simulation, without having to redefine the abstract Ad representation of the equations).
- Parameters:
- parse(mdg)[source]
Convert the Ad expression into numerical values for the scalar sources, in the form of an np.ndarray concatenated for all subdomains.
- Parameters:
mdg (
pp.MixedDimensionalGrid
) – Mixed-dimensional grid. The boundary condition will be taken from the data dictionaries with the relevant keyword.- Returns:
Value of boundary conditions.
- Return type:
np.ndarray
- class ParameterMatrix(param_keyword, array_keyword, subdomains=None, interfaces=None, name=None)[source]
Bases:
ParameterArray
Extract a matrix from the parameter dictionaries for a given set of subdomains.
- Typical use: Parameters which are left multiplied with an ad expression. Note that
array parameters are represented by one diagonal matrix for each grid.
- Parameters:
- parse(mdg)[source]
Convert the Ad expression into numerical values for the scalar sources, in the form of an np.ndarray concatenated for all subdomains.
- Parameters:
mdg (
pp.MixedDimensionalGrid
) – Mixed-dimensional grid. The boundary condition will be taken from the data dictionaries with the relevant keyword.- Returns:
Value of boundary conditions.
- Return type:
sps.spmatrix
- class SubdomainProjections(subdomains, dim=1)[source]
Bases:
Operator
Wrapper class for generating projection to and from subdomains.
One use case in when variables are defined on only some subdomains.
The class should be used through the methods {cell, face}_{projection, restriction}.
See also MortarProjections for projections to and from mortar subdomains.
- cell_prolongation(subdomains)[source]
Construct prolongation from subdomain to global cell quantities.
- Parameters:
subdomains (
List
ofpp.Grid
) – One or several subdomains to which the prolongation should apply.- Returns:
- Matrix operator (in the Ad sense) that represent the
prolongation.
- Return type:
pp.ad.Matrix
- cell_restriction(subdomains)[source]
Construct restrictions from global to subdomain cell quantities.
- Parameters:
subdomains (
List
ofpp.Grid
) – One or several subdomains to which the projection should apply.- Returns:
- Matrix operator (in the Ad sense) that represents the
projection.
- Return type:
pp.ad.Matrix
- face_prolongation(subdomains)[source]
Construct prolongation from subdomain to global face quantities.
- Parameters:
subdomains (
List
ofpp.Grid
) – One or several subdomains to which the prolongation should apply.- Returns:
- Matrix operator (in the Ad sense) that represent the
prolongation.
- Return type:
pp.ad.Matrix
- face_restriction(subdomains)[source]
Construct restrictions from global to subdomain face quantities.
- Parameters:
subdomains (
List
ofpp.Grid
) – One or several subdomains to which the projection should apply.- Returns:
- Matrix operator (in the Ad sense) that represent the
projection.
- Return type:
pp.ad.Matrix
- class Trace(subdomains, dim=1, name=None)[source]
Bases:
Operator
Wrapper class for Ad representations of trace operators and their inverse, that is, mappings between grid cells and faces.
NOTE: The mapping will hit both boundary and interior faces, so the values to be mapped should be carefully filtered (e.g. by combining it with a mortar mapping).
The mapping does not alter signs of variables, that is, the direction of face normal vectors is not accounted for.
- trace
Matrix of trace projections from cells to faces.
- Type:
pp.ad.Matrix
- inv_trace
Matrix of trace projections from faces to cells.
- Type:
pp.ad.Matrix