ansys.dpf.core.StringField ========================== .. py:class:: ansys.dpf.core.StringField(nentities=0, string_field=None, server=None) Bases: :py:obj:`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. :param nentities: Number of entities that the string field is to contain (reserved). The default is ``0``. :type nentities: int :param string_field: Field message generated from a gRPC stub, or returned by DPF's C clients. :type string_field: Field, ansys.grpc.dpf.field_pb2.Field, ctypes.c_void_p, optional :param server: 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. :type server: server.DPFServer, optional .. rubric:: 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 .. rubric:: Notes Class available with server's version starting at 5.0 (Ansys 2023R1). .. py:attribute:: _server .. py:property:: _api :type: ansys.dpf.gate.string_field_abstract_api.StringFieldAbstractAPI .. py:method:: _init_api_env() .. py:method:: _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) :staticmethod: Return a gRPC field message or C object instance of a new field. This new field is created with this functions parameter attributes :param client: :type client: None, GrpcClient, GrpcServer :param snature: Nature of the field entity data. For example: - :class:`ansys.dpf.core.natures.matrix` - :class:`ansys.dpf.core.natures.scalar` :type snature: str :param num_entities: Number of entities to reserve. :type num_entities: int :param location: Location of the field. For example: - :class:`ansys.dpf.core.natures.nodal` (``"Nodal"``) - :class:`ansys.dpf.core.natures.elemental` (``"Elemental"``) - :class:`ansys.dpf.core.natures.elemental_nodal` (``"ElementalNodal"``) - ... :type location: str, optional :param ncomp_n: Number of lines. :type ncomp_n: int :param ncomp_m: Number of columns. :type ncomp_m: int :returns: **field** -- DPF field in the requested format. :rtype: field_pb2.Field or ctypes.void_p .. py: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``. :rtype: str .. rubric:: 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' .. py:property:: component_count Return the number of component, always 1. .. py:property:: elementary_data_count Return elementary data count. .. py:property:: size Return elementary data size. .. py:method:: _set_scoping(scoping) Set the scoping. :param scoping: :type scoping: :class:`ansys.dpf.core.scoping.Scoping` .. py:method:: _get_scoping() Retrieve the scoping. :returns: **scoping** :rtype: :class:`ansys.dpf.core.scoping.Scoping` .. py:method:: get_entity_data(index) Return entity data. .. py:method:: get_entity_data_by_id(id) Return entity data corresponding to the provided id. .. py:method:: 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. .. py:method:: _get_data(np_array=True) .. py:method:: _set_data(data)