pygeon.discretizations.fem.mat_l2 module

Module for the discretizations of the matrix L2 space.

class pygeon.discretizations.fem.mat_l2.MatPwPolynomials(keyword='unitary_data')[source]

Bases: VecPwPolynomials

Base class for matrix-valued piecewise polynomial discretizations.

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_trace_matrix(sd)[source]

Assembles and returns the trace matrix for the matrix-valued piecewise polynomials.

Parameters:

sd (pg.Grid) – The grid.

Returns:

The trace matrix.

Return type:

sps.csc_array

assemble_asym_matrix(sd)[source]

Assembles and returns the asymmetry matrix for the matrix-valued piecewise polynomials.

Parameters:

sd (pg.Grid) – The grid.

Returns:

The asymmetry matrix.

Return type:

sps.csc_array

assemble_mult_matrix(sd, mult_mat, *, right_mult=None, left_mult=None)[source]

Assembles and returns the matrix that multiplies with an elementwise matrix-valued function.

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

  • mult_mat (np.ndarray) – The matrix to multiply with. It is assumed to be a piecewise constant matrix and can be provided with shape (d, d, n_cells), (d, d, n_dof), or their flattened equivalents.

  • right_mult (bool, optional) – If True, performs right multiplication (A @ X). Exactly one of ‘right_mult’ or ‘left_mult’ must be True.

  • left_mult (bool, optional) – If True, performs left multiplication (X @ A). Exactly one of ‘right_mult’ or ‘left_mult’ must be True.

Returns:

The multiplication matrix obtained from the discretization.

Return type:

sps.csc_array

Raises:

ValueError – If exactly one of ‘right_mult’ or ‘left_mult’ is not True.

assemble_transpose_matrix(sd)[source]

Assembles and returns the operator that transposes a matrix-valued function.

Parameters:

sd (pg.Grid) – The grid.

Returns:

The transposition operator.

Return type:

sps.csc_array

assemble_symmetrizing_matrix(sd)[source]

Assembles and returns the operator that symmetrizes a matrix-valued function.

Parameters:

sd (pg.Grid) – The grid.

Returns:

The symmetrization operator.

Return type:

sps.csc_array

assemble_upper_convected_distortion(sd, grad_v)[source]

Assembles the term - grad_v * A - A * grad_v.T, with grad_v a matrix-valued function in the matrix piecewise constant space.

This term appears in the upper-convected derivative of a matrix-valued function, and it is the distortion part of the upper-convected derivative.

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

  • grad_v (np.ndarray) – The gradient of the velocity, a matrix-valued function in the matrix piecewise constant space.

Returns:

The upper convected distortion matrix obtained from the

discretization.

Return type:

sps.csc_array

class pygeon.discretizations.fem.mat_l2.MatPwConstants(keyword='unitary_data')[source]

Bases: MatPwPolynomials

A class representing the discretization using matrix piecewise constant functions.

poly_order = 0

Polynomial degree of the basis functions

__init__(keyword='unitary_data')[source]

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

Parameters:

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

Returns:

None

mat_invert(sd, val)[source]

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

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

  • val (np.ndarray) – The matrix-valued function to invert. It is assumed to be 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.mat_l2.MatPwLinears(keyword='unitary_data')[source]

Bases: MatPwPolynomials

A class representing the discretization using matrix piecewise linear functions.

poly_order = 1

Polynomial degree of the basis functions

__init__(keyword='unitary_data')[source]

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

Parameters:

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

Returns:

None

assemble_corotational_correction(sd, rotation)[source]

Assembles and returns the corotational correction matrix for the matrix-valued piecewise linears. We assume rotation to be a piecewise constant function in P0.

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

  • rotation (np.ndarray) – The rotation in P0, either a scalar field in 2D or a vector field in 3D.

Returns:

The corotational correction matrix obtained from the

discretization.

Return type:

sps.csc_array

class pygeon.discretizations.fem.mat_l2.MatPwQuadratics(keyword='unitary_data')[source]

Bases: MatPwPolynomials

A class representing the discretization using matrix piecewise quadratic functions.

poly_order = 2

Polynomial degree of the basis functions

__init__(keyword='unitary_data')[source]

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

Parameters:

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

Returns:

None