pygeon.discretizations.fem.vec_l2 module

Module for the discretizations of the vector L2 space.

class pygeon.discretizations.fem.vec_l2.VecPwPolynomials(keyword='unitary_data')[source]

Bases: VecDiscretization

A class representing an abstract vector piecewise polynomial discretization.

poly_order

Polynomial degree of the basis functions

tensor_order = 1

Vector-valued discretization

base_discr

The scalar discretization method.

assemble_mass_matrix(sd, data=None)[source]

Assembles the mass matrix, using the scalar and tensor weights in data.

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

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

Returns:

The mass matrix.

Return type:

sps.csc_array

assemble_lumped_matrix(sd, data=None)[source]

Assembles the lumped mass matrix, using the scalar and tensor weights in data.

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

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

Returns:

The mass matrix.

Return type:

sps.csc_array

assemble_weighting_matrix(sd, sot)[source]

Assembles the weighting matrix based on a second-order tensor.

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

  • sot (pp.SecondOrderTensor) – The physical scaling parameter. Usually the

  • permeability (inverse of the)

Returns:

The weighting matrix.

Return type:

sps.csc_array

interpolate(sd, func)[source]

Interpolates a vector-valued function onto the finite element space

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

  • func (Callable) – A function that returns the function values at coordinates.

Returns:

The values of the degrees of freedom

Return type:

np.ndarray

local_dofs_of_cell(sd, c, ambient_dim=-1)[source]

Compute the local degrees of freedom (DOFs) of a cell in a vector-valued finite element discretization.

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

  • c (int) – The index of the cell for which the local DOFs are to be computed. ambient_dim (int, optional): The ambient dimension of the space. If not provided, it defaults to the dimension of the grid (sd.dim).

Returns:

An array containing the local DOFs of the specified cell, adjusted for the vector-valued nature of the discretization.

Return type:

np.ndarray

ndof_per_cell(sd)[source]

Computes the number of degrees of freedom (DOF) per cell for the given grid.

This method calculates the total number of DOFs per cell by multiplying the number of DOFs per cell from the base discretization by the spatial dimension of the grid.

Parameters:

sd (pg.Grid) – The grid object representing the spatial discretization.

Returns:

The total number of degrees of freedom per cell.

Return type:

int

get_range_discr_class(dim)[source]

Returns the discretization class for the range of the differential.

Parameters:

dim (int) – The dimension of the range space.

Returns:

The discretization class for the range of the differential.

Return type:

pg.Discretization

assemble_nat_bc(sd, _func, _b_faces)[source]

Assembles the natural boundary condition vector, equal to zero.

Parameters:
  • sd (pg.Grid) – The grid object.

  • func (Callable[[np.ndarray], np.ndarray]) – The function defining the natural boundary condition.

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

Returns:

The assembled natural boundary condition vector.

Return type:

np.ndarray

proj_to_higher_PwPolynomials(sd)[source]

Projects the discretization to +1 order discretization.

Parameters:

sd (pg.Grid) – The grid object.

Returns:

The projection matrix.

Return type:

sps.csc_array

proj_to_lower_PwPolynomials(sd)[source]

Projects the discretization to -1 order discretization.

Parameters:

sd (pg.Grid) – The grid object.

Returns:

The projection matrix.

Return type:

sps.csc_array

eval_at_cell_centers(sd)[source]

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

Parameters:

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

Returns:

The evaluation matrix.

Return type:

sps.csc_array

assemble_broken_grad_matrix(sd)[source]

Assembles the broken (element-wise) gradient matrix for the given grid.

Parameters:

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

Returns:

The assembled broken gradient matrix.

Return type:

sps.csc_array

class pygeon.discretizations.fem.vec_l2.VecPwConstants(keyword='unitary_data')[source]

Bases: VecPwPolynomials

A class representing the discretization using vector piecewise constant functions.

poly_order = 0

Polynomial degree of the basis functions

__init__(keyword='unitary_data')[source]

Initialize the vector discretization class. The base discretization class is pg.PwConstants.

Parameters:

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

Returns:

None

class pygeon.discretizations.fem.vec_l2.VecPwLinears(keyword='unitary_data')[source]

Bases: VecPwPolynomials

A class representing the discretization using vector piecewise linear functions.

poly_order = 1

Polynomial degree of the basis functions

__init__(keyword='unitary_data')[source]

Initialize the vector discretization class. The base discretization class is pg.PwLinears.

Parameters:

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

Returns:

None

class pygeon.discretizations.fem.vec_l2.VecPwQuadratics(keyword='unitary_data')[source]

Bases: VecPwPolynomials

A class representing the discretization using vector piecewise quadratic functions.

poly_order = 2

Polynomial degree of the basis functions

__init__(keyword='unitary_data')[source]

Initialize the vector discretization class. The base discretization class is pg.PwQuadratics.

Parameters:

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

Returns:

None