porepy.numerics.vem.dual_elliptic module

Module contains common functionalities for discretization based on the mixed variational formulation.

class DualElliptic(keyword, name)[source]

Bases: EllipticDiscretization

Parent class for methods based on the mixed variational form of the elliptic equation. The class should not be used by itself, but provides a sheared implementation of central methods.

Known subclasses that can be used for actual discretization are MVEM and RT0.

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

Abstract method. 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.

  • sd (Grid)

  • intf (MortarGrid)

Return type:

None

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:
  • 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.

  • grid_swap (boolean) – If True, the grid g is identified with the @ secondary side of the mortar grid in data_adge.

  • 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.

  • intf (MortarGrid)

Return type:

None

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]

Abstract method. 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:
  • 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.

  • sd (Grid)

  • intf (MortarGrid)

Return type:

None

assemble_int_bound_pressure_trace_between_interfaces(g, data_grid, data_primary_edge, data_secondary_edge, cc, matrix, rhs)[source]

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

No contribution for this method.

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

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

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

  • data_secondary_edge (dictionary) – Data dictionary for the secondary edge in the mixed-dimensional 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.

Return type:

None

assemble_int_bound_pressure_trace_rhs(sd, data, 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:
  • 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.

  • sd (Grid)

  • intf (MortarGrid)

Return type:

None

assemble_matrix(g, data)[source]

Assemble matrix from an existing discretization.

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

  • data (dictionary) – With data stored.

  • g (Grid)

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_neumann_robin(sd, data, M, bc_weight=False)[source]

Impose Neumann and Robin boundary discretization on an already assembled system matrix.

Parameters:
Return type:

tuple[csr_matrix, int]

assemble_rhs(sd, data, bc_weight=1.0)[source]

Return the righ-hand side for a discretization of a second order elliptic equation.

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

  • data (dictionary) – With data stored.

  • bc_weight (float) – to use the infinity norm of the matrix to impose the boundary conditions. Default 1.

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.

Methods based on a mixed variational form need this function to implement essential boundary conditions.

The discretization matrix should be modified in place.

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.

  • self_ind (int) – Index in local block system of this grid and variable.

  • sd (Grid)

  • intf (MortarGrid)

  • data_edge (dict)

Return type:

None

extract_flux(sd, solution_array, data)[source]

Extract the velocity from a dual virtual element solution.

Parameters

sd : grid, or a subclass, with geometry fields computed. up : array (sd.num_faces+sd.num_cells)

Solution, stored as [velocity,pressure]

data: data dictionary associated with the grid.

Unused, but included for consistency reasons.

Return

uarray (sd.num_faces)

Velocity at each face.

Parameters:
Return type:

ndarray

extract_pressure(sd, solution_array, data)[source]

Extract the pressure from a dual virtual element solution.

Parameters

sd : grid, or a subclass, with geometry fields computed. solution_array : array (sd.num_faces + sd.num_cells)

Solution, stored as [velocity,pressure]

data: data dictionary associated with the grid.

Unused, but included for consistency reasons.

Return

parray (sd.num_cells)

Pressure at each cell.

Parameters:
Return type:

ndarray

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

project_flux(sd, u, data)[source]

Project the velocity computed with a dual solver to obtain a piecewise constant vector field, one triplet for each cell.

We assume the following two sub-dictionaries to be present in the data dictionary:

matrix_dictionary, for storage of discretization matrices.

Stored in data[pp.DISCRETIZATION_MATRICES][self.keyword] with matrix named self.vector_proj_key and constructed in the discretize method.

Parameters

sd : grid, or a subclass, with geometry fields computed. u : array (sd.num_faces) Velocity at each face. data: data of the current grid.

Return

P0u : ndarray (3, sd.num_faces) Velocity at each cell.

Parameters:
Return type:

ndarray

project_flux(mdg, discr, flux, P0_flux, mortar_key='mortar_solution')[source]

Save in the grid bucket a piece-wise vector representation of the flux for each grid.

Parameters

mdg: the grid bucket discr: discretization class flux: identifier of the flux, already split, in the grid bucket P0_flux: identifier of the reconstructed flux which will be added to the grid bucket. mortar_key (optional): identifier of the mortar variable, already split, in the

grid bucket. The default value is “mortar_solution”.

Parameters:
Return type:

None