pysdic.Mesh.compute_shape_function_matrix#

Mesh.compute_shape_function_matrix(integration_points, *, sparse=False, sparse_format='csr', allow_unlocated_points=False, tolerance=0.0)[source]#

Compute the shape function matrix \(\mathcal{N}\) of the mesh at integration points, such that the values of a property at the points are \(\mathcal{N} U\), with \(U\) the values at the vertices.

Shortcut for pysdic.fem.compute_shape_function_matrix() with the connectivity, element type and number of vertices of the mesh.

Parameters:
  • integration_points (pysdic.IntegrationPoints) – The integration points, consistent with the mesh (see validate_integration_points()).

  • sparse (bool, optional (default: False)) – If True, a sparse matrix is returned.

  • sparse_format (str, optional (default: "csr")) – The format of the sparse matrix: "csr" or "coo".

  • allow_unlocated_points (bool, optional (default: False)) – If True, the rows of the unlocated points (element index -1) are zero. Otherwise, they raise an error.

  • tolerance (Real, optional (default: 0.0)) – The tolerance to decide if a point is inside the reference element.

Returns:

A matrix of shape \((N_p, N_v)\).

Return type:

Union[numpy.ndarray, scipy.sparse.csr_matrix, scipy.sparse.coo_matrix]

Examples

1from pysdic import Mesh, IntegrationPoints
2
3mesh = Mesh([[0, 0, 0], [1, 0, 0], [0, 1, 0], [1, 1, 0]], [[0, 1, 2], [1, 3, 2]], element_type="triangle_3")
4integration_points = IntegrationPoints.from_gauss_points("triangle_3", mesh.n_elements)
5
6print(mesh.compute_shape_function_matrix(integration_points))
7# [[0.33333333 0.33333333 0.33333333 0.        ]
8#  [0.         0.33333333 0.33333333 0.33333333]]