pygeon.discretizations.vem.hdiv module

Module for the discretizations of the H(div) space.

class pygeon.discretizations.vem.hdiv.VRT0(keyword='unitary_data')[source]

Bases: RT0

VRT0 class for virtual lowest order Raviart-Thomas discretization.

Each degree of freedom is the integral over a mesh face.

poly_order = 1

Polynomial degree of the basis functions

tensor_order = 1

Vector-valued discretization

__init__(keyword='unitary_data')[source]

Initialize the MVEM class.

Parameters:

keyword (str) – The keyword for the discretization. Default is pg.UNITARY_DATA.

Returns:

None

assemble_mass_matrix(sd, data=None)[source]

Assembles the mass matrix

Parameters:
  • sd (pg.Grid) – Grid object or a subclass.

  • data (dict | None) – Optional dictionary with physical parameters for scaling.

Returns:

The mass matrix.

Return type:

sps.csc_array

eval_at_cell_centers(sd)[source]

Assembles the matrix for evaluating the solution at the cell centers.

Parameters:

sd (pg.Grid) – Grid object or a subclass.

Returns:

The evaluation matrix.

Return type:

sps.csc_array

class pygeon.discretizations.vem.hdiv.VBDM1(keyword='unitary_data')[source]

Bases: BDM1

Virtual Element Method (VEM) based on the BDM1 (Brezzi-Douglas-Marini) discretization for the H(div) space.

This class implements the VEM discretization for the H(div) space. It provides methods for assembling the mass matrix, projecting to VRT0 space, assembling the differential matrix, evaluating at cell centers, interpolating a function, assembling the natural boundary condition term, and more.

poly_order = 1

Polynomial degree of the basis functions

tensor_order = 1

Vector-valued discretization

assemble_mass_matrix(sd, _data=None)[source]

Computes the mass matrix for the Virtual Element Method (VEM).

Parameters:
  • sd (pg.Grid) – The grid object representing the computational domain.

  • data (dict | None) – Optional data dictionary.

Returns:

The assembled mass matrix.

Return type:

sps.csc_array

Notes

The mass matrix is computed using the VEM approach. The mass matrix is a sparse matrix in compressed sparse column (CSC) format.

proj_to_VRT0(sd)[source]

Project the degrees of freedom to the space VRT0.

Parameters:

sd (pg.Grid) – The grid on which to project the degrees of freedom.

Returns:

The projection matrix.

Return type:

sps.csc_array

proj_from_RT0(sd)[source]

Project the RT0 finite element space onto the H(div) finite element space.

Parameters:

sd (pg.Grid) – The grid on which the projection is performed.

Returns:

The projection matrix.

Return type:

sps.csc_array

Raises:

NotImplementedError – This method is not implemented and should be overridden in a subclass.

assemble_diff_matrix(sd)[source]

Assembles the matrix corresponding to the differential operator for the H(div) space.

Parameters:

sd (pg.Grid) – The grid or a subclass.

Returns:

The differential matrix.

Return type:

sps.csc_array

eval_at_cell_centers(sd)[source]

Evaluate the function at the cell centers of the given grid.

Parameters:

sd (pg.Grid) – The grid on which to evaluate the function.

Returns:

The evaluated function values at the cell centers.

Return type:

sps.csc_array

Raises:

NotImplementedError – This method is not implemented and should be overridden in a subclass.

interpolate(sd, func)[source]

Interpolates a function onto the given grid.

Parameters:
  • sd (pg.Grid) – The grid onto which the function will be interpolated.

  • func (Callable[[np.ndarray], np.ndarray]) – The function to be interpolated.

Returns:

The interpolated values on the grid.

Return type:

np.ndarray

Raises:

NotImplementedError – This method is not implemented and should be overridden in a subclass.

assemble_nat_bc(sd, func, b_faces)[source]

Assembles the natural boundary condition term (n dot q, func)_Gamma

Parameters:
  • sd (pg.Grid) – The grid object representing the computational domain.

  • func (Callable[[np.ndarray], np.ndarray]) – The function used to evaluate the values on the boundary.

  • b_faces (np.ndarray) – The array of boundary faces.

Returns:

The assembled natural boundary condition term.

Return type:

np.ndarray

get_dof_enumeration(sd)[source]

Get the degree of freedom enumeration for a given grid.

Parameters:

sd (pg.Grid) – The grid for which to compute the degree of freedom enumeration.

Returns:

The degree of freedom enumeration.

Return type:

sps.csc_array

assemble_lumped_matrix(sd, data=None)[source]

Assembles the lumped matrix for the given grid and data.

Parameters:
  • sd (pg.Grid) – The grid for which the lumped matrix is assembled.

  • data (dict | None) – Optional data required for the assembly.

Returns:

The assembled lumped matrix.

Return type:

sps.csc_array

Raises:

NotImplementedError – This method is not implemented and should be overridden in a subclass.