Post-Processing of FEM Results with Paraview

From FreeCAD Documentation
Revision as of 12:41, 9 February 2020 by HarryvL (talk | contribs) (Created page with "Some forum posts and tutorials use Paraview (PV) to review and analyse FreeCAD FEM workbench (FEMWB) results. This tutorial explains the basics of transferring data from FEMWB...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Some forum posts and tutorials use Paraview (PV) to review and analyse FreeCAD FEM workbench (FEMWB) results. This tutorial explains the basics of transferring data from FEMWB to PV and shows some of the options and settings for displaying data.

Paraview can be downloaded on https://www.paraview.org/download/. This tutorial is based on version 5.8.0 for Windows, which was the most recent version at the time of writing the tutorial.

The files for this tutorial can be found here:

Data Transfer from FEMWB

1) In FEMWB highlight the CCX_Results object

2) Use menu option File > Export > FEM result VTK (*.vtk *.vtu)

Data import in Paraview

1) The start-up screen shows an empty Pipeline Browser. This is where VTK data objects and applied filters (for geometry or data) will be visible.



2) Use menu option File > Open > *.vtk to open the VTK file that was generated with FEMWB



3) Press Apply on the properties tab. This will show a top view (looking down along z-axis) of the geometry by default






The gray geometry can be inspected by rotating the view. The left mouse button makes the geometry swivel, but unfortunately in a difficult-to-control way (compared to FreeCAD). To get a predictable rotation hold the x, y or z key while dragging the mouse with left mouse button pressed to rotate the model around the x, y or z axis, respectively









Saving/Loading State

Rather than saving data, Paraview stores the status (state) of the actions performed on the imported VTK file. Therefore, to save your work use menu option File > Save State. NOTE: there will be no warning when leaving Paraview to save the state and all work may be lost when exiting the program.

To continue where you left off in the previous session use File > Load State. This prompts the user to specify a VTK file, which means that the actions performed in the last session can also be applied to a new VTK file. In this way, data from different FEMWB analyses can be displayed in exactly the same way, without any additional effort.


Visualise FEMWB results

Paraview has many options and settings for displaying results. We will first have a look at displaying base import data on the original geometry and thereafter see how to apply filters to modify the geometry. Finally, we will use the calculator and integration filters to derive new results by combining base import data.

Base data on original geometry

As the pipeline browser can have several VTK entires and filters, first confirm that the right VTK entry is highlighted in the pipeline browser. The selections and settings for displaying this VTK data can now be found on the properties tab. To make sure all settings are visible and aligned with this tutorial press the Advanced Settings button (the gear wheel on the below picture).



The first setting that we can change is the way data is presented on the geometry. This is done on the Representation drop down menu. For now we will only use Surface or Wireframe, but will come back to 3D Glyphs when displaying principal stresses. As expected, Surface plots results on the solid geometry and Wireframe only on the element edges of the surface,



So far no results are displayed. For this we need to change the Coloring option. The default is Solid Color, but the drop down menu shows all the scalar data that is available in the imported VTK file.




For the purpose of this tutorial we choose ReinforcementRatio_x, but it is easy to change to any data type.

The RenderView window will now show an iso-plot of the selected data type and a Color Legend of the data range.



The Color Legend can be dragged around the screen to a more convenient location and will change orientation when nearing any of the windows edges.



Alternatively, the settings of the color legend can be controlled in great detail by opening the Edit Color Legend Properties dialogue




The coloring of the iso map can be controlled through the Color Map Editor, which is activated by pressing the edit button:


The setting for Color Discretization is useful to limit the number of iso values, thus creating more practical ranges for design. The default number of ranges is 256, but here the number is limited to 10.








Applying Filters to FEMWB results

To modify the base data or geometry imported from FEMWB filters can be applied.

Here only the Slice and Warp filters will be discussed. Filters for creating compound results from base data will be discussed in the next section.

To apply the Slice filter, highlight the VTK geometry that needs to be sliced and press the Slice Icon. Alternatively, find the Slice filter in the menu Filters > Alphabetical. This adds the Slice filter to the Pipeline Browser and the location in the tree shows that it is applied to the VTK dataset. The position in the tree matters, because filters can be applied to different data sets or even to other filters. The Filter cannot be dragged around in the tree to change the object it is applied to. This can only be changed through the menu (or right-clicking) Edit > Change Input.



The location and orientation of the slice can be modified by dragging the slice and its normal vector with the mouse or through the Properties tab. In the below figure the origin of the slice has been placed at the center of the beam (over the central support) and the normal to the plane points in the x-direction.



To get rid of the bounding boxes deselect the Show Plane box at the top of the Plane Parameters dialogue.



The Warp by Vector filter can be used to display the deformed geometry. Highlight the VTK dataset and press the Warp by Vector Icon. This adds the filter to the Pipeline Browser. Alternatively look for the filter in the menu Filters > Alphabetical. Next select Displacement in the Vectors drop-down menu of the Properties tab and set an appropriate scale factor. Don’t forget to press the Apply button after changing the settings.



The maximum displacement value is 0.98 mm.

To show the deformed geometry superimposed on the undeformed geometry, simply make both the VTK dataset and Warp filter visible by clicking the eye icon next to it. In the following picture the Representaion setting for the VTK dataset was changed to Wireframe and the Opacity reduced to 0.5 to prevent it from obscuring the Deformed geometry.




Applying Filters to Derive Compound Results from Base Import Data

If we want to know the amount of reinforcement steel in the beam as a whole or the amount passing though a particular cross section we need to perform integration (summation over the geometry) of the base data.

For example, the total volume of reinforcement bars in the beam running in x-direction is obtained from the integral INTEGRATE(ReinforcementRatio_x * dx * dy * dz) over the full geometry and the total area of reinforcement steel running though a particular beam cross section is obtained from INTEGRATE(ReinforcementRatio_x * dy * dz) over a slice.

In Paraview, integration can be done with an Integration Filter. This filter can be applied to the full dataset (the beam) or to a Slice (the cross section).

NOTE: due to a mismatch of node ordering between FCFEM and PV, integration over a volume renders negative results, i.e. INTEGRATE( 1.0 * dx * dy *dz) = - Volume instead of+ Volume.

To calculate integrals we need to apply an Integration Filter, which can be found in the menu item Filters > Alphabetical. Highlight the VTK result object and apply the filter.


Press the Apply button in the Properties tab and the results will open in a separate window to the right of the Renderview.








Before we tidy this up to find the desired result, i.e. INTEGRATE(ReinforcementRatio_x * dx * dy * dz), lets first see how we can control where the window is placed and what it contains.

First close the SpreadSheetView window that has opened to the right. Then press the horizontal split icon on the Renderview window and a new window will open with a menu of display options. Before selecting an option, make sure the Integration filter is highlighted in the Pipeline Browser.



To display numerical results we need to select SpreadSheet View at the bottom of the Create View list. This generate a spreadsheet of all available results in the VTK object integrated over the volume.


To inspect INTEGRATE(ReinforcementRatio_x * dx * dy * dz) we could scroll to the right through the table, but we can also remove all unwanted results by deselecting them, i.e. deselect All Columns and select ReinforcementRatio_x.

Now we are left with just one value in the table of integration results


As explained before this is the negative value of the integral we are looking for. So the indicative total volume of steel required in x direction is 2.27e+06 mm3 (= 2272 cm3) or 2272 cm3 * 7.6 g/cm3 = 17267 g (= 17.3 kg). In practice the number will be higher due to practical considerations (e.g. anchoring requirements, minimum reinforcement requirements, etc.). However it can be used as a way to compare conceptual designs.


The above was an example of the integration of a variable directly exported by FEMWB. In some cases we may want to combine VTK variables to obtain new results. This can be done in several ways, but here I will only discuss the simplest, i.e. using the Calculator Filter.

For example, if we want to know the total reinforcement requirement in all three coordinate directions we would have to sum ReinforcementRatio_x, ReinforcementRatio_y and ReinforcementRatio_z.

The Calculator filter can be found as an icon on the left of the filter bar or via the menu Filters > Alphabetical. The name for the resulting variable can be entered in field Result Array Name. Here we name the result Total_Reinforcement_Ratio. The formula can be composed in the box below the Result Array Name field. Input values can be selected from the Scalars drop down menu and they can be combined into a formula for the result using the operators given. After pressing the Apply button, the result will be available as a new variable in any subsequent operations (e.g. an Integration Filter) or views (e.g. RenderView or SpreadSheetView, see below).




For example, we can now apply the integration filter to the new variable Total Reinforcement Ratio



This shows how the total reinforcement requirements compares to that in the individual coordinate directions.

Integration over a Line

Work in progress ...

Representation of Vector Results with Glyph 3D

So far we have only dealt with Scalar values, like reinforcement ratio and displacement magnitude. Visualization of vector results, like Principal Stress vectors, is done with Glyphs.

Let’s start again with the VTK data object for the beam and visualize maximum and minimum principal stress vectors.

Highlight the VTK data object in the Pipeline Browser and select the Glyph Filter from the Filter Icon bar or from the menu option Filter > Alphabetical. Then apply the following settings in the Properties tab of the Glyph Filter object (see table and picture):

Properties Tab Settings Comment Glyph Source > Glyph Type: Line Unfortunately there is no option for a double sided arrow Orientation > Orientation: Major Principal Stress The Glyph takes the principal stress direction Scale > Scale Array: Major Principal Stress The length of the line will represent the magnitude of the principal stress Scale > Vector Scale Mode: Scale by Magnitude

Scale > Scale Factor: 100 Or any other setting that gives a pleasing result Masking > Glyph Mode: All Points To make sure the stress in every node is displayed Coloring > Solid Color A single color gives greatest clarity of “stress flow” Coloring > Edit > Green Or any other setting that gives a pleasing result Styling > Line Width > 2 Or any other setting that gives a pleasing result




If all goes well you should see the following result for the example file.



Next add another Glyph Filter with the following settings for the Minor Principal Stress (don’t forget to first highlight the VTK data object in the Pipeline Browser):

Properties Tab Settings Comment Glyph Source > Glyph Type: Line Unfortunately there is no option for a double sided arrow Orientation > Orientation: Minor Principal Stress The Glyph takes the principal stress direction Scale > Scale Array: Minor Principal Stress The length of the line will represent the magnitude of the principal stress Scale > Vector Scale Mode: Scale by Magnitude

Scale > Scale Factor: 100 Or any other setting that gives a pleasing result Masking > Glyph Mode: All Points To make sure the stress in every node is displayed Coloring > Solid Color A single color gives greatest clarity of “stress flow” Coloring > Edit > Red Or any other setting that gives a pleasing result Styling > Line Width > 2 Or any other setting that gives a pleasing result



The final result shows the major and minor principal stress vectors superimposed on the beam with ReinforcementRatio_x.

Export of Graphical Results

To export a RenderView window highlight the window and use menu option File > Save Screenshot