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))
Overview#
Set the ID of a scoping’s index. |
|
Retrieve the ID at a given index. |
|
Retrieve the index of a given 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#
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()
andansys.dpf.core.runtime_config.RuntimeClientConfig.return_arrays()
. To change the return type to a list once, useansys.dpf.core.scoping.Scoping._get_ids()
with the parameternp_array=False
.- Return type:
DPFArray, list of int
Notes
Print a progress bar.
- property Scoping.location#
Location of the IDs as a string, such as
"nodal"
,"elemental"
, and"time_freq"
.- Returns:
location
- Return type:
str
- property Scoping.size#
Length of the list of IDs.
- Returns:
size
- Return type:
int
Method detail#
- Scoping.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.
- Scoping.id(index: int)#
Retrieve the ID at a given index.
- Parameters:
index (int) – Index for the ID.
- Returns:
size
- Return type:
int
- Scoping.index(id: int)#
Retrieve the index of a given ID.
- Parameters:
id (int) – ID for the index to retrieve.
- Returns:
size
- Return type:
int
- 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