:class:`MeshesContainer` ======================== .. py:class:: ansys.dpf.core.meshes_container.MeshesContainer(meshes_container=None, server=None) Bases: :py:obj:`ansys.dpf.core.collection_base.CollectionBase`\ [\ :py:obj:`ansys.dpf.core.meshed_region.MeshedRegion`\ ] Represents a meshes container, which contains meshes split on a given space. :param meshes_container: 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``. :type meshes_container: ansys.grpc.dpf.collection_message_pb2.Collection or :param server: 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. :type server: ansys.dpf.core.server, optional .. py:currentmodule:: MeshesContainer Overview -------- .. tab-set:: .. tab-item:: Methods .. list-table:: :header-rows: 0 :widths: auto * - :py:attr:`~create_subtype` - Create a meshed region sub type. * - :py:attr:`~plot` - Plot the meshes container with a specific result if fields_container is specified. * - :py:attr:`~get_meshes` - Retrieve the meshes at a label space. * - :py:attr:`~get_mesh` - Retrieve the mesh at a requested index or label space. * - :py:attr:`~add_mesh` - Add or update the mesh at a requested label space. * - :py:attr:`~set_labels` - Set labels for scoping the collection. * - :py:attr:`~add_label` - Add the requested label to scope the collection. * - :py:attr:`~has_label` - Check if a collection has a specified label. * - :py:attr:`~get_entries_indices` - Retrieve the indices of the entries corresponding a requested label space . * - :py:attr:`~get_label_space` - Retrieve the label space of an entry at a requested index. * - :py:attr:`~get_available_ids_for_label` - Retrieve the IDs assigned to an input label. * - :py:attr:`~get_label_scoping` - Retrieve the scoping for an input label. * - :py:attr:`~set_support` - Set the support of the collection for a given label. * - :py:attr:`~get_support` - Get the support of the collection for a given label. .. tab-item:: Properties .. list-table:: :header-rows: 0 :widths: auto * - :py:attr:`~name` - Name of the Collection. * - :py:attr:`~labels` - Provides for getting scoping labels as a property. .. tab-item:: Attributes .. list-table:: :header-rows: 0 :widths: auto * - :py:attr:`~entries_type` - * - :py:attr:`~owned` - .. tab-item:: Static methods .. list-table:: :header-rows: 0 :widths: auto * - :py:attr:`~integral_collection` - Create a collection of integral type with a list. .. tab-item:: Special methods .. list-table:: :header-rows: 0 :widths: auto * - :py:attr:`~__getitem__` - Retrieve the mesh at a requested index. * - :py:attr:`~__str__` - Describe the entity. * - :py:attr:`~__len__` - Retrieve the number of entries. * - :py:attr:`~__del__` - Delete the entry. * - :py:attr:`~__iter__` - Provide for looping through entry items. Import detail ------------- .. code-block:: python from ansys.dpf.core.meshes_container import MeshesContainer Property detail --------------- .. py:property:: name Name of the Collection. .. rubric:: Notes Available starting with DPF 2024 R2 pre0. :rtype: str .. py:property:: labels :type: List[str] Provides for getting scoping labels as a property. :returns: List of labels scoping the collection. :rtype: List[str] Attribute detail ---------------- .. py:attribute:: entries_type .. py:attribute:: owned :value: False Method detail ------------- .. py:method:: create_subtype(obj_by_copy) Create a meshed region sub type. .. py:method:: 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. :param fields_container: Data to plot. The default is ``None``. :type fields_container: FieldsContainer, optional :param deform_by: Used to deform the plotted mesh. Must output a 3D vector field. Defaults to None. :type deform_by: Field, Result, Operator, optional :param scale_factor: Scaling factor to apply when warping the mesh. Defaults to 1.0. :type scale_factor: float, optional :param \*\*kwargs: Additional keyword arguments for the plotter. For additional keyword arguments, see ``help(pyvista.plot)``. :type \*\*kwargs: optional .. rubric:: 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) .. py:method:: get_meshes(label_space) Retrieve the meshes at a label space. :param label_space: Meshes corresponding to a filter (label space) in the input. For example: ``{"elshape":1, "body":12}`` :type label_space: dict[str,int] :returns: **meshes** -- Meshes corresponding to the request. :rtype: list[MeshedRegion] .. py:method:: 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. :param label_space_or_index: Scoping of the requested mesh, such as ``{"time": 1, "complex": 0}`` or the index of the mesh. :type label_space_or_index: dict[str,int] , int :returns: **mesh** -- Mesh corresponding to the request. :rtype: MeshedRegion .. py:method:: __getitem__(key) Retrieve the mesh at a requested index. :param key: Index :type key: int :returns: **mesh** -- Mesh corresponding to the request. :rtype: MeshedRegion .. py:method:: add_mesh(label_space, mesh) Add or update the mesh at a requested label space. :param label_space: Label space of the requested meshes. For example, {"elshape":1, "body":12}. :type label_space: dict[str,int] :param mesh: DPF mesh to add or update. :type mesh: MeshedRegion .. py:method:: integral_collection(inpt, server: ansys.dpf.core.server_types.BaseServer = None) :staticmethod: 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. :param inpt: list to transfer server side :type inpt: list[float], list[int], numpy.array :rtype: IntegralCollection .. rubric:: Notes Used by default by the ``'Operator'`` and the``'Workflow'`` when a list is connected or returned. .. py:method:: set_labels(labels) Set labels for scoping the collection. :param labels: Labels to scope entries to. For example, ``["time", "complex"]``. :type labels: list[str], optional .. py:method:: add_label(label, default_value=None) Add the requested label to scope the collection. :param label: Labels to scope the entries to. For example, ``"time"``. :type label: str :param default_value: Default value for existing fields in the collection. The default is ``None``. :type default_value: int, optional .. rubric:: Examples >>> from ansys.dpf import core as dpf >>> coll = dpf.FieldsContainer() >>> coll.add_label('time') .. py:method:: has_label(label) -> bool Check if a collection has a specified label. :param label: Label to search for. For example, ``"time"``. :type label: str :returns: ``True`` when successful, ``False`` when failed. :rtype: bool .. rubric:: 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 .. py:method:: get_entries_indices(label_space) Retrieve the indices of the entries corresponding a requested label space . .. rubric:: Notes Available starting with DPF 2025R1. :param label_space: Label space or index. For example, ``{"time": 1, "complex": 0}`` or the index of the field. :type label_space: dict[str,int] :returns: **indices** -- Indices of the entries corresponding to the request. :rtype: list[int], list[Field], list[MeshedRegion] .. py:method:: get_label_space(index) Retrieve the label space of an entry at a requested index. :param index: Index of the entry. :type index: int :returns: **label_space** -- Scoping of the requested entry. For example, ``{"time": 1, "complex": 0}``. :rtype: dict(str:int) .. py:method:: get_available_ids_for_label(label='time') Retrieve the IDs assigned to an input label. :param label: Name of the input label. The default is ``"time"``. :type label: str :returns: **ids** -- List of IDs assigned to the input label. :rtype: list[int] .. py:method:: 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. :param label: Name of the input label. :type label: str :returns: **scoping** -- IDs scoped to the input label. :rtype: Scoping .. py:method:: set_support(label: str, support: ansys.dpf.core.support.Support) -> None Set the support of the collection for a given label. .. rubric:: Notes Available starting with DPF 2023 R1. .. py:method:: get_support(label: str) -> ansys.dpf.core.support.Support Get the support of the collection for a given label. .. rubric:: Notes Available starting with DPF 2023 R1. .. py:method:: __str__() Describe the entity. :returns: **description** -- Description of the entity. :rtype: str .. py:method:: __len__() Retrieve the number of entries. .. py:method:: __del__() Delete the entry. .. py:method:: __iter__() Provide for looping through entry items.