Collection#

class ansys.dpf.core.collection.Collection(collection=None, server=None, entries_type: type = None)#

Bases: ansys.dpf.core.collection_base.CollectionBase[ansys.dpf.core.collection_base.TYPE]

Represents a collection of dpf objects organised by label spaces.

Parameters:
  • collection (ansys.grpc.dpf.collection_pb2.Collection or) – ansys.dpf.core.Collection, optional Create a collection from a collection message or create a copy from an existing collection. The default is None.

  • server (ansys.dpf.core.server, optional) – Server with the channel connected to the remote or local instance. The default is None, in which case an attempt is made to use the global server.

  • entries_type (type) – Type of the entries in the collection.

Notes

Class available with server’s version starting at 8.1 (Ansys 2024 R2 pre1).

Overview#

create_subtype

Create dpf instance of any type, which has been cast to its original type.

get_entries

Retrieve the entries at a label space.

get_entry

Retrieve the entry at a requested index or label space.

add_entry

Add or update the entry at a requested label space.

Import detail#

from ansys.dpf.core.collection import Collection

Method detail#

Collection.create_subtype(obj_by_copy)#

Create dpf instance of any type, which has been cast to its original type.

Collection.get_entries(label_space)#

Retrieve the entries at a label space.

Parameters:

label_space (dict[str,int]) – Entries corresponding to a filter (label space) in the input. For example: {"elshape":1, "body":12}

Returns:

entries – Entries corresponding to the request.

Return type:

list[self.type]

Collection.get_entry(label_space_or_index) ansys.dpf.core.collection_base.TYPE#

Retrieve the entry at a requested index or label space.

Raises an exception if the request returns more than one entry.

Parameters:

label_space_or_index (dict[str,int] , int) – Scoping of the requested entry, such as {"time": 1, "complex": 0} or the index of the mesh.

Returns:

entry – Entry corresponding to the request.

Return type:

self.type

Collection.add_entry(label_space, entry)#

Add or update the entry at a requested label space.

Parameters:
  • label_space (dict[str,int]) – Label space of the requested meshes. For example, {“elshape”:1, “body”:12}.

  • entry (self.type) – DPF entry to add or update.