PropertyFieldsContainer#
- class ansys.dpf.core.property_fields_container.PropertyFieldsContainer(property_fields_container: PropertyFieldsContainer | None = None, server: ansys.dpf.core.server_types.AnyServerType | None = None, entries_type: type = property_field.PropertyField)#
Bases:
ansys.dpf.core.collection.Collection[ansys.dpf.core.property_field.PropertyField]Represents a property fields container, which is a collection of property fields.
A property fields container is a collection of property fields ordered by labels and IDs. Each property field in the collection has an ID for each label, allowing flexible organization and retrieval of property fields based on various criteria.
- Parameters:
property_fields_container (ansys.grpc.dpf.collection_message_pb2.Collection, ctypes.c_void_p,) – PropertyFieldsContainer, optional Property fields container created from either a collection message or by copying an existing one. The default is
None.server (ansys.dpf.core.server, 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
Create a property fields container from scratch.
>>> from ansys.dpf import core as dpf >>> pfc = dpf.PropertyFieldsContainer() >>> pfc.labels = ['time', 'body'] >>> for i in range(0, 5): ... label_space = {"time": i+1, "body": 0} ... pfield = dpf.PropertyField() ... pfield.data = list(range(i*10, (i+1)*10)) ... pfc.add_entry(label_space, pfield)
Overview#
Create classes deriving from Collection at runtime for a given subtype. |
Create dpf instance of any type, which has been cast to its original type. |
|
Retrieve the entries at a label space. |
|
Retrieve the entry at a requested index or label space. |
|
Add or update the entry at a requested label space. |
|
Set labels for scoping the collection. |
|
Add the requested label to scope the collection. |
|
Check if a collection has a specified label. |
|
Retrieve the indices of the entries corresponding a requested label space . |
|
Retrieve the label space of an entry at a requested index. |
|
Retrieve the IDs assigned to an input label. |
|
Retrieve the scoping for an input label. |
|
Set the support of the collection for a given label. |
|
Get the support of the collection for a given label. |
Create a collection of integral type with a list. |
Retrieve the entry at a requested index value. |
|
Describe the entity. |
|
Retrieve the number of entries. |
|
Delete the entry. |
|
Provide for looping through entry items. |
Import detail#
from ansys.dpf.core.property_fields_container import PropertyFieldsContainer
Property detail#
- property PropertyFieldsContainer.name#
Name of the Collection.
Notes
Available starting with DPF 2024 R2 pre0.
- Return type:
str
- property PropertyFieldsContainer.labels: List[str]#
Provides for getting scoping labels as a property.
- Returns:
List of labels scoping the collection.
- Return type:
List[str]
Attribute detail#
- PropertyFieldsContainer.entries_type: type[TYPE] | None#
- PropertyFieldsContainer.owned = False#
Method detail#
- PropertyFieldsContainer.create_subtype(obj_by_copy)#
Create dpf instance of any type, which has been cast to its original type.
- PropertyFieldsContainer.get_entries(label_space)#
Retrieve the entries at a label space.
- Parameters:
label_space (dict[str,int]) – Entries corresponding to a filter (label space) in the input. For example:
{"elshape":1, "body":12}- Returns:
entries – Entries corresponding to the request.
- Return type:
list[self.type]
- PropertyFieldsContainer.get_entry(label_space_or_index) T#
Retrieve the entry at a requested index or label space.
Raises an exception if the request returns more than one entry.
- Parameters:
label_space_or_index (dict[str,int] , int) – Scoping of the requested entry, such as
{"time": 1, "complex": 0}or the index of the mesh.- Returns:
entry – Entry corresponding to the request.
- Return type:
self.type
- PropertyFieldsContainer.add_entry(label_space, entry)#
Add or update the entry at a requested label space.
- Parameters:
label_space (dict[str,int]) – Label space of the requested meshes. For example, {“elshape”:1, “body”:12}.
entry (self.type) – DPF entry to add or update.
- classmethod PropertyFieldsContainer.collection_factory(subtype: Type[S]) Type[Collection[S]]#
Create classes deriving from Collection at runtime for a given subtype.
This factory method dynamically creates a new class that inherits from Collection and is specialized for storing entries of the specified subtype.
- Parameters:
subtype (type) – Any recognized DPF type. For example, CustomTypeField, GenericDataContainer, StringField, Operator, etc. This type will be used as the entries_type for the new collection class.
- Returns:
A new class that inherits from Collection and is specialized for the given subtype. The class name will be “{subtype.__name__}sCollection”.
- Return type:
Type[Collection[S]]
Examples
>>> from ansys.dpf.core.string_field import StringField >>> from ansys.dpf.core.collection import Collection >>> string_fields_collection = Collection.collection_factory(StringField)() >>> string_fields_collection.__class__.__name__ 'StringFieldsCollection' >>> string_fields_collection.entries_type.__name__ 'StringField'
- static PropertyFieldsContainer.integral_collection(inpt, server: ansys.dpf.core.server_types.BaseServer = None)#
Create a collection of integral type with a list.
The collection of integral is the equivalent of an array of data sent server side. It can be used to efficiently stream large data to the server.
- Parameters:
inpt (list[float], list[int], numpy.array) – list to transfer server side
- Return type:
Notes
Used by default by the
'Operator'and the``’Workflow’`` when a list is connected or returned.
- PropertyFieldsContainer.set_labels(labels)#
Set labels for scoping the collection.
- Parameters:
labels (list[str], optional) – Labels to scope entries to. For example,
["time", "complex"].
- PropertyFieldsContainer.add_label(label, default_value=None)#
Add the requested label to scope the collection.
- Parameters:
label (str) – Labels to scope the entries to. For example,
"time".default_value (int, optional) – Default value for existing fields in the collection. The default is
None.
Examples
>>> from ansys.dpf import core as dpf >>> coll = dpf.FieldsContainer() >>> coll.add_label('time')
- PropertyFieldsContainer.has_label(label) bool#
Check if a collection has a specified label.
- Parameters:
label (str) – Label to search for. For example,
"time".- Returns:
Truewhen successful,Falsewhen failed.- Return type:
bool
Examples
>>> from ansys.dpf import core as dpf >>> coll = dpf.FieldsContainer() >>> coll.add_label('time') >>> coll.has_label('time') True
>>> coll.has_label('complex') False
- PropertyFieldsContainer.get_entries_indices(label_space)#
Retrieve the indices of the entries corresponding a requested label space .
Notes
Available starting with DPF 2025R1.
- Parameters:
label_space (dict[str,int]) – Label space or index. For example,
{"time": 1, "complex": 0}or the index of the field.- Returns:
indices – Indices of the entries corresponding to the request.
- Return type:
list[int], list[Field], list[MeshedRegion]
- PropertyFieldsContainer.get_label_space(index)#
Retrieve the label space of an entry at a requested index.
- Parameters:
index (int) – Index of the entry.
- Returns:
label_space – Scoping of the requested entry. For example,
{"time": 1, "complex": 0}.- Return type:
dict(str:int)
- PropertyFieldsContainer.get_available_ids_for_label(label='time')#
Retrieve the IDs assigned to an input label.
- Parameters:
label (str) – Name of the input label. The default is
"time".- Returns:
ids – List of IDs assigned to the input label.
- Return type:
list[int]
- PropertyFieldsContainer.get_label_scoping(label='time')#
Retrieve the scoping for an input label.
This method allows you to retrieve a list of IDs for a given input label in the collection. For example, if the label
el_typeexists in the collection, you can use the get_lable_scoping method to retrieve a list of IDS with this label. You can then use these IDs to request a given entity inside the collection.- Parameters:
label (str) – Name of the input label.
- Returns:
scoping – IDs scoped to the input label.
- Return type:
- PropertyFieldsContainer.__getitem__(index)#
Retrieve the entry at a requested index value.
- PropertyFieldsContainer.set_support(label: str, support: ansys.dpf.core.support.Support) None#
Set the support of the collection for a given label.
Notes
Available starting with DPF 2023 R1.
- PropertyFieldsContainer.get_support(label: str) ansys.dpf.core.support.Support#
Get the support of the collection for a given label.
Notes
Available starting with DPF 2023 R1.
- PropertyFieldsContainer.__str__()#
Describe the entity.
- Returns:
description – Description of the entity.
- Return type:
str
- PropertyFieldsContainer.__len__()#
Retrieve the number of entries.
- PropertyFieldsContainer.__del__()#
Delete the entry.
- PropertyFieldsContainer.__iter__()#
Provide for looping through entry items.