Scoping#

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.

Parameters:
  • scoping (ctypes.c_void_p, ansys.grpc.dpf.scoping_pb2.Scoping message, optional) –

  • server (DPFServer, optional) – 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.

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))
set_id(index, scopingid)#

Set the ID of a scoping’s index.

Parameters:
  • index (int) – Index of the scoping.

  • scopingid (int) – ID of the scoping.

id(index: int)#

Retrieve the ID at a given index.

Parameters:

index (int) – Index for the ID.

Returns:

size

Return type:

int

index(id: int)#

Retrieve the index of a given ID.

Parameters:

id (int) – ID for the index to retrieve.

Returns:

size

Return type:

int

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 ansys.dpf.core.settings.get_runtime_client_config() and ansys.dpf.core.runtime_config.RuntimeClientConfig.return_arrays(). To change the return type to a list once, use ansys.dpf.core.scoping.Scoping._get_ids() with the parameter np_array=False.

Return type:

DPFArray, list of int

Notes

Print a progress bar.

property location#

Location of the IDs as a string, such as "nodal", "elemental", and "time_freq".

Returns:

location

Return type:

str

property size#

Length of the list of IDs.

Returns:

size

Return type:

int

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.

Parameters:

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.

Returns:

scoping_copy

Return type:

Scoping

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, <release_data> 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

Return type:

Scoping

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