dpf.FieldsContainer item access by label name

Rajesh Meena
Rajesh Meena Moderator, Employee Posts: 105
Second Anniversary 10 Comments 5 Answers Solution Developer Community of Practice Member
✭✭✭✭

I've explored the capabilities of Data Processing Framework (DPF) in getting and processing data of Mechanical analysis for possible application in ACT-extension. dpf.FieldsContainer is the object that stores results data for particular entity and time scoping. Target entity is a 'Location', result set is 'time scoping' labeled as 'Time'. I can access the data from defined location and time scoping using AddFieldByTimeId(timeid) method. All had gone well before I tried to get data from field with more than one label! In case the field has more than one label the method AddFieldByTimeId(timeid) doesn't work because timeid is only argument for method and it is not enough to get data (see the following listing):

>>>mystresses1
DPF stress(s)Fields Container
with 4 field(s)
defined on labels: elshape time

with:
- field 0 {elshape: 2, time: 1} with Nodal location, 1 components and 1 entities.
- field 1 {elshape: 1, time: 1} with Nodal location, 1 components and 1 entities.
- field 2 {elshape: 2, time: 2} with Nodal location, 1 components and 1 entities.
- field 3 {elshape: 1, time: 2} with Nodal location, 1 components and 1 entities.
>>>mystresses1.GetFieldByTimeId(1)
the label space request in this collection has more than one entry, to get an entry, be more specific, the labels are: [elshape, time]

There is get_fields(self, label_space) method in dpf.FieldsContainer class which aims to retrieve the fields at a label space but it is not accessible 
via API (got: 'FieldsContainer' object has no attribute 'get_fields' in scripting window). This aspect is not covered by learning materials and I wonder is there a way to filter and get fields from fields container by label? Any help would be appreciated!

Tagged:

Best Answer

  • Rajesh Meena
    Rajesh Meena Moderator, Employee Posts: 105
    Second Anniversary 10 Comments 5 Answers Solution Developer Community of Practice Member
    ✭✭✭✭
    Answer ✓

    The APIs available in PyDPF and DPF in mechanical are slightly different. I guess this isn't mentioned on GitHub as the documentation there coveres APIs only for PyDPF.
    The best resource to learn about this is ALH course on DPF. In order to get details about Mechanical DPF  Ironpython APIs, follow below steps in Mechanical Scripiting console.

    1. import mech_dpf
    2. mech_dpf.help() #This would give you local help html file path.
    3. In help file, head over to APIs --> Data API --> Get Fields Container's data. For your question, use Get function. This html file will have APIs for CPython (PyDPF) and C++ as well.