pysdic.Mesh.compute_property_projection#

Mesh.compute_property_projection(values, integration_points, *, sparse=False, allow_unlocated_points=False, tolerance=0.0, default=nan, return_unaffected=False)[source]#

Project a property defined at integration points to the vertices of the mesh.

Shortcut for pysdic.fem.compute_property_projection() with the connectivity and element type of the mesh (see this function for the projection formula).

Important

The weights of the integration points (integration_points.weights) are used as the weights of the projection. Set integration_points.weights = None for a projection with equal weights.

Parameters:
  • values (Union[str, ArrayLike]) – The property at the integration points: the name of a property of integration_points or an array of shape \((N_p, \dots)\).

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

  • sparse (bool, optional (default: False)) – If True, the linear system of the projection is solved with sparse matrices.

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

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

  • default (Real, optional (default: numpy.nan)) – The value of the vertices that are not affected by any point.

  • return_unaffected (bool, optional (default: False)) – If True, the mask of the unaffected vertices is also returned.

Returns:

  • projected_values (numpy.ndarray) – An array of shape \((N_v, P)\) with the projected property.

  • unaffected_mask (numpy.ndarray) – Only returned if return_unaffected is True. A boolean array of shape \((N_v,)\), True for the vertices set to default.

Return type:

ndarray | Tuple[ndarray, ndarray]

Examples

Interpolate a property at the 4 Gauss points of a quadrangle and project it back to the vertices (the property is recovered).

 1import numpy
 2from pysdic import Mesh, IntegrationPoints
 3
 4mesh = Mesh([[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]], [[0, 1, 2, 3]], element_type="quadrangle_4")
 5mesh.vertices["u"] = [0.0, 1.0, 2.0, 3.0]
 6
 7integration_points = IntegrationPoints.from_gauss_points("quadrangle_4", mesh.n_elements)
 8integration_points["u"] = mesh.compute_property_interpolation("u", integration_points)
 9
10projected = mesh.compute_property_projection("u", integration_points)
11print(numpy.round(projected.ravel(), 6))  # [0. 1. 2. 3.]