FEM Meshing & Post-Processing
Relevant source files
The following files were used as context for generating this wiki page:
The FEM (Finite Element Method) Meshing & Post-Processing module provides the infrastructure for generating finite element meshes from CAD geometry and analyzing numerical results generated by solvers. The system supports multiple meshing backends, including GMSH and Netgen, and features a robust post-processing pipeline based on VTK for result visualization and data extraction.
Mesh Generation Infrastructure
Meshing in the FEM module is handled through specialized generator objects that interface with external tools. The primary generators supported are GMSH and Netgen.
Mesh Generation Workflow
The mesh generation process identifies unmeshed generator objects within an analysis container or the document and invokes the appropriate tool (e.g., GmshTools or NetgenTools). If a mesh already contains nodes, the generation is skipped unless explicitly cleared.
The diagram shows the logic for selecting and executing meshing tools based on object derivation.
Sources: src/Mod/Fem/femexamples/manager.py:112-149
Supported Mesh Elements
The system supports a variety of 2D and 3D element types during mesh reconstruction and manipulation. These are mapped to standard finite element definitions.
| Dimension | Type | Nodes | internal Label |
|---|---|---|---|
| 2D | Triangle | 3, 6 | S3, S6 |
| 2D | Quadrilateral | 4, 8 | S4, S8 |
| 3D | Tetrahedron | 4, 10 | C3D4, C3D10 |
| 3D | Pentahedron | 6, 15 | C3D6, C3D15 |
| 3D | Hexahedron | 8, 20 | C3D8, C3D20 |
| 3D | Pyramid | 5, 13 | N/A |
Sources: src/Mod/Fem/Gui/TaskCreateElementSet.cpp:44-159, src/Mod/Fem/Gui/TaskCreateElementSet.cpp:322-334
Adaptive Meshing and Refinement
The FEM module supports adaptive meshing, specifically through GMSH, where the mesh density can be controlled by mathematical equations or existing analysis results.
Refinement Logic
Refinements are added to a MeshRefinementList. Advanced mesh objects can use result fields (e.g., "von Mises Stress") to determine local element sizing. This allows for higher mesh density in areas of high stress and lower density elsewhere.
- Result Refinement: Links a mesh to a post-processing pipeline field.
- Manipulation: Smoothes or modifies existing refinements (e.g., using "Mean" delta smoothing).
- Math Refinement: Applies a
MathEvaltype where an equation (e.g.,10/(F1/1e8)) defines the characteristic length.
Sources: src/Mod/Fem/femexamples/gmsh_adaptive.py:90-115
Post-Processing Pipeline
The post-processing system transforms raw solver data into visual insights. It uses a pipeline-based approach where filters are applied sequentially to a result object.
Pipeline Filters
The VTK-based pipeline supports various filters to manipulate the visual representation of data:
- Clip Filters: Region-based clipping (using planes, spheres, cylinders, or boxes) or scalar-based clipping to isolate specific value ranges.
- Cut Filters: Slicing the data along an implicit function.
- Warp Filters: Deforming the geometry based on a vector field (e.g., scaling displacements).
- Contours: Displaying iso-surfaces or iso-lines.
- Glyphs: Adding vector arrows to mesh vertices.
The sequence demonstrates the layered application of filters on top of a mechanical result.
Sources: src/Mod/Fem/femtest/app/test_object.py:346-372
Data Extraction and Visualization
Beyond 3D visualization, the module provides tools for extracting quantitative data:
- Line Plots: Plotting field data along a specified path or over simulation frames.
- Histograms: Analyzing the distribution of scalar values across nodes.
- Tables: Exporting nodal or element data to tabular formats.
Sources: src/Mod/Fem/femtest/app/test_object.py:363-372, src/Mod/Fem/Gui/Resources/translations/Fem.ts:1533-1577
Mesh Manipulation: Element Sets
Users can create and manipulate sub-sets of mesh elements. This is often used for erasing specific elements from a results mesh to inspect internal structures or for creating specific boundary regions.
Polygon Erasure
The TaskCreateElementSet allows users to define a polygon in the 3D view. Elements whose center of gravity falls inside (or outside) the projected polygon can be kept or erased.
- Logic: The
DefineNodesfunction iterates through elements, calculates the center of gravity, projects it to 2D coordinates using the camera's view volume, and checks if it is contained within the user-defined polygon. - Persistence: Erased elements are written to a temporary Abaqus-style
.inpfile, which is then re-imported as a newFemMeshObject.
Sources: src/Mod/Fem/Gui/TaskCreateElementSet.cpp:463-589, src/Mod/Fem/Gui/TaskCreateElementSet.cpp:613-739
Result Field Definitions
The module recognizes several standard physical result types provided by solvers like CalculiX or Elmer.
| Result Type | Variables | Description |
|---|---|---|
| Displacement | x, y, z | Translational movement of nodes. |
| Stress | sxx, syy, szz, sxy... | Components of the stress tensor. |
| von Mises | vM | Equivalent stress for yielding criteria. |
| Temperature | T | Scalar thermal distribution. |
| Strain | exx, eyy, ezz... | Components of the strain tensor. |
| Flow Rate | MF | Mass flow rate for CFD. |
Sources: src/Mod/Fem/Gui/Resources/translations/Fem.ts:1143-1224
Summary
The FEM Meshing and Post-Processing module provides a complete loop from geometry to analysis. It leverages GMSH and Netgen for flexible mesh generation, including adaptive techniques. Its VTK-driven post-processing pipeline allows for complex data manipulation through filters and specialized visualization objects like histograms and line plots.