MeshesContainer#

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

Bases: ansys.dpf.core.collection_base.CollectionBase[ansys.dpf.core.meshed_region.MeshedRegion]

Represents a meshes container, which contains meshes split on a given space.

Parameters:
  • meshes_container (ansys.grpc.dpf.collection_message_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. 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.

Overview#

create_subtype

Create a meshed region sub type.

plot

Plot the meshes container with a specific result if fields_container is specified.

get_meshes

Retrieve the meshes at a label space.

get_mesh

Retrieve the mesh at a requested index or label space.

add_mesh

Add or update the mesh at a requested label space.

set_labels

Set labels for scoping the collection.

add_label

Add the requested label to scope the collection.

has_label

Check if a collection has a specified label.

get_entries_indices

Retrieve the indices of the entries corresponding a requested label space .

get_label_space

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

get_available_ids_for_label

Retrieve the IDs assigned to an input label.

get_label_scoping

Retrieve the scoping for an input label.

set_support

Set the support of the collection for a given label.

get_support

Get the support of the collection for a given label.

name

Name of the Collection.

labels

Provides for getting scoping labels as a property.

integral_collection

Create a collection of integral type with a list.

__getitem__

Retrieve the mesh at a requested index.

__str__

Describe the entity.

__len__

Retrieve the number of entries.

__del__

Delete the entry.

__iter__

Provide for looping through entry items.

Import detail#

from ansys.dpf.core.meshes_container import MeshesContainer

Property detail#

property MeshesContainer.name#

Name of the Collection.

Notes

Available starting with DPF 2024 R2 pre0.

Return type:

str

property MeshesContainer.labels: List[str]#

Provides for getting scoping labels as a property.

Returns:

List of labels scoping the collection.

Return type:

List[str]

Attribute detail#

MeshesContainer.entries_type#
MeshesContainer.owned = False#

Method detail#

MeshesContainer.create_subtype(obj_by_copy)#

Create a meshed region sub type.

MeshesContainer.plot(fields_container=None, deform_by=None, scale_factor=1.0, **kwargs)#

Plot the meshes container with a specific result if fields_container is specified.

Parameters:
  • fields_container (FieldsContainer, optional) – Data to plot. The default is None.

  • deform_by (Field, Result, Operator, optional) – Used to deform the plotted mesh. Must output a 3D vector field. Defaults to None.

  • scale_factor (float, optional) – Scaling factor to apply when warping the mesh. Defaults to 1.0.

  • **kwargs (optional) – Additional keyword arguments for the plotter. For additional keyword arguments, see help(pyvista.plot).

Examples

>>> from ansys.dpf import core as dpf
>>> from ansys.dpf.core import examples
>>> model = dpf.Model(examples.find_multishells_rst())
>>> mesh = model.metadata.meshed_region
>>> split_mesh_op = dpf.operators.mesh.split_mesh(mesh=mesh, property="mat")
>>> meshes_cont = split_mesh_op.eval()
>>> disp_op = dpf.operators.result.displacement(
...     data_sources = dpf.DataSources(examples.find_multishells_rst()),
...     mesh = meshes_cont
... )
>>> disp_fc = disp_op.outputs.fields_container()
>>> meshes_cont.plot(disp_fc)
MeshesContainer.get_meshes(label_space)#

Retrieve the meshes at a label space.

Parameters:

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

Returns:

meshes – Meshes corresponding to the request.

Return type:

list[MeshedRegion]

MeshesContainer.get_mesh(label_space_or_index)#

Retrieve the mesh at a requested index or label space.

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

Parameters:

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

Returns:

mesh – Mesh corresponding to the request.

Return type:

MeshedRegion

MeshesContainer.__getitem__(key)#

Retrieve the mesh at a requested index.

Parameters:

key (int) – Index

Returns:

mesh – Mesh corresponding to the request.

Return type:

MeshedRegion

MeshesContainer.add_mesh(label_space, mesh)#

Add or update the mesh at a requested label space.

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

  • mesh (MeshedRegion) – DPF mesh to add or update.

static MeshesContainer.integral_collection(inpt, server: ansys.dpf.core.server_types.BaseServer = None)#

Create 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.

MeshesContainer.set_labels(labels)#

Set labels for scoping the collection.

Parameters:

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

MeshesContainer.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')
MeshesContainer.has_label(label) bool#

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
MeshesContainer.get_entries_indices(label_space)#

Retrieve the indices of the entries corresponding a requested label space .

Notes

Available starting with DPF 2025R1.

Parameters:

label_space (dict[str,int]) – Label space or index. For example, {"time": 1, "complex": 0} or the index of the field.

Returns:

indices – Indices of the entries corresponding to the request.

Return type:

list[int], list[Field], list[MeshedRegion]

MeshesContainer.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)

MeshesContainer.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]

MeshesContainer.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

MeshesContainer.set_support(label: str, support: ansys.dpf.core.support.Support) None#

Set the support of the collection for a given label.

Notes

Available starting with DPF 2023 R1.

MeshesContainer.get_support(label: str) ansys.dpf.core.support.Support#

Get the support of the collection for a given label.

Notes

Available starting with DPF 2023 R1.

MeshesContainer.__str__()#

Describe the entity.

Returns:

description – Description of the entity.

Return type:

str

MeshesContainer.__len__()#

Retrieve the number of entries.

MeshesContainer.__del__()#

Delete the entry.

MeshesContainer.__iter__()#

Provide for looping through entry items.