ScopingsContainer#

Contains classes associated to the DPF ScopingsContainer

class ansys.dpf.core.scopings_container.ScopingsContainer(scopings_container=None, server=None)#
entries_type#

A class used to represent a ScopingsContainer which contains scopings split on a given space

Parameters:
  • scopings_container (ansys.grpc.dpf.collection_pb2.Collection or) – ansys.dpf.core.ScopingsContainer, optional Create a scopings container from a Collection message or create a copy from an existing scopings container

  • server (server.DPFServer, optional) – Server with channel connected to the remote or local instance. When None, attempts to use the global server.

alias of Scoping

get_scopings(label_space)#

Returns the scopings at a requested label space

Parameters:

label_space_or_index (dict[str,int] , int) – Scopings corresponding to the filter (label space) in input, for example: {"elshape":1, "body":12}

Returns:

scopings – scopings corresponding to the request

Return type:

list[Scoping]

get_scoping(label_space_or_index)#

Returns the scoping at a requested index or label space. Throws if the request returns several scoping

Parameters:

label_space_or_index (dict[str,int] , int) – Scopings corresponding to the filter (label space) in input, for example: {"elshape":1, "body":12} or Index of the scoping.

Returns:

scopings – scoping corresponding to the request

Return type:

Scoping

add_label(label, default_value=None)#

Add the requested label to scope the collection.

Parameters:
  • label (str) – Labels to scope the entries to. For example, "time".

  • default_value (int, optional) – Default value for existing fields in the collection. The default is None.

Examples

>>> from ansys.dpf import core as dpf
>>> coll = dpf.FieldsContainer()
>>> coll.add_label('time')
get_available_ids_for_label(label='time')#

Retrieve the IDs assigned to an input label.

Parameters:

label (str) – Name of the input label. The default is "time".

Returns:

ids – List of IDs assigned to the input label.

Return type:

list[int]

get_label_scoping(label='time')#

Retrieve the scoping for an input label.

This method allows you to retrieve a list of IDs for a given input label in the collection. For example, if the label el_type exists in the collection, you can use the get_lable_scoping method to retrieve a list of IDS with this label. You can then use these IDs to request a given entity inside the collection.

Parameters:

label (str) – Name of the input label.

Returns:

scoping – IDs scoped to the input label.

Return type:

Scoping

get_label_space(index)#

Retrieve the label space of an entry at a requested index.

Parameters:

index (int) – Index of the entry.

Returns:

label_space – Scoping of the requested entry. For example, {"time": 1, "complex": 0}.

Return type:

dict(str:int)

has_label(label)#

Check if a collection has a specified label.

Parameters:

label (str) – Label to search for. For example, "time".

Returns:

True when successful, False when failed.

Return type:

bool

Examples

>>> from ansys.dpf import core as dpf
>>> coll = dpf.FieldsContainer()
>>> coll.add_label('time')
>>> coll.has_label('time')
True
>>> coll.has_label('complex')
False
static integral_collection(inpt, server: ansys.dpf.core.server_types.BaseServer | None = None)#

Creates a collection of integral type with a list.

The collection of integral is the equivalent of an array of data sent server side. It can be used to efficiently stream large data to the server.

Parameters:

inpt (list[float], list[int], numpy.array) – list to transfer server side

Return type:

IntegralCollection

Notes

Used by default by the 'Operator' and the``’Workflow’`` when a list is connected or returned.

property labels: list#

Retrieve labels scoping the collection.

Returns:

labels – List of labels that entries are scoped to. For example, ["time", "complex"].

Return type:

list[str]

property name#

Name of the Collection.

Notes

Available starting with DPF 2024 R2 pre0.

Return type:

str

set_labels(labels)#

Set labels for scoping the collection.

Parameters:

labels (list[str], optional) – Labels to scope entries to. For example, ["time", "complex"].

add_scoping(label_space, scoping)#

Update or add the scoping at a requested label space.

Parameters:
  • label_space (dict[str,int]) – label_space of the requested scopings, ex : {“elshape”:1, “body”:12}

  • scoping (Scoping) – DPF scoping to add.