ansys.dpf.core.PropertyField#

class ansys.dpf.core.PropertyField(nentities=0, nature=natures.scalar, location=locations.nodal, property_field=None, server=None)#

Bases: ansys.dpf.core.field_base._FieldBase

Describes field properties such as connectivity.

This class is a field with integer values instead of double values.

Parameters:
  • nentities (int) – Number of entities that the property field is to contain. The default is 0.

  • nature (core.natures) – Nature of the property field, such as scalar or vector.

  • location (str, optional) – Location of the property field. Options are in ansys.dpf.core.locations. The default is ansys.dpf.core.locations.nodal.

  • field (property) – 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.

Returns:

property_field

Return type:

PropertyField

Examples

>>> from ansys.dpf import core as dpf
>>> pfield = dpf.PropertyField()
>>> list_ids = [1, 2, 4, 6, 7]
>>> scop = dpf.Scoping(ids = list_ids, location = dpf.locations.nodal)
>>> pfield.scoping = scop
>>> list_data = [20, 30, 50, 70, 80]
>>> pfield.data = list_data
_field_definition_instance = None#
property _api: ansys.dpf.gate.property_field_abstract_api.PropertyFieldAbstractAPI#
property _field_definition#
_init_api_env()#
static _field_create_internal_obj(api: ansys.dpf.gate.property_field_abstract_api.PropertyFieldAbstractAPI, 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

_load_field_definition()#

Attempt to load the field definition for this field.

property location#

Location of the property 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 ansys.dpf.core.locations: ie. dpf.locations.nodal or dpf.locations.elemental.

Return type:

str

Examples

Create a property field and request the location.

>>> from ansys.dpf import core as dpf
>>> pfield = dpf.PropertyField()
>>> 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 components.

property elementary_data_count#

Return the number of elementary data.

property size#

Return the 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 the data associated with the entity by index.

get_entity_data_by_id(id)#

Return the data associated with entity by id.

append(data, scopingid)#

Append data to the property field.

This method appends data to the property field for a specific scoping ID.

_get_data_pointer()#

First index of each entity data.

Returns:

Data in the field.

Return type:

numpy.ndarray

Notes

Print a progress bar.

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

Create a deep copy of the field locally.

This copy can then be accessed and modified locally, without a request being sent to the server. This method 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’s not used in a with statement, the method release_data() should be used to actually update the field.

Warning

If this as_local_field 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 actually be updated.

Returns:

local_field

Return type:

PropertyField

Examples

>>> from ansys.dpf import core as dpf
>>> num_entities = 5
>>> field_to_local = dpf.PropertyField(num_entities, dpf.natures.scalar)
>>> with field_to_local.as_local_field() as f:
...     for i in range(1,num_entities+1):
...         f.append(list(range(i,i+3)),i)
...         print(f.get_entity_data(i-1))
[1 2 3]
[2 3 4]
[3 4 5]
[4 5 6]
[5 6 7]
property name#

Name of the property field.

..note:

Available starting with DPF 2024.2.pre1.