pygeon.discretizations.fem.vec_hdiv module

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

class pygeon.discretizations.fem.vec_hdiv.VecHDiv(keyword='unitary_data')[source]

Bases: VecDiscretization

Base class for vector-valued discretizations in the H(div) space. This class provides methods for assembling mass matrices, trace matrices, asymmetric matrices, and lumped matrices for vector-valued finite element discretizations in the H(div) space.

poly_order

Polynomial degree of the basis functions

tensor_order = 2

Matrix-valued discretization

assemble_mass_matrix_elasticity(sd, data=None)[source]

Assembles and returns the elasticity inner product matrix, which is given by \((A \sigma, \tau)\) where

\[A \sigma = \frac{1}{2\mu} \left[ \sigma - c \text{Tr}(\sigma) I\right]\]

with \(\mu\) and \(\lambda\) the Lamé constants and

\[c = \frac{\lambda}{2\mu + d \lambda}\]

where \(d\) is the dimension.

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

  • data (dict) – Data for the assembly.

Returns:

The mass matrix obtained from the discretization.

Return type:

sps.csc_array

assemble_deviator_matrix(sd, data=None)[source]

Assembles and returns the mass matrix for an incompressible material, which is given by (A sigma, tau) where A sigma = (sigma - coeff * Trace(sigma) * I) / (2 mu) with mu the Lamé constants and coeff = 1 / dim

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

  • data (dict) – Data for the assembly.

Returns:

The mass matrix obtained from the discretization.

Return type:

sps.csc_array

assemble_mass_matrix_cosserat(sd, data=None)[source]

Assembles and returns the Cosserat inner product, which is given by \((A \sigma, \tau)\) where

\[A \sigma = \frac{1}{2\mu} \left( \text{sym}(\sigma) - c \text{Tr}(\sigma) I \right) + \frac{1}{2\mu_c} \text{skw}(\sigma)\]

with \(\mu\) and \(\lambda\) the Lamé constants, \(\mu_c\) the coupling Lamé modulus, and

\[c = \frac{\lambda}{2\mu + d \lambda}\]

where \(d\) is the dimension.

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

  • data (dict) – Data for the assembly.

Returns:

The mass matrix obtained from the discretization.

Return type:

sps.csc_array

assemble_lumped_matrix_elasticity(sd, data=None)[source]

Assembles the lumped matrix for the given grid.

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

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

Returns:

The assembled lumped matrix.

Return type:

sps.csc_array

assemble_lumped_matrix_cosserat(sd, data=None)[source]

Assembles the lumped matrix with Cosserat terms for the given grid.

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

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

Returns:

The assembled lumped matrix.

Return type:

sps.csc_array

assemble_asym_matrix(sd, as_pwconstant=False)[source]

Assemble the asymmetric matrix for the given grid.

This method constructs an asymmetric matrix by projecting to matrix piecewise polynomials and combining it with the discretization’s asymmetric matrix.

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

  • as_pwconstant (bool) – Compute the operator with the range on the piece-wise polynomials (default), otherwise the mapping is on the piece-wise constant.

Returns:

The assembled asymmetric matrix in compressed sparse column format.

Return type:

sps.csc_array

assemble_trace_matrix(sd)[source]

Assembles and returns the trace matrix for the vector HDiv.

Parameters:

sd (pg.Grid) – The grid.

Returns:

The trace matrix obtained from the discretization.

Return type:

sps.csc_array

Note

This method should be implemented in subclasses.

class pygeon.discretizations.fem.vec_hdiv.VecBDM1(keyword='unitary_data')[source]

Bases: VecHDiv

VecBDM1 is a class that represents the vector BDM1 (Brezzi-Douglas-Marini) finite element method. It provides methods for assembling matrices like the mass matrix, the trace matrix, the asymmetric matrix and the differential matrix. It also provides methods for evaluating the solution at cell centers, interpolating a given function onto the grid, assembling the natural boundary condition term, and more.

poly_order = 1

Polynomial degree of the basis functions

__init__(keyword='unitary_data')[source]

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

We are considering the following structure of the stress tensor in 2D:

\[\begin{split}\sigma = \begin{bmatrix} \sigma_{xx} & \sigma_{xy} \\ \sigma_{yx} & \sigma_{yy} \end{bmatrix}\end{split}\]

which is represented in the code unrolled row-wise as a vector of length 4:

\[\sigma = [\sigma_{xx}, \sigma_{xy}, \sigma_{yx}, \sigma_{yy}]\]

While in 3D the stress tensor can be written as:

\[\begin{split}\sigma = \begin{bmatrix} \sigma_{xx} & \sigma_{xy} & \sigma_{xz} \\ \sigma_{yx} & \sigma_{yy} & \sigma_{yz} \\ \sigma_{zx} & \sigma_{zy} & \sigma_{zz} \end{bmatrix}\end{split}\]

where its vectorized structure of length 9 is given by:

\[\sigma = [\sigma_{xx}, \sigma_{xy}, \sigma_{xz}, \sigma_{yx}, \sigma_{yy}, \sigma_{yz}, \sigma_{zx}, \sigma_{zy}, \sigma_{zz}]\]
Parameters:

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

Returns:

None

base_discr

The scalar discretization method.

proj_to_RT0(sd)[source]

Project the function space to the lowest order Raviart-Thomas (RT0) space.

Parameters:

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

Returns:

The projection matrix to the RT0 space.

Return type:

sps.csc_array

proj_from_RT0(sd)[source]

Project the RT0 finite element space onto the faces of the given grid.

Parameters:

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

Returns:

The projection matrix.

Return type:

sps.csc_array

get_range_discr_class(_dim)[source]

Returns the discretization class that contains the range of the differential

Parameters:

dim (int) – The dimension of the range.

Returns:

The discretization class containing the range of the differential

Return type:

pg.Discretization

class pygeon.discretizations.fem.vec_hdiv.VecRT0(keyword='unitary_data')[source]

Bases: VecHDiv

VecRT0 is a tensor-valued discretization class for the Raviart-Thomas RT0 finite element, specialized for handling stress tensors in 2D and 3D. This class provides methods for assembling trace and asymmetric matrices for vector RT0 discretizations, as well as retrieving the appropriate range discretization class.

poly_order = 1

Polynomial degree of the basis functions

__init__(keyword='unitary_data')[source]

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

We are considering the following structure of the stress tensor in 2D:

\[\begin{split}\sigma = \begin{bmatrix} \sigma_{xx} & \sigma_{xy} \\ \sigma_{yx} & \sigma_{yy} \end{bmatrix}\end{split}\]

which is represented in the code unrolled row-wise as a vector of length 4:

\[\sigma = [\sigma_{xx}, \sigma_{xy}, \sigma_{yx}, \sigma_{yy}]\]

While in 3D the stress tensor can be written as:

\[\begin{split}\sigma = \begin{bmatrix} \sigma_{xx} & \sigma_{xy} & \sigma_{xz} \\ \sigma_{yx} & \sigma_{yy} & \sigma_{yz} \\ \sigma_{zx} & \sigma_{zy} & \sigma_{zz} \end{bmatrix}\end{split}\]

where its vectorized structure of length 9 is given by:

\[\sigma = [\sigma_{xx}, \sigma_{xy}, \sigma_{xz}, \sigma_{yx}, \sigma_{yy}, \sigma_{yz}, \sigma_{zx}, \sigma_{zy}, \sigma_{zz}]\]
Parameters:

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

Returns:

None

base_discr

The scalar discretization method.

get_range_discr_class(_dim)[source]

Returns the range discretization class for the given dimension.

Parameters:

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

Returns:

The range discretization class.

Return type:

pg.Discretization

class pygeon.discretizations.fem.vec_hdiv.VecRT1(keyword='unitary_data')[source]

Bases: VecHDiv

VecRT1 is a vector Raviart-Thomas finite element discretization class of order 1.

This class is designed for matrix-valued finite element discretizations in the H(div) space, specifically using the Raviart-Thomas elements of order 1 (RT1).

poly_order = 2

Polynomial degree of the basis functions

__init__(keyword='unitary_data')[source]

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

Parameters:

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

Returns:

None

base_discr

The scalar discretization method.

get_range_discr_class(_dim)[source]

Returns the range discretization class for the given dimension.

Parameters:

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

Returns:

The range discretization class.

Return type:

pg.Discretization