pygeon.discretizations.vem.vec_h1 module

Module for the discretizations of the H1 space.

class pygeon.discretizations.vem.vec_h1.VecVLagrange1(keyword='unitary_data')[source]

Bases: VecDiscretization

Vector Lagrange virtual element discretization for H1 space in 2d.

This class represents a virtual element discretization for the H1 space using vector virtual 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.

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

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

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

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

local_div(sd, cell, diam, nodes)[source]

Compute the local div matrix for vector P1.

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

  • cell (int) – The index of the cell on which to compute the div matrix.

  • diam (float) – The diameter of the cell.

  • nodes (np.ndarray) – The array of node indices.

Returns:

Local mass Hdiv matrix.

Return type:

ndarray

assemble_div_div_matrix(sd, data=None)[source]

Returns the div-div matrix operator for the lowest order vector Lagrange element. The matrix is multiplied by the Lame’ parameter lambda.

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

  • data (dict | None) – Additional data, the Lame’ parameter lambda. Defaults to None.

Returns:

Sparse (sd.num_nodes, sd.num_nodes) Div-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

Notes

  • If a 0-dimensional grid is given, a zero matrix is returned.

  • The method maps the domain to a reference geometry.

  • The method allocates data to store matrix entries efficiently.

  • The symmetrization matrix is constructed differently for 2D and 3D cases.

  • The method computes the symgrad local matrix for each cell and saves the values in the global structure.

  • Finally, the method constructs the global matrices using the saved values.

local_symgrad(sd, cell, diam, nodes, sym)[source]

Compute the local symgrad matrix for vector virtual Lagrangian.

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

  • cell (int) – The index of the cell on which to compute the div matrix.

  • diam (float) – The diameter of the cell.

  • nodes (np.ndarray) – The array of node indices.

  • sym (np.ndarray) – Symmetric matrix.

Returns:

Local symmetric gradient matrix.

Return type:

np.ndarray

assemble_symgrad_symgrad_matrix(sd, data=None)[source]

Returns the symgrad-symgrad matrix operator for the lowest order vector Lagrange element. The matrix is multiplied by twice the Lame’ parameter mu.

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

  • data (dict | None) – Additional data, the Lame’ parameter mu. Defaults to None.

Returns:

Sparse symgrad-symgrad matrix of shape (sd.num_nodes, sd.num_nodes). The matrix obtained from the discretization.

Return type:

sps.csc_array

Notes

Duplicate of pg.VecLagrange1.assemble_symgrad_symgrad_matrix

assemble_penalisation_matrix(sd, data=None)[source]

Assembles and returns the penalisation matrix.

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

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

Returns:

The penalisation matrix obtained from the discretization.

Return type:

sps.csc_array

assemble_loc_penalisation_matrix(sd, cell, diam, nodes)[source]

Computes the local penalisation VEM matrix on a given cell according to the Hitchhiker’s (6.5)

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

  • cell (int) – The index of the cell on which to compute the mass matrix.

  • diam (float) – The diameter of the cell.

  • nodes (np.ndarray) – The array of nodes associated with the cell.

Returns:

The computed local VEM mass matrix.

Return type:

np.ndarray

assemble_diff_matrix(sd)[source]

Assembles the matrix corresponding to the differential operator.

Parameters:

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

Returns:

The differential matrix.

Return type:

sps.csc_array

Notes

Duplicate of pg.VecLagrange1.assemble_diff_matrix

assemble_stiff_matrix(sd, data=None)[source]

Assembles the global stiffness 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 stiffness 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 – 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.

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

Notes

Duplicate of pg.VecLagrange1.compute_stress