ansys.dpf.core.StringField#

class ansys.dpf.core.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).

_server#
property _api: ansys.dpf.gate.string_field_abstract_api.StringFieldAbstractAPI#
_init_api_env()#
static _field_create_internal_obj(api: ansys.dpf.gate.string_field_abstract_api.StringFieldAbstractAPI, client, nature, nentities, location=locations.nodal, ncomp_n=0, ncomp_m=0, with_type=None)#

Return a gRPC field message or C object instance of a new field.

This new field is created with this functions parameter attributes

Parameters:
  • client (None, GrpcClient, GrpcServer)

  • snature (str) –

    Nature of the field entity data. For example:

  • num_entities (int) – Number of entities to reserve.

  • location (str, optional) –

    Location of the field. For example:

    • ansys.dpf.core.natures.nodal ("Nodal")

    • ansys.dpf.core.natures.elemental ("Elemental")

    • ansys.dpf.core.natures.elemental_nodal ("ElementalNodal")

  • ncomp_n (int) – Number of lines.

  • ncomp_m (int) – Number of columns.

Returns:

field – DPF field in the requested format.

Return type:

field_pb2.Field or ctypes.void_p

property 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 or dpf.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 component_count#

Return the number of component, always 1.

property elementary_data_count#

Return elementary data count.

property size#

Return elementary data size.

_set_scoping(scoping)#

Set the scoping.

Parameters:

scoping (ansys.dpf.core.scoping.Scoping)

_get_scoping()#

Retrieve the scoping.

Returns:

scoping

Return type:

ansys.dpf.core.scoping.Scoping

get_entity_data(index)#

Return entity data.

get_entity_data_by_id(id)#

Return entity data corresponding to the provided id.

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.

_get_data(np_array=True)#
_set_data(data)#