pygeon.discretizations.fem.vec_h1 module

Module for the discretizations of the vector H1 space.

class pygeon.discretizations.fem.vec_h1.VecLagrange1(keyword='unitary_data')[source]

Bases: VecDiscretization

Vector Lagrange finite element discretization for H1 space.

This class represents a finite element discretization for the H1 space using vector Lagrange elements. It provides methods for assembling various matrices and operators, such as the mass matrix, divergence matrix, symmetric gradient matrix, and more.

Convention for the ordering is first all the x, then all the y, and (if dim = 3) all the z.

The stress tensor and strain tensor are represented as vectors unrolled row-wise. In 2D, the stress tensor has a length of 4, and in 3D, it has a length of 9.

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}]\]

The strain tensor follows the same approach.

poly_order = 1

Polynomial degree of the basis functions

tensor_order = 1

Vector-valued discretization

__init__(keyword='unitary_data')[source]

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

Parameters:

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

Returns:

None

base_discr

The scalar discretization method.

assemble_div_matrix(sd)[source]

Returns the div matrix operator for the lowest order vector Lagrange element

Parameters:

sd (pg.Grid) – The grid object.

Returns:

The div matrix obtained from the discretization.

Return type:

sps.csc_array

assemble_symgrad_matrix(sd)[source]

Returns the symmetric gradient matrix operator for the lowest order vector Lagrange element

Parameters:

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

Returns:

The sparse symmetric gradient matrix operator.

Return type:

sps.csc_array

assemble_stiff_matrix_elasticity(sd, data=None)[source]

Assembles the elasticity matrix for the finite element method.

Parameters:
  • sd (pg.Grid) – The grid on which the finite element method is defined.

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

Returns:

The assembled global elasticity 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 that contains the range of the differential.

Return type:

Discretization

Raises:
  • NotImplementedError – If there is no range discretization for the vector

  • Lagrangian 1 in PyGeoN.

compute_stress(sd, u, data)[source]

Compute the stress tensor for a given displacement field at the cell centers as a (3, 3, num_cells) tensor.

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

  • u (ndarray) – The displacement field.

  • data (dict) – Data for the computation including the Lame parameters accessed with the keys pg.LAME_LAMBDA and pg.LAME_MU. Both float and np.ndarray are accepted.

Returns:

The stress tensor.

Return type:

ndarray

class pygeon.discretizations.fem.vec_h1.VecLagrange2(keyword='unitary_data')[source]

Bases: VecDiscretization

VecLagrange2 is a vector discretization class that extends the functionality of the pg.VecDiscretization base class. It utilizes the pg.Lagrange2 scalar discretization class for its operations.

poly_order = 2

Polynomial degree of the basis functions

tensor_order = 1

Vector-valued discretization

__init__(keyword='unitary_data')[source]

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

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 discretization class that contains the range of the differential.

Parameters:

dim (int) – The dimension of the range.

Returns:

The discretization class that contains the range of the differential.

Return type:

Discretization

Raises:
  • NotImplementedError – If there is no range discretization for the vector

  • Lagrangian 2 in PyGeoN.