pysdic.IntegrationPoints#

The pysdic.IntegrationPoints stores \(N_p\) points located in the elements of a mesh by their element index and their natural coordinates \(\Xi\) (shape \((N_p, K)\)), with a weight and optional properties for each point. A point outside the mesh is unlocated (element index -1).

IntegrationPoints class#

class IntegrationPoints(natural_coordinates, element_indices, *, weights=None, n_topological_dimensions=None, properties=None)[source]#

Bases: LockableMixin, JsonSerializerMixin, NpzSerializerMixin, Hdf5SerializerMixin

A set of \(N_p\) integration points located in the elements of a mesh.

Each point is defined by the index of its element and its natural coordinates \(\Xi = (\xi, \eta, ...)\) in the reference element. There are \(K\) natural coordinates, the topological dimension of the elements (1 for segments, 2 for triangles and quadrangles). Each point also has a weight (e.g. a Gauss quadrature weight).

Each point can carry additional properties stored in a pysdic.core.property_container.PropertyContainer, accessible through the properties attribute or directly with integration_points[name].

A point outside the mesh is unlocated: its element index is -1. Only the element index defines the location: the natural coordinates of an unlocated point are ignored by the pysdic.fem functions (the methods of this class set them to numpy.nan).

Note

The arrays are copied when they are set and stored as numpy.float64 (natural coordinates, weights) and numpy.int64 (element indices) arrays. The attributes return read-only views: to change the values, assign a new array.

Important

The integration points do not know their mesh: use pysdic.Mesh.validate_integration_points() to check that they are consistent with a mesh (topological dimension and element indices).

Important

The properties are stored in a pysdic.core.property_container.PropertyContainer with force_2d=True, i.e. with shape \((N_p, P)\). A container given by the user with other settings is accepted, but some operations may behave unexpectedly.

Parameters:
  • natural_coordinates (ArrayLike) – An array of shape \((N_p, K)\) with the natural coordinates of the points. A 1D array of shape \((N_p,)\) is accepted if n_topological_dimensions=1.

  • element_indices (ArrayLike) – An integer array of shape \((N_p,)\) with the index of the element of each point, or -1 for an unlocated point. Floats are accepted only if they are integral (no truncation).

  • weights (Optional[ArrayLike], optional (default: None)) – An array of shape \((N_p,)\) with the finite and non-negative weights of the points. By default, all the weights are 1.

  • n_topological_dimensions (Optional[Integral], optional (default: None)) – The topological dimension \(K\). By default, it is inferred from the shape of natural_coordinates. If given, it must match this shape.

  • properties (Optional[Union[Dict[str, ArrayLike], PropertyContainer]], optional) –

    The properties of the points:

Notes

len(integration_points) gives the number of points \(N_p\), while integration_points[name], name in integration_points and iter(integration_points) refer to the properties.

The methods never modify the integration points in place: the methods that change the points (filter_points(), filter_elements(), unlocate_points_by_index(), …) return new integration points. Only the setters (same number of points) and the properties modify existing integration points.

Note

Integration points can be locked by an object of the package that uses them (for example a term built with pysdic.build_sdic_term(), which computes the shape functions of the points once, see pysdic.core.lockable.LockableMixin): the setters natural_coordinates, element_indices and weights then raise a RuntimeError explaining why. The locked points can still be read and used everywhere, and their properties can be modified. A copy (copy) is always unlocked.

Instantiation#

The IntegrationPoints class can be instantiated in two ways:

  • From natural coordinates and element indices with the constructor (and optional weights).

  • From the Gauss points of all the elements of a mesh using the classmethod from_gauss_points().

IntegrationPoints.from_gauss_points(...)

Create the Gauss quadrature points of all the elements of a mesh.

Implemented methods and attributes#

The following sections provide an overview of the attributes and methods defined in the pysdic.IntegrationPoints class.

Attributes#

The points can carry properties stored in a property container (see Core Tools), accessible with obj.properties or directly with obj[name].

IntegrationPoints.element_indices

[Get/Set] The element index of each point (-1 for an unlocated point), an array of shape \((N_p,)\).

IntegrationPoints.n_located

[Get] The number of points located in an element (element index \(\neq -1\)).

IntegrationPoints.n_points

[Get] The number of points \(N_p\) (located or not).

IntegrationPoints.n_properties

[Get] The number of properties of the points.

IntegrationPoints.n_topological_dimensions

[Get] The topological dimension \(K\) of the elements.

IntegrationPoints.natural_coordinates

[Get/Set] The natural coordinates of the points, an array of shape \((N_p, K)\).

IntegrationPoints.properties

[Get] The properties of the points.

IntegrationPoints.shape

[Get] The shape \((N_p, K)\) of the natural coordinates.

IntegrationPoints.weights

[Get/Set] The weights of the points, an array of shape \((N_p,)\).

Structure methods#

IntegrationPoints.concatenate(other, *[, ...])

Concatenate two sets of integration points (the points of other come after).

IntegrationPoints.copy(*[, copy_properties])

Create a copy of the integration points.

IntegrationPoints.filter_points(mask, *[, ...])

Keep only the points selected by a boolean mask.

IntegrationPoints.keep_points_by_index(...)

Keep only the points with the given indices.

IntegrationPoints.remove_points_by_index(...)

Remove the points with the given indices.

IntegrationPoints.keep_points_by_element(...)

Keep only the points located in the given elements.

IntegrationPoints.remove_points_by_element(...)

Remove the points located in the given elements.

IntegrationPoints.remove_unlocated(*[, ...])

Remove the unlocated points (element index -1).

IntegrationPoints.unlocate_points_by_index(...)

Unlocate the points with the given indices without removing them: their element index is set to -1 and their natural coordinates to numpy.nan.

IntegrationPoints.unlocate_points_by_element(...)

Unlocate the points located in the given elements without removing them: their element index is set to -1 and their natural coordinates to numpy.nan.

Update after a modification of the mesh#

When the elements of the mesh are filtered, removed or kept, these methods unlocate the points of the removed elements and renumber the element indices of the other points.

IntegrationPoints.filter_elements(mask, *[, ...])

Update the integration points after the elements of their mesh are filtered with a boolean mask (see pysdic.Mesh.filter_connectivity()).

IntegrationPoints.keep_elements(...[, ...])

Update the integration points after only some elements of their mesh are kept (see pysdic.Mesh.keep_connectivity_by_index()).

IntegrationPoints.remove_elements(...[, ...])

Update the integration points after elements are removed from their mesh (see pysdic.Mesh.remove_connectivity_by_index()).

Checks#

Use pysdic.Mesh.validate_integration_points() to check the consistency of the points with a mesh.

IntegrationPoints.validate(*[, recursive])

Validate the integrity of the integration points.

IntegrationPoints.is_located()

Check which points are located in an element (element index \(\neq -1\)).

Serialization methods#

The pysdic.IntegrationPoints is converted to a flat dictionary with to_dict (and created back with from_dict). It inherits the file methods of the serialization mixins (see Core Tools).

IntegrationPoints.to_dict(*[, save_properties])

Convert the integration points to a flat dictionary.

IntegrationPoints.from_dict(data, *[, ...])

Create integration points from a dictionary.

IntegrationPoints.to_json_file(file_path, *)

Serialize the object to a JSON file.

IntegrationPoints.from_json_file(file_path, ...)

Deserialize a JSON file to an object of the class.

IntegrationPoints.to_hdf5_file(file_path, *)

Serialize the object to an HDF5 file.

IntegrationPoints.from_hdf5_file(file_path, ...)

Deserialize an object from an HDF5 file.

IntegrationPoints.to_npz_file(file_path, *)

Serialize the object to an NPZ file.

IntegrationPoints.from_npz_file(file_path, ...)

Deserialize an object from an NPZ file.