How do I create a fields container from a list of fields in DPF?
Ayush Kumar
Member, Moderator, Employee Posts: 442
✭✭✭✭
Answers
-
Let's say we have a
list
of fields -all_stress_fields
with 16 fields (1 real and 1 imaginary for a Harmonic response of 8 frequencies), then you put all these fields in a fields container using the following code:import mech_dpf mech_dpf.setExtAPI(ExtAPI) import Ans.DataProcessing as dpf my_stressx_fc = dpf.FieldsContainer() my_stressx_fc.Labels = ["time", "complex"] my_stressy_fc = dpf.FieldsContainer() for index in range(1, 9): stressx_real_field = dpf.Operator("fieldify") stressx_real_field.Connect(0, sx_mid_side.GetOutputAsFieldsContainer(0).GetFieldByTimeId(index).Data[0]) my_stressx_fc.Add(stressx_real_field.GetOutputAsField(0), {'time':index, "complex": 0}) stressx_imag_field = dpf.Operator("fieldify") stressx_imag_field.Connect(0, sx_mid_side.GetOutputAsFieldsContainer(0).GetImaginaryField(index).Data[0]) my_stressx_fc.Add(stressx_imag_field.GetOutputAsField(0), {'time':index, "complex": 1})
2