porepy.numerics.vem.hybrid module

@author: fumagalli, alessio

class HybridDualVEM(keyword='flow')[source]

Bases: object

Implementation of mixed virtual element method, using hybridization to arrive at a SPD system.

WARNING: The implementation does not follow the newest formulations used in PorePy. Specifically, it does not support mixed-dimensional problems. This may or may not be improved in the future, depending on various factors.

compute_up(g, solution, data)[source]

Return the velocity and pressure computed from the hybrid variables.

Parameters

g : grid, or a subclass, with geometry fields computed. solution : array (g.num_faces) Hybrid solution of the system. data: dictionary to store the data. See self.matrix_rhs for a detaild

description.

Return

u : array (g.num_faces) Velocity at each face. p : array (g.num_cells) Pressure at each cell.

matrix_rhs(g, data)[source]

Return the matrix and righ-hand side for a discretization of a second order elliptic equation using hybrid dual virtual element method. The name of data in the input dictionary (data) are: perm : tensor.SecondOrderTensor

Permeability defined cell-wise. If not given a identity permeability is assumed and a warning arised.

sourcearray (self.g.num_cells)

Scalar source term defined cell-wise. If not given a zero source term is assumed and a warning arised.

bc : boundary conditions (optional) bc_val : dictionary (optional)

Values of the boundary conditions. The dictionary has at most the following keys: ‘dir’ and ‘neu’, for Dirichlet and Neumann boundary conditions, respectively.

Parameters

g : grid, or a subclass, with geometry fields computed. data: dictionary to store the data.

Return

matrix: sparse csr (g.num_faces+g_num_cells, g.num_faces+g_num_cells)

Saddle point matrix obtained from the discretization.

rhs: array (g.num_faces+g_num_cells)

Right-hand side which contains the boundary conditions and the scalar source term.

Examples

b_faces_neu = … # id of the Neumann faces b_faces_dir = … # id of the Dirichlet faces bnd = bc.BoundaryCondition(g, np.hstack((b_faces_dir, b_faces_neu)),

[‘dir’]*b_faces_dir.size + [‘neu’]*b_faces_neu.size)

bnd_val = {‘dir’: fun_dir(g.face_centers[:, b_faces_dir]),

‘neu’: fun_neu(f.face_centers[:, b_faces_neu])}

data = {‘perm’: perm, ‘source’: f, ‘bc’: bnd, ‘bc_val’: bnd_val}

H, rhs = hybrid.matrix_rhs(g, data) l = sps.linalg.spsolve(H, rhs) u, p = hybrid.compute_up(g, l, data) P0u = dual.project_u(g, perm, u)

ndof(g)[source]

Return the number of degrees of freedom associated to the method. In this case number of faces (hybrid dofs).

Parameter

g: grid, or a subclass.

Return

dof: the number of degrees of freedom.