StringField
#
- class ansys.dpf.core.string_field.StringField(nentities=0, string_field=None, server=None)#
Bases:
ansys.dpf.core.field_base._FieldBase
Describes string data scoped on entities such as names.
This class is a field with string values instead of double values.
- Parameters:
nentities (int) – Number of entities that the string field is to contain (reserved). The default is
0
.string_field (Field, ansys.grpc.dpf.field_pb2.Field, ctypes.c_void_p, optional) – Field message generated from a gRPC stub, or returned by DPF’s C clients.
server (server.DPFServer, 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.
Examples
>>> from ansys.dpf import core as dpf >>> pfield = dpf.StringField() >>> list_ids = [1, 2, 4, 6, 7] >>> scop = dpf.Scoping(ids = list_ids, location = dpf.locations.nodal) >>> pfield.scoping = scop >>> list_data = ["water", "oil", "gaz", "paint", "air"] >>> pfield.data = list_data
Notes
Class available with server’s version starting at 5.0 (Ansys 2023R1).
Overview#
Return entity data. |
|
Return entity data corresponding to the provided id. |
|
Append data to the string field. |
Location of the string field. |
|
Return the number of component, always 1. |
|
Return elementary data count. |
|
Return elementary data size. |
Import detail#
from ansys.dpf.core.string_field import StringField
Property detail#
- property StringField.location#
Location of the string field.
A property field contains a scoping, which is the location that is read. To update location, directly update the scoping location.
- Returns:
location – Location string, can be found in
dpf.locations
: ie.dpf.locations.nodal
ordpf.locations.elemental
.- Return type:
str
Examples
Create a string field and request the location.
>>> from ansys.dpf import core as dpf >>> pfield = dpf.StringField() >>> list_ids = [1, 2, 4, 6, 7] >>> scop = dpf.Scoping(ids = list_ids, location = dpf.locations.nodal) >>> pfield.scoping = scop >>> pfield.scoping.location = dpf.locations.nodal >>> pfield.location 'Nodal'
- property StringField.component_count#
Return the number of component, always 1.
- property StringField.elementary_data_count#
Return elementary data count.
- property StringField.size#
Return elementary data size.
Method detail#
- StringField.get_entity_data(index)#
Return entity data.
- StringField.get_entity_data_by_id(id)#
Return entity data corresponding to the provided id.
- StringField.append(data: List[str], scopingid: int)#
Append data to the string field.
This method appends data to the string field for a specific scoping ID.