How to extract fields container from a h5 result file, using result name that appears in hdf viewer?

Rohith Patchigolla
Rohith Patchigolla Member, Moderator, Employee Posts: 218
100 Comments 25 Answers Second Anniversary 25 Likes
✭✭✭✭

How to extract via Mechanical scripting console data from h5 file, based on the result names that appear in hdf viewer file?

Tagged:

Comments

  • Rohith Patchigolla
    Rohith Patchigolla Member, Moderator, Employee Posts: 218
    100 Comments 25 Answers Second Anniversary 25 Likes
    ✭✭✭✭

    In Mechanical, you can extract the fields container using the result name in the hdf viewer, "S_data" using custom result operator as shown below.

    import mech_dpf
    import Ans.DataProcessing as dpf 
    mech_dpf.setExtAPI(ExtAPI)
    
    filepath = r"D:\h5\dpf.h5"
    dataSource = dpf.DataSources()
    dataSource.SetResultFilePath(filepath,"h5dpf")
    
    model_h5 = dpf.Model(dataSource)
    
    op2 = dpf.operators.serialization.hdf5dpf_custom_read()
    op2.inputs.data_sources.Connect(dataSource)
    op2.inputs.result_name.Connect("BFE_data")
    bfe_fc = op2.outputs.field_or_fields_container.GetDataT1()
    
  • Mike.Thompson
    Mike.Thompson Member, Employee Posts: 366
    25 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭

    @Rohith Patchigolla , can you provide example of how you generated such an h5 file?
    Are there any further options to configure the reading? For example the different items are under “Results” path, but that seems assumed as it is not specified directly in the operator inputs.

    Lastly, anything to get a DPF mesh from the h5 instead of fields?