pygeon.discretizations.fem.symmat_l2 module

Module for the discretizations of the symmetric matrix L2 space.

class pygeon.discretizations.fem.symmat_l2.SymMatPwPolynomials(keyword='unitary_data')[source]

Bases: Discretization

Base class for symmetric matrix-valued piecewise polynomial discretizations.

poly_order

Polynomial degree of the basis functions

tensor_order = 2

Matrix-valued discretization

__init__(keyword='unitary_data')[source]

Initialize the symmetric matrix discretization class. The base discretization class is pg.MatPwPolynomials.

Parameters:

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

ndof(sd)[source]

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

Parameters:

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

Returns:

The number of degrees of freedom.

Return type:

int

ndof_per_cell(sd)[source]

Returns the number of degrees of freedom for each cell in the symmetric matrix-valued piecewise polynomial discretization.

Parameters:

sd (pg.Grid) – The grid.

Returns:

The number of degrees of freedom per cell.

Return type:

int

proj_to_PwPolynomials(sd)[source]

Returns the projection matrix from the symmetric matrix-valued piecewise polynomial space to the full matrix-valued piecewise polynomial space.

Parameters:

sd (pg.Grid) – The grid.

Returns:

The projection matrix.

Return type:

sps.csc_array

assemble_symmetrizing_matrix(sd)[source]

Returns the projection matrix from the full matrix-valued piecewise polynomial space to the symmetric matrix-valued piecewise polynomial space. Off-diagonal entries are averaged: sym_{ij} = (full_{ij} + full_{ji}) / 2. This is the left inverse of proj_to_PwPolynomials, meaning that assemble_symmetrizing_matrix @ proj_to_PwPolynomials = I

Parameters:

sd (pg.Grid) – The grid.

Returns:

The projection matrix.

Return type:

sps.csc_array

proj_to_higher_PwPolynomials(sd)[source]

Projects the discretization to +1 order discretization in the space of matrix valued piecewise polynomials, without symmetrization.

Parameters:

sd (pg.Grid) – The grid object.

Returns:

The projection matrix.

Return type:

sps.csc_array

interpolate(sd, func)[source]

Interpolates a given matrix-valued function to the symmetric matrix-valued piecewise polynomial space. The full matrix-valued interpolant is projected onto the symmetric subspace, i.e. the symmetric part is taken.

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

  • func (callable) – The function to interpolate.

Returns:

The interpolated function, with shape (ndof,).

Return type:

np.ndarray

assemble_diff_matrix(sd)[source]

Assembles the matrix corresponding to the differential operator.

This method takes a grid object and returns the differential matrix corresponding to the given grid.

Parameters:

sd (pg.Grid) – The grid object or its subclass.

Returns:

The differential matrix.

Return type:

sps.csc_array

assemble_stiff_matrix(sd, _data=None)[source]

Assembles the stiffness matrix for the given grid.

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

  • data (dict | None) – Additional data for the assembly process.

Returns:

The assembled stiffness matrix.

Return type:

sps.csc_array

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

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.

Raises:

NotImplementedError – There is no zero discretization available in PyGeoN.

class pygeon.discretizations.fem.symmat_l2.SymMatPwConstants(keyword='unitary_data')[source]

Bases: SymMatPwPolynomials

A class representing the discretization using symmetric matrix piecewise constant functions.

poly_order = 0

Polynomial degree of the basis functions

mat_invert(sd, val)[source]

Inverts a matrix-valued function in the symmetric matrix piecewise constant space.

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

  • val (np.ndarray) – The matrix-valued function to invert. It is assumed to be symmetric and piecewise constant and can be provided with shape (ndof,).

Returns:

The inverted matrix-valued function, with the same shape as val.

Return type:

np.ndarray

class pygeon.discretizations.fem.symmat_l2.SymMatPwLinears(keyword='unitary_data')[source]

Bases: SymMatPwPolynomials

A class representing the discretization using symmetric matrix piecewise linear functions.

poly_order = 1

Polynomial degree of the basis functions

class pygeon.discretizations.fem.symmat_l2.SymMatPwQuadratics(keyword='unitary_data')[source]

Bases: SymMatPwPolynomials

A class representing the discretization using symmetric matrix piecewise quadratic functions.

poly_order = 2

Polynomial degree of the basis functions