BodyFieldsContainer
#
- class ansys.dpf.core.custom_fields_container.BodyFieldsContainer(fields_container=None, server=None)#
Bases:
ansys.dpf.core.fields_container.FieldsContainer
Represents a fields container with fields split by a body.
Instances of this class are created when a model result is split by a body, which is an MAPDL material property.
- Parameters:
fields_container (ansys.grpc.dpf.collection_pb2.Collection or FieldsContainer, optional) – Fields container created from either a collection message or by copying an existing fields container. The default is
None
.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 >>> from ansys.dpf.core import examples >>> model = dpf.Model(examples.download_all_kinds_of_complexity_modal()) >>> fc = model.results.displacement.on_all_time_freqs.split_by_body.eval() >>> fc.get_mat_scoping().ids[3] np.int32(45) >>> len(fc.get_fields_by_mat_id(45)) 45 >>> f_time_2 = fc.get_field_by_mat_id(45, timeid=2)
Overview#
Retrieve a list of all fields for a material ID. |
|
Retrieve a field with a given material ID. |
|
Retrieve the material or body scoping containing material IDs. |
Import detail#
from ansys.dpf.core.custom_fields_container import BodyFieldsContainer
Method detail#
- BodyFieldsContainer.get_fields_by_mat_id(matid, timeid=None, complexid=None)#
Retrieve a list of all fields for a material ID.
You can filter the list of fields for a material ID based on a given time, complex type, or both.
- Parameters:
matid (int, optional) – Material ID. To request available material IDs, you can use the get_mat_scoping method.
timeid (int, optional) – Time ID for filtering fields with the given material ID.
complexid (int, optional) – Complex type ID for filtering fields with the given material ID. 0 is for real numbers, and 1 is for imaginary numbers.
- Returns:
List of fields corresponding to the request.
- Return type:
List
Examples
>>> from ansys.dpf import core as dpf >>> from ansys.dpf.core import examples >>> model = dpf.Model(examples.download_all_kinds_of_complexity_modal()) >>> fc = model.results.displacement.on_all_time_freqs.split_by_body.eval() >>> len(fc.get_fields_by_mat_id(1)) 45 >>> len(fc.get_fields_by_mat_id(1, timeid=3)) 1
- BodyFieldsContainer.get_field_by_mat_id(matid, timeid=None, complexid=None)#
Retrieve a field with a given material ID.
You can filter the field based on a given time, complex type, or both.
- Parameters:
matid (int, optional) – Material ID. To request available material IDs, you can use the get_mat_scoping method.
timeid (int, optional) – Time ID for filtering fields with the given material ID.
complexid (int, optional) – Complex type ID for filtering fields with the given material ID. 0 is for real numbers, and 1 is for imaginary numbers.
- Returns:
Field corresponding to the request.
- Return type:
Examples
>>> from ansys.dpf import core as dpf >>> from ansys.dpf.core import examples >>> model = dpf.Model(examples.download_all_kinds_of_complexity_modal()) >>> fc = model.results.displacement.on_all_time_freqs.split_by_body.eval() >>> f_time_2 = fc.get_field_by_mat_id(45, timeid=2)