:class:`Scoping` ================ .. py:class:: ansys.dpf.core.scoping.Scoping(scoping=None, server=None, ids=None, location=None) Represents a scoping, which is a subset of a model support. :param scoping: :type scoping: ctypes.c_void_p, ansys.grpc.dpf.scoping_pb2.Scoping message, optional :param server: Server with 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: DPFServer, optional .. rubric:: Examples Create a mesh scoping. >>> from ansys.dpf import core as dpf >>> # 1. using the mesh_scoping_factory >>> from ansys.dpf.core import mesh_scoping_factory >>> # a. scoping with elemental location that targets the elements with id 2, 7 and 11 >>> my_elemental_scoping = mesh_scoping_factory.elemental_scoping([2, 7, 11]) >>> # b. scoping with nodal location that targets the elements with id 4 and 6 >>> my_nodal_scoping = mesh_scoping_factory.nodal_scoping([4, 6]) >>> #2. using the classic API >>> my_scoping = dpf.Scoping() >>> my_scoping.location = dpf.locations.nodal #optional >>> my_scoping.ids = list(range(1,11)) .. py:currentmodule:: Scoping Overview -------- .. tab-set:: .. tab-item:: Methods .. list-table:: :header-rows: 0 :widths: auto * - :py:attr:`~set_id` - Set the ID of a scoping's index. * - :py:attr:`~id` - Retrieve the ID at a given index. * - :py:attr:`~index` - Retrieve the index of a given ID. * - :py:attr:`~deep_copy` - Create a deep copy of the scoping's data on a given server. * - :py:attr:`~as_local_scoping` - Create a deep copy of the scoping that can be accessed and modified locally. .. tab-item:: Properties .. list-table:: :header-rows: 0 :widths: auto * - :py:attr:`~ids` - Retrieve a list of IDs in the scoping. * - :py:attr:`~location` - Location of the IDs as a string, such as ``"nodal"``, ``"elemental"``, and ``"time_freq"``. * - :py:attr:`~size` - Length of the list of IDs. .. tab-item:: Special methods .. list-table:: :header-rows: 0 :widths: auto * - :py:attr:`~__len__` - Return the number of scoping ids. * - :py:attr:`~__del__` - Clean up resources associated with the instance. * - :py:attr:`~__iter__` - Return an iterator over the scoping ids. * - :py:attr:`~__getitem__` - Retrieve the ID at a requested index. * - :py:attr:`~__setitem__` - Set the ID at a given index. * - :py:attr:`~__str__` - Describe the entity. Import detail ------------- .. code-block:: python from ansys.dpf.core.scoping import Scoping Property detail --------------- .. py:property:: ids Retrieve a list of IDs in the scoping. :returns: **ids** -- List of IDs to retrieve. By default a mutable DPFArray is returned, to change the return type to a list for the complete python session, see :func:`ansys.dpf.core.settings.get_runtime_client_config` and :func:`ansys.dpf.core.runtime_config.RuntimeClientConfig.return_arrays`. To change the return type to a list once, use :func:`ansys.dpf.core.scoping.Scoping._get_ids` with the parameter ``np_array=False``. :rtype: DPFArray, list of int .. rubric:: Notes Print a progress bar. .. py:property:: location Location of the IDs as a string, such as ``"nodal"``, ``"elemental"``, and ``"time_freq"``. :returns: **location** :rtype: str .. py:property:: size Length of the list of IDs. :returns: **size** :rtype: int Method detail ------------- .. py:method:: set_id(index, scopingid) Set the ID of a scoping's index. :param index: Index of the scoping. :type index: int :param scopingid: ID of the scoping. :type scopingid: int .. py:method:: id(index: int) Retrieve the ID at a given index. :param index: Index for the ID. :type index: int :returns: **size** :rtype: int .. py:method:: index(id: int) Retrieve the index of a given ID. :param id: ID for the index to retrieve. :type id: int :returns: **size** :rtype: int .. py:method:: __len__() Return the number of scoping ids. :returns: The number of scoping ids. :rtype: int .. py:method:: __del__() Clean up resources associated with the instance. This method calls the deleter function to release resources. If an exception occurs during deletion, a warning is issued. :raises Warning: If an exception occurs while attempting to delete resources. .. py:method:: __iter__() Return an iterator over the scoping ids. .. py:method:: __getitem__(key) Retrieve the ID at a requested index. .. py:method:: __setitem__(index, id) Set the ID at a given index. .. py:method:: __str__() Describe the entity. :returns: **description** :rtype: str .. py:method:: deep_copy(server=None) Create a deep copy of the scoping's data on a given server. This method is useful for passiong data from one server instance to another. :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 :returns: **scoping_copy** :rtype: Scoping .. py:method:: as_local_scoping() Create a deep copy of the scoping that can be accessed and modified locally. This method allows you to access and modify the local copy of the scoping without sending a request to the server. It should be used in a ``with`` statement so that the local field is released and the data is sent to the server in one action. If it is not used in a ``with`` statement, :func:` Scoping.release_data()` should be used to update the scoping. .. warning:: If this `as_local_scoping` method is not used as a context manager in a ``with`` statement or if the method `release_data()` is not called, the data will not be updated. :returns: **local_scoping** :rtype: Scoping .. rubric:: Examples >>> from ansys.dpf import core as dpf >>> num_entities = 3 >>> scoping_to_local = dpf.Scoping() >>> with scoping_to_local.as_local_scoping() as scoping: ... for i in range(0,num_entities): ... scoping[i] = i+1