Macro export transient FEM results/pl

Description
This macro exports multiple FEM result objects from a transient analysis to the VTK format and generates a PVU file which can be used to load the results directly into ParaView for post-processing.

Background
A transient analysis in FreeCAD ends up with a bunch of FEM result objects, one for each timestamp. The individual results can be investigated directly in FreeCAD and be post-processed using pipelines. However, the possibilities within FreeCAD are still limited, especially for transient analyses. A better tool for post-processing and visualisation is ParaView. You can export single FEM result objects from FreeCAD as a .vtk or .vtu file, which can then be opened with ParaView. Unfortunately, the FEM workbench doesn't support the export of multiple .vtk files at one time (yet). That's where this macro comes into play.

How to use (experienced users)
Run the macro on a FreeCAD project that includes several FEM result objects from a transient analysis. Besides the .FCStd file, a new folder 'vtk-export' will be created, containing the individual results (.vtu files), and a .pvu file that can be opened from ParaView.

How to use (step-by-step with example)
As an example, the bending of a aluminium/steel bimetal strip is used. A step-by-step guide to create the sample file is given here, or you can download the file from the downloads section of this page. Save the FCMacro file in the FreeCAD macro folder, which can be found via Edit → Preferences → General → Macro.

With the example file opened, we go to Macro → Macros..., select "ExportTransientResults_190830.FCMacro" (or whatever name you saved it as) and execute it. The macro will now create a subfolder 'vtk-export' besides the .FCStd file. Depending on the number and size of the result objects, this may take some time. In the Report View (View → Report View), we should see 'Macro finished', if eveything went fine - or some error messages. (Note: Sometimes messages like 'PropertyFloatList NOT exported to vtk' appear, but I was able to work with the VTK files anyway...) In the subfolder 'vtk-export', we will find .vtu files, one for each result set for each timestamp. Additionally, a .pvd file is created, which tells ParaView which result set belongs to which timestamp.

Now, we open ParaView and go to File → Open... and open the .pvd file. In the 'Properties' tab, we click 'Apply' to load the results. In the 'Information' tab we will see a list of Index and Value, corresponding to the timestamps of the results that we just imported. (Of course, it always makes sense to check if the times given here are correct or if something strange happened during the export.) From here, we can use ParaView to play around with the results. Since ParaView offers a lot of possibilities, please refer to the appropriate documentations around the internet.

For demonstrating purposes, let us now visualise the temperature of the bent bimetal strip: In the 'properties' tab on the left, under 'coloring' we select temperature, and the image gets color-mapped according to the local temperature. Via the little icon with a heart, we select the color scale 'cool to warm'. With the recorder-like icons on the top, we can move through all the individual results that were created during the analysis. The 'play' button will display the individual images in their sequence. However, the individual results are not separated by a constant time interval, so the animation is not proportional in time.

What we need is an interpolation of the results in between the time steps, which is available via Filters → Temporal → Temporal Interpolator. Here we choose again the temperature for coloring. In the 'animation view' (View → Animation View), we can now switch from 'sequence' mode to 'real time' mode. We can also set the start time (default is 0.01 s), the end time, and the duration. While start and end time refer to simulation time, the duration is the actual real time that the animation takes to play completely. With 10 s duration, our 60 s simulation time will be squeezed into 10 s real time.

We go one step further and want to visualise the actual bending of the strip. With the Temporal Interpolator selected, we add Filters → Common → Warp by Vector. Under 'vectors' we choose 'DisplacementVectors' and set the 'scale factor' to 10. When we play the animation now, we can actually see the color-mapped strip bending (exaggerated by a factor of 10).



The post-processing we have just done can be saved as a 'state' in ParaView, which can be opened any time again and even be applied to a different set of results.

Downloads

 * Macro file (3 kB)
 * Example file without results (200 kB)
 * Example file with results (10 MB)
 * All example files, including the vtk-export folder (21 MB)

Script
The ToolBar Icon

Macro_export_transient_FEM_results.FCMacro

Link
Example Transient FEM analysis

The Forum discussion Export transient FEM results to vtk/vtu for ParaView