PropertyField#

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

Overview#

get_entity_data

Return the data associated with the entity by index.

get_entity_data_by_id

Return the data associated with entity by id.

append

Append data to the property field.

as_local_field

Create a deep copy of the field locally.

location

Location of the property field.

component_count

Return the number of components.

elementary_data_count

Return the number of elementary data.

size

Return the data size.

name

Name of the property field.

Import detail#

from ansys.dpf.core.property_field import PropertyField

Property detail#

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

Return the number of components.

property PropertyField.elementary_data_count#

Return the number of elementary data.

property PropertyField.size#

Return the data size.

property PropertyField.name#

Name of the property field.

..note:

Available starting with DPF 2024.2.pre1.

Method detail#

PropertyField.get_entity_data(index)#

Return the data associated with the entity by index.

PropertyField.get_entity_data_by_id(id)#

Return the data associated with entity by id.

PropertyField.append(data, scopingid)#

Append data to the property field.

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

PropertyField.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]