porepy.numerics.fv.fv_elliptic module

Module contains superclass for mpfa and tpfa.

class EllipticDiscretizationZeroPermeability(keyword)[source]

Bases: FVElliptic

Specialized discretization for domains with zero tangential permeability.

Intended usage is to impose full continuity conditions between domains of higher dimensions separated by a lower-dimensional domain (think two intersecting fractures), in cases where one does not want to eliminate the lower-dimensional domain from the MixedDimensionalGrid. The class is designed to interact with the class FluxPressureContinuity. Wider usage is possible, but be cautious.

The subclassing from FVElliptic was convenient, but other options could also have worked.

NOTICE: There seems no point in assigning this method as the higher-dimensional discretization. Accordingly, the methods for assembly of interface contributions from the primary side of a mortar grid are delibierately designed to fail.

assemble_int_bound_flux(sd, data, data_edge, cc, matrix, rhs, self_ind, use_secondary_proj=False)[source]

Assemble the contribution from an internal boundary, manifested as a flux boundary condition.

This method should not be used for the zero-permeability case; it would require a flux in the higher-dimensional grid. Therefore raise an error if this method is invoked.

Parameters
  • g (Grid) – Grid which the condition should be imposed on.

  • data (dictionary) – Data dictionary for the node in the mixed-dimensional grid.

  • data_edge (dictionary) – Data dictionary for the edge in the mixed-dimensional grid.

  • cc (block matrix, 3x3) – Block matrix for the coupling condition. The first and second rows and columns are identified with the primary and secondary side; the third belongs to the edge variable. The discretization of the relevant term is done in-place in cc.

  • matrix (block matrix 3x3) – Discretization matrix for the edge and the two adjacent nodes.

  • rhs (block_array 3x1) – Right hand side contribution for the edge and the two adjacent nodes.

  • self_ind (int) – Index in cc and matrix associated with this node. Should be either 1 or 2.

  • use_secondary_proj (boolean) – If True, the secondary side projection operator is used. Needed for periodic boundary conditions.

assemble_int_bound_pressure_trace(sd, data, data_edge, cc, matrix, rhs, self_ind, use_secondary_proj=False)[source]

Assemble the contribution from an internal boundary, manifested as a condition on the boundary pressure.

This method should not be used for the zero-permeability case; it would require a flux in the higher-dimensional grid. Therefore raise an error if this method is invoked.

Parameters
  • g (Grid) – Grid which the condition should be imposed on.

  • data (dictionary) – Data dictionary for the node in the mixed-dimensional grid.

  • data_edge (dictionary) – Data dictionary for the edge in the mixed-dimensional grid.

  • cc (block matrix, 3x3) – Block matrix for the coupling condition. The first and second rows and columns are identified with the primary and secondary side; the third belongs to the edge variable. The discretization of the relevant term is done in-place in cc.

  • matrix (block matrix 3x3) – Discretization matrix for the edge and the two adjacent nodes.

  • rhs (block_array 3x1) – Right hand side contribution for the edge and the two adjacent nodes.

  • self_ind (int) – Index in cc and matrix associated with this node. Should be either 1 or 2.

  • use_secondary_proj (boolean) – If True, the secondary side projection operator is used. Needed for periodic boundary conditions.

assemble_matrix(sd, data)[source]

Assemble system matrix. Will be zero matrix of appropriate size.

Parameters
  • g (Grid) – Computational grid, with geometry fields computed.

  • data (dictionary) – With data stored.

Returns

Zero matrix.

Return type

scipy.sparse.csr_matrix

assemble_rhs(sd, data)[source]

Assemble right hand side vector. Will be zero vector of appropriate size.

Parameters
  • g (Grid) – Computational grid, with geometry fields computed.

  • data (dictionary) – With data stored.

Returns

Zero vector.

Return type

np.array

discretize(sd, data)[source]

Formal discretization method - nothing to do here.

Args

g (pp.Grid): grid, or a subclass. data (dict).

class FVElliptic(keyword)[source]

Bases: EllipticDiscretization

Superclass for finite volume discretizations of the elliptic equation.

Should not be used by itself, instead use a subclass that implements an actual discretization method. Known subclasses are Tpfa and Mpfa.

assemble_int_bound_flux(sd, data, intf, data_edge, cc, matrix, rhs, self_ind, use_secondary_proj=False)[source]

Assemble the contribution from an internal boundary, manifested as a flux boundary condition.

The intended use is when the internal boundary is coupled to another node in a mixed-dimensional method. Specific usage depends on the interface condition between the nodes; this method will typically be used to impose flux continuity on a higher-dimensional domain.

Implementations of this method will use an interplay between the grid on the node and the mortar grid on the relevant edge.

Parameters
  • g (Grid) – Grid which the condition should be imposed on.

  • data (dictionary) – Data dictionary for the node in the mixed-dimensional grid.

  • data_edge (dictionary) – Data dictionary for the edge in the mixed-dimensional grid.

  • cc (block matrix, 3x3) – Block matrix for the coupling condition. The first and second rows and columns are identified with the primary and secondary side; the third belongs to the edge variable. The discretization of the relevant term is done in-place in cc.

  • matrix (block matrix 3x3) – Discretization matrix for the edge and the two adjacent nodes.

  • rhs (block_array 3x1) – Right hand side contribution for the edge and the two adjacent nodes.

  • self_ind (int) – Index in cc and matrix associated with this node. Should be either 1 or 2.

  • use_secondary_proj (boolean) – If True, the secondary side projection operator is used. Needed for periodic boundary conditions.

assemble_int_bound_pressure_cell(sd, data, intf, data_edge, cc, matrix, rhs, self_ind)[source]

Abstract method. Assemble the contribution from an internal boundary, manifested as a condition on the cell pressure.

The intended use is when the internal boundary is coupled to another node in a mixed-dimensional method. Specific usage depends on the interface condition between the nodes; this method will typically be used to impose flux continuity on a lower-dimensional domain.

Implementations of this method will use an interplay between the grid on the node and the mortar grid on the relevant edge.

Parameters
  • g (Grid) – Grid which the condition should be imposed on.

  • data (dictionary) – Data dictionary for the node in the mixed-dimensional grid.

  • data_edge (dictionary) – Data dictionary for the edge in the mixed-dimensional grid.

  • cc (block matrix, 3x3) – Block matrix for the coupling condition. The first and second rows and columns are identified with the primary and secondary side; the third belongs to the edge variable. The discretization of the relevant term is done in-place in cc.

  • matrix (block matrix 3x3) – Discretization matrix for the edge and the two adjacent nodes.

  • rhs (block_array 3x1) – Right hand side contribution for the edge and the two adjacent nodes.

  • self_ind (int) – Index in cc and matrix associated with this node. Should be either 1 or 2.

assemble_int_bound_pressure_trace(sd, data, intf, data_edge, cc, matrix, rhs, self_ind, use_secondary_proj=False, assemble_matrix=True, assemble_rhs=True)[source]

Assemble the contribution from an internal boundary, manifested as a condition on the boundary pressure.

The intended use is when the internal boundary is coupled to another node in a mixed-dimensional method. Specific usage depends on the interface condition between the nodes; this method will typically be used to impose flux continuity on a higher-dimensional domain.

Implementations of this method will use an interplay between the grid on the node and the mortar grid on the relevant edge.

Parameters
  • sd (Grid) – Grid which the condition should be imposed on.

  • data (dictionary) – Data dictionary for the node in the mixed-dimensional grid.

  • data_edge (dictionary) – Data dictionary for the edge in the mixed-dimensional grid.

  • cc (block matrix, 3x3) – Block matrix for the coupling condition. The first and second rows and columns are identified with the primary and secondary side; the third belongs to the edge variable. The discretization of the relevant term is done in-place in cc.

  • matrix (block matrix 3x3) – Discretization matrix for the edge and the two adjacent nodes.

  • rhs (block_array 3x1) – Right hand side contribution for the edge and the two adjacent nodes.

  • self_ind (int) – Index in cc and matrix associated with this node. Should be either 1 or 2.

  • use_secondary_proj (boolean) – If True, the secondary side projection operator is used. Needed for periodic boundary conditions.

assemble_int_bound_pressure_trace_between_interfaces(sd, data_grid, proj_primary, proj_secondary, cc, matrix, rhs)[source]

Assemble the contribution from an internal boundary, manifested as a condition on the boundary pressure.

Parameters
  • g (Grid) – Grid which the condition should be imposed on.

  • data_grid (dictionary) – Data dictionary for the node in the mixed-dimensional grid.

  • proj_primary (sparse matrix) – Pressure projection from the higher-dim grid to the primary mortar grid.

  • proj_secondary (sparse matrix) – Flux projection from the secondary mortar grid to the main grid.

  • cc (block matrix, 3x3) – Block matrix of size 3 x 3, whwere each block represents coupling between variables on this interface. Index 0, 1 and 2 represent the primary grid, the primary and secondary interface, respectively.

  • matrix (block matrix 3x3) – Discretization matrix for the edge and the two adjacent nodes.

  • rhs (block_array 3x1) – Block matrix of size 3 x 1, representing the right hand side of this coupling. Index 0, 1 and 2 represent the primary grid, the primary and secondary interface, respectively.

assemble_int_bound_pressure_trace_rhs(sd, data, intf, data_edge, cc, rhs, self_ind, use_secondary_proj=False)[source]

Assemble the rhs contribution from an internal boundary, manifested as a condition on the boundary pressure.

For details, see self.assemble_int_bound_pressure_trace()

Parameters
  • g (Grid) – Grid which the condition should be imposed on.

  • data (dictionary) – Data dictionary for the node in the mixed-dimensional grid.

  • data_edge (dictionary) – Data dictionary for the edge in the mixed-dimensional grid.

  • cc (block matrix, 3x3) – Block matrix for the coupling condition. The first and second rows and columns are identified with the primary and secondary side; the third belongs to the edge variable. The discretization of the relevant term is done in-place in cc.

  • matrix (block matrix 3x3) – Discretization matrix for the edge and the two adjacent nodes.

  • rhs (block_array 3x1) – Right hand side contribution for the edge and the two adjacent nodes.

  • self_ind (int) – Index in cc and matrix associated with this node. Should be either 1 or 2.

  • use_secondary_proj (boolean) – If True, the secondary side projection operator is used. Needed for periodic boundary conditions.

assemble_int_bound_source(sd, data, intf, data_edge, cc, matrix, rhs, self_ind)[source]

Abstract method. Assemble the contribution from an internal boundary, manifested as a source term.

The intended use is when the internal boundary is coupled to another node in a mixed-dimensional method. Specific usage depends on the interface condition between the nodes; this method will typically be used to impose flux continuity on a lower-dimensional domain.

Implementations of this method will use an interplay between the grid on the node and the mortar grid on the relevant edge.

Parameters
  • sd (Grid) – Grid which the condition should be imposed on.

  • data (dictionary) – Data dictionary for the node in the mixed-dimensional grid.

  • data_edge (dictionary) – Data dictionary for the edge in the mixed-dimensional grid.

  • cc (block matrix, 3x3) – Block matrix for the coupling condition. The first and second rows and columns are identified with the primary and secondary side; the third belongs to the edge variable. The discretization of the relevant term is done in-place in cc.

  • matrix (block matrix 3x3) – Discretization matrix for the edge and the two adjacent nodes.

  • rhs (block_array 3x1) – Right hand side contribution for the edge and the two adjacent nodes.

  • self_ind (int) – Index in cc and matrix associated with this node. Should be either 1 or 2.

assemble_matrix(sd, data)[source]

Return the matrix for a discretization of a second order elliptic equation using a FV method.

Parameters
  • sd (pp.Grid) – Computational grid, with geometry fields computed.

  • data (dictionary) – With data stored.

Returns

System matrix of this discretization. The

size of the matrix will depend on the specific discretization.

Return type

scipy.sparse.csr_matrix

assemble_matrix_rhs(sd, data)[source]

Return the matrix and right-hand side for a discretization of a second order elliptic equation.

Parameters
  • sd (pp.Grid) – Computational grid, with geometry fields computed.

  • data (dictionary) – With data stored.

Returns

System matrix of this discretization. The size of

the matrix will depend on the specific discretization.

np.ndarray: Right-hand side vector with representation of boundary

conditions. The size of the vector will depend on the discretization.

Return type

scipy.sparse.csr_matrix

assemble_rhs(sd, data)[source]

Return the right-hand side for a discretization of a second order elliptic equation using a finite volume method.

Parameters
  • sd (Grid) – Computational grid, with geometry fields computed.

  • data (dictionary) – With data stored.

Returns

Right hand side vector with representation of boundary

conditions. The size of the vector will depend on the discretization.

Return type

np.ndarray

enforce_neumann_int_bound(sd, intf, data_edge, matrix, self_ind)[source]

Enforce Neumann boundary conditions on a given system matrix.

The method is void for finite volume approaches, but is implemented to be compatible with the general framework.

Parameters
  • g (Grid) – On which the equation is discretized

  • data (dictionary) – Of data related to the discretization.

  • matrix (scipy.sparse.matrix) – Discretization matrix to be modified.

  • intf (MortarGrid) –

extract_flux(sd, solution_array, data)[source]

Extract the flux related to a solution.

The flux is computed from the discretization and the given pressure solution.

Parameters
  • sd (pp.Grid) – To which the solution array belongs.

  • solution_array (np.array) – Solution for this grid obtained from either a mono-dimensional or a mixed-dimensional problem. Will correspond to the pressure solution.

  • data (dictionary) – Data dictionary associated with the grid.

Returns

Flux vector.

Return type

np.array (g.num_faces)

extract_pressure(sd, solution_array, data)[source]

Extract the pressure part of a solution. The method is trivial for finite volume methods, with the pressure being the only primary variable.

Parameters
  • sd (pp.Grid) – To which the solution array belongs.

  • solution_array (np.array) – Solution for this grid obtained from either a mono-dimensional or a mixed-dimensional problem.

  • data (dictionary) – Data dictionary associated with the grid. Not used, but included for consistency reasons.

Returns

Pressure solution vector. Will be identical

to solution_array.

Return type

np.array (g.num_cells)

ndof(sd)[source]

Return the number of degrees of freedom associated to the method.

Parameters

sd (pp.Grid) – A grid.

Returns

The number of degrees of freedom.

Return type

int