Scoping
#
- class ansys.dpf.core.scoping.Scoping(scoping: ansys.grpc.dpf.scoping_pb2.Scoping | ctypes.c_void_p = None, server: ansys.dpf.core.server_types.AnyServerType = None, ids: IdVectorType = None, location: ansys.dpf.core.common.locations = None)#
Represents a scoping, which is a subset of a model support.
- Parameters:
scoping – gRPC message or pointer for an existing scoping on the server.
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.ids – List of entity IDs.
location – Location for this scoping. Defines the type of entities the IDs correspond to. For example, if location is
locations.nodal
, then the scoping is a list of node IDs.
Examples
Create a scoping for mesh entities.
>>> 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 to 6 >>> my_nodal_scoping = mesh_scoping_factory.nodal_scoping(range(4, 7)) >>> #2. using the Scoping class directly >>> # a. scoping with elemental location that targets the elements with id 2, 7 and 11 >>> my_elemental_scoping = dpf.Scoping(location=dpf.locations.elemental, ids=[2, 7, 11]) >>> # b. scoping with nodal location that targets the elements with id 4 to 6 >>> my_nodal_scoping = dpf.Scoping(ids=range(4, 7)) >>> # 3. create a time_freq scoping that targets the second load step >>> from ansys.dpf.core import time_freq_scoping_factory >>> # a. using the time_freq_scoping_factory >>> my_load_step_scoping = time_freq_scoping_factory.scoping_by_load_step(2) >>> # b. using the Scoping class directly >>> my_load_step_scoping = dpf.Scoping(location=dpf.locations.time_freq_step, ids=[2])
Overview#
Return the list of entity IDs in the scoping as a list or as a numpy.ndarray. |
|
Set the ID of the entity at index in the scoping. |
|
Retrieve the entity ID at a given index. |
|
Retrieve the index for a given entity ID. |
|
Create a deep copy of the scoping’s data on a given server. |
|
Create a deep copy of the scoping that can be accessed and modified locally. |
Return the number of scoping ids. |
|
Clean up resources associated with the instance. |
|
Return an iterator over the scoping ids. |
|
Retrieve the ID at a requested index. |
|
Set the ID at a given index. |
|
Describe the entity. |
Import detail#
from ansys.dpf.core.scoping import Scoping
Property detail#
- property Scoping.ids: ansys.dpf.gate.dpf_array.DPFArray | list[int]#
Retrieve the entity IDs in the scoping.
- Returns:
List of IDs in the scoping. 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()
andansys.dpf.core.runtime_config.RuntimeClientConfig.return_arrays()
. To get the list of IDs from a scoping as a Python list without changing a default configuration, useansys.dpf.core.scoping.Scoping.get_ids()
instead.- Return type:
ids
- property Scoping.location: str#
Location of the scoping as a string.
This defines the type of entity the IDs correspond to (such as node ID, element ID, face ID, and so on).
- Returns:
The location of the scoping. One of the values of
locations
.- Return type:
location
- property Scoping.size: int#
Length of the list of IDs.
- Returns:
Size of the scoping.
- Return type:
size
Method detail#
- Scoping.get_ids(np_array: bool = False) list[int] | ansys.dpf.gate.dpf_array.DPFArray #
Return the list of entity IDs in the scoping as a list or as a numpy.ndarray.
- Parameters:
np_array – Whether to return the list of IDs as a numpy array.
- Returns:
List of entity IDs in the scoping.
- Return type:
ids
- Scoping.set_id(index: int, scopingid: int)#
Set the ID of the entity at index in the scoping.
- Parameters:
index – Index in the scoping.
scopingid – ID of the entity.
- Scoping.id(index: int) int #
Retrieve the entity ID at a given index.
- Parameters:
index – Index of the entity in the scoping.
- Returns:
ID of the entity at index in the scoping.
- Return type:
entity_id
- Scoping.index(id: int) int #
Retrieve the index for a given entity ID.
- Parameters:
id – Entity ID at the index in the scoping.
- Returns:
Index in the scoping for the entity ID.
- Return type:
index
- Scoping.__len__()#
Return the number of scoping ids.
- Returns:
The number of scoping ids.
- Return type:
int
- Scoping.__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.
- Scoping.__iter__()#
Return an iterator over the scoping ids.
- Scoping.__getitem__(key)#
Retrieve the ID at a requested index.
- Scoping.__setitem__(index, id)#
Set the ID at a given index.
- Scoping.__str__()#
Describe the entity.
- Returns:
description
- Return type:
str
- Scoping.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 awith
statement,
should be used to update the scoping.Scoping.release_data() 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:
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