MeshesContainer

Contains classes associated to the DPF MeshesContainer

class ansys.dpf.core.meshes_container.MeshesContainer(meshes_container=None, server=None)

A class used to represent a MeshesContainer which contains meshes split on a given space

Parameters
  • meshes_container (ansys.grpc.dpf.collection_pb2.Collection or ansys.dpf.core.MeshesContainer, optional) – Create a meshes container from a Collection message or create a copy from an existing meshes container

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

get_meshes(label_space)

Returns the meshes at a label space

Parameters

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

Returns

meshes – meshes corresponding to the request

Return type

list[MeshedRegion]

get_mesh(label_space_or_index)

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

Parameters

label_space_or_index (dict[str,int] , int) – Scoping of the requested mesh, for example: {"time": 1, "complex": 0} or Index of the mesh.

Returns

mesh – mesh corresponding to the request

Return type

MeshedRegion

add_mesh(label_space, mesh)

Update or add the scoping at a requested label space.

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

  • mesh (MeshedRegion) – DPF mesh to add.

add_label(label, default_value=None)

Add the requested label to scope the collection

Parameters
  • label (str) – Labels on which the entries will be scoped, for example 'time'.

  • default_value (int , optional) – default value set for existing fields in the collection

Examples

>>> from ansys.dpf import core as dpf
>>> coll = dpf.Collection(dpf.types.field)
>>> coll.add_label('time')
get_available_ids_for_label(label='time')

Get the IDs corresponding to the input label.

Parameters

label (str) – name of the requested ids

Returns

ids – ids corresponding to the input label

Return type

list[int]

get_label_scoping(label='time')

Get the scoping corresponding to the input label. This method allows to get the list of available ids for a given label in the Collection. For example, if the label “el_type” is available in the collection, the get_lable_scoping method, will return the list element type ids available in it. Those ids can then be used to request a given entity inside the collection.

Parameters

label (str) – name of the requested ids

Returns

scoping – scoping containing the ids of the input label

Return type

Scoping

get_label_space(index)

Returns the label space of an entry at a requested index

Parameters

index (int, optional) – 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) – Labels that must be searched, for example 'time'.

Returns

True if the specified value has been found in the collection.

Return type

bool

Examples

>>> from ansys.dpf import core as dpf
>>> coll = dpf.Collection(dpf.types.field)
>>> coll.add_label('time')
>>> coll.has_label('time')
True
>>> coll.has_label('complex')
False
property labels

get the labels scoping the collection

Returns

labels

labels on which the entries are scoped, for example:

['time', 'complex']

Return type

list[str]

set_labels(labels)

set the requested labels to scope the collection

Parameters

labels (list[str], optional) –

labels on which the entries will be scoped, for example:

[‘time’,’complex’]