FEM MeshGmshFromShape/en: Difference between revisions
(Updating to match new version of source page) |
(Updating to match new version of source page) |
||
(14 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<languages/> |
<languages/> |
||
{{UnfinishedDocu{{#translation:}}}} |
|||
{{Docnav |
{{Docnav |
||
|[[FEM_MeshNetgenFromShape|FEM mesh from shape by Netgen]] |
|[[FEM_MeshNetgenFromShape|FEM mesh from shape by Netgen]] |
||
|[[FEM_MeshBoundaryLayer|FEM mesh boundary layer]] |
|[[FEM_MeshBoundaryLayer|FEM mesh boundary layer]] |
||
|[[ |
|[[FEM_Workbench|FEM]] |
||
|IconL=FEM_MeshNetgenFromShape. |
|IconL=FEM_MeshNetgenFromShape.svg |
||
|IconR=FEM_MeshBoundaryLayer.svg |
|||
|IconC=Workbench_FEM.svg |
|IconC=Workbench_FEM.svg |
||
|IconR=Fem-femmesh-boundary-layer.svg |
|||
}} |
}} |
||
Line 13: | Line 13: | ||
|Name=FEM MeshGmshFromShape |
|Name=FEM MeshGmshFromShape |
||
|MenuLocation=Mesh → FEM mesh from shape by Gmsh |
|MenuLocation=Mesh → FEM mesh from shape by Gmsh |
||
|Workbenches=[[ |
|Workbenches=[[FEM_Workbench|FEM]] |
||
|Shortcut=None |
|||
|SeeAlso=[[FEM_tutorial|FEM tutorial]] |
|SeeAlso=[[FEM_tutorial|FEM tutorial]] |
||
}} |
}} |
||
Line 20: | Line 19: | ||
==Description== |
==Description== |
||
For a finite elements analysis the geometry needs to be discretized into a [[FEM_Mesh]]. This command uses |
For a finite elements analysis the geometry needs to be discretized into a [[FEM_Mesh|FEM Mesh]]. This command uses the software [https://en.wikipedia.org/wiki/Gmsh Gmsh] (which needs to be installed on the system) to generate the mesh. |
||
Depending on your operating system and your installation package, Gmsh might be bundled with FreeCAD or not. For further information see [[FEM_Install|FEM Install]]. |
|||
==Usage== |
==Usage== |
||
# Select the shape you want to analyze. For volume FEM this needs to be a solid or compsolid. A compsolid is necessary if your part is made from multiple materials. (A compsolid can be created with the [[Part_BooleanFragments|BooleanFragments]] command.) |
# Select the shape you want to analyze. For volume FEM this needs to be a solid or compsolid. A compsolid is necessary if your part is made from multiple materials. (A compsolid can be created with the [[Part_BooleanFragments|BooleanFragments]] command.) |
||
# Press the {{ |
#* Press the {{Button|[[Image:FEM_MeshGmshFromShape.svg|16px]] [[FEM_MeshGmshFromShape|FEM mesh from shape by Gmsh]]}} button. |
||
#* Select the {{MenuCommand|Mesh → [[Image:FEM_MeshGmshFromShape.svg|16px]] FEM mesh from shape by Gmsh}} option from the menu. |
|||
# Optionally edit the minimal and maximal element size |
# Optionally edit the minimal and maximal element size (autodetection often creates meshes that are too coarse). |
||
# Click the {{ |
# Click the {{Button|Apply}} button and wait for the generation of the mesh to complete. |
||
# Close the task. You now should see a new FEMMeshGMSH object in your active analysis container. |
# Close the task. You now should see a new FEMMeshGMSH object in your active analysis container. |
||
After the mesh has been created, you can change its properties using the [[Property_editor|property editor]]. After you change a property, you must reopen the Gmsh dialog again and click the {{Button|Apply}} button (you can leave the dialog open while changing properties). |
|||
== Properties == |
|||
* {{PropertyData|Algorithm2D}}: The algorithm to create 2D meshes. The different algorithms are [https://gmsh.info/doc/texinfo/gmsh.html#Choosing-the-right-unstructured-algorithm explained here]. For Delaunay, see [https://en.wikipedia.org/wiki/Delaunay_triangulation Delaunay triangulation]. |
|||
* {{PropertyData|Algorithm3D}}: The algorithm to create 3D meshes. The different algorithms are [https://gmsh.info/doc/texinfo/gmsh.html#Choosing-the-right-unstructured-algorithm explained here]. |
|||
* {{PropertyData|Characteristic Length Max}}: The maximal size of the mesh elements. If set to ''0.0'', the size will be set automatically. This property can also be changed in the Gmsh dialog in the field '''Max element size'''. |
|||
* {{PropertyData|Characteristic Length Min}}: The minimal size of the mesh elements. If set to ''0.0'', the size will be set automatically. This property can also be changed in the Gmsh dialog in the field '''Min element size'''. |
|||
* {{PropertyData|Coherence Mesh}}: |
|||
** true (default); duplicate mesh nodes will be removed |
|||
** false |
|||
* {{PropertyData|Element Dimension}}: The dimension of the mesh elements. This property can also be changed in the Gmsh dialog in the field '''Mesh element dimension'''. |
|||
** From Shape (default); the dimension will be determined from the dimension of the object that is meshed |
|||
** 1D |
|||
** 2D |
|||
** 3D |
|||
* {{PropertyData|Element Order}}: The [https://www.comsol.de/support/knowledgebase/1270 mesh element order]. This property can also be changed in the Gmsh dialog in the field '''Mesh order'''. {{Version|0.20}} |
|||
** 1st |
|||
** 2nd (default)</br>'''Note:''' If you use the solver [[FEM_SolverElmer|Elmer]] you may get this error: ''ERROR:: GetEdgeBasis: Can't handle but linear elements, sorry.'' This means the solver equation cannot handle 2nd order meshes. Use either 1st order meshes then, or check the FreeCAD Wiki page for the solver equation for possible options to handle 2nd order meshes. |
|||
* {{PropertyData|Geometrical Tolerance}}: The geometrical tolerance for the mesh to match the object edges. The default ''0.0'' means that Gmsh's default of 1e-8 is used. |
|||
* {{PropertyData|Groups Of Nodes}}: All nodes and not only the elements will be saved for each physical mesh group. Physical groups are collections of mesh entities (points, curves, surfaces and volumes). They and are identified by their dimension and by a tag. For example a mesh of the same object region is internally tagged the same. So all surfaces of this region will form one physical group. |
|||
* {{PropertyData|High Order Optimize}}: If and how meshes with {{PropertyData|Element Order}} = ''2nd'' are optimized. The optimization is done by a deformation of the element borders.</br>{{Version|0.20}} Gmsh supports different optimization algorithms. '''Elastic''' is an algorithm in which the mesh elements are treated as a collection of deformable viscoelastic solids. 1st order meshes cannot be optimized because their element borders are linear an cannot be deformed. |
|||
* {{PropertyData|Mesh Size From Curvature}} {{Version|0.20}}: The number of mesh elements per <math>2\pi</math> times the radius of the curvature. To get a finer mesh at small corners or holes, this value can be increased for better results |
|||
[[Image:FEM_Gmsh-MeshSizeFromCurvature.png|450px]] |
|||
{{Caption|Effect of ''Mesh Size From Curvature'''; left: set to 12, right: deactivated}} |
|||
* {{PropertyData|Optimize Netgen}}: Whether the mesh will be optimized using the 3D mesh generator [https://github.com/NGSolve/netgen Netgen] to improve the quality of tetrahedral elements. '''Note:''' since Netgen can only create tetrahedral elements, this option is ignored for meshes whose {{PropertyData|Element Dimension}} is not ''3D''. |
|||
* {{PropertyData|Recombination Algorithm}} {{Version|0.20}}: The algorithm used for {{PropertyData|Recombine 3D All}} and also for {{PropertyData|Recombine All}}. For more info, see section [[#Element_Recombination|Element Recombination]] and for technical details see the [https://www.gmsh.info/doc/texinfo/gmsh.html#t11 Gmsh documentation]. |
|||
* {{PropertyData|Recombine 3D All}} {{Version|0.20}}: Applies a recombination 3D-algorithm to all volumes. Tetrahedra will be recombined into prisms, hexahedra or pyramids if possible. |
|||
* {{PropertyData|Recombine All}}: Applies a recombination algorithm to all surfaces. Triangles will be recombined into quadrangles when possible. |
|||
* {{PropertyData|Optimize Std}} Optimizes the mesh to improve the quality of tetrahedral elements. |
|||
* {{PropertyData|Second Order Linear}}: Option if second order nodes (if {{PropertyData|Element Order}} set to ''2nd'') and/or mesh refinement points are created by linear interpolation. |
|||
** true; linear interpolation is used |
|||
** false (default); curvilinear interpolation is used |
|||
* {{PropertyData|Subdivision Algorithm}} {{Version|1.0}}: allows the creation of quadrilateral and hexahedral elements by subdivision |
|||
** None; doesn't use any subdivision algorithm |
|||
** All Quadrangles; creates quadrilateral elements by subdivision |
|||
** All Hexahedra; creates hexahedral elements by subdivision |
|||
** Barycentric; creates triangular elements by barycentric subdivision |
|||
==Notes== |
|||
=== Nonpositive Jacobians === |
|||
When you get a meshing error about nonpositive Jacobians, you can try out the following strategies: |
|||
* Set {{PropertyData|Second Order Linear}} to ''true'' but keep {{PropertyData|Element Order}} at ''2nd''. |
|||
* Set {{PropertyData|Element Order}} to ''1st''. |
|||
* Use a smaller element size by reducing the {{PropertyData|Characteristic Length Max}}. |
|||
* If solver ccxtools is used and the run button is used (not the task panel) the nodes of nonpositive jacobian elements will be green. |
|||
===Mesh Growth=== |
|||
At edges and small geometric entities, the mesh has to be smaller than in areas without edges. So the mesh element size grows away from the edges. The growing strategy of Gmsh is to grow between edges of different sizes. So the growing fails when an area has the same sized edges like for example this tube: |
|||
[[Image:FEM_Gmsh-MeshGrowth-failing.png|400px]] |
|||
{{Caption|Failing mesh growing because the cylindrical area is surrounded by the same edges}} |
|||
To enable a sensible mesh growing, you must in this case add an edge to the area. In the example, this would be a circle in the middle of the cylinder. The circle is added as part of a [[Part_BooleanFragments|BooleanFragments]] compound (to form a CompSolid), see [https://forum.freecadweb.org/download/file.php?id=146255 the project file] of the example. |
|||
[[Image:FEM_Gmsh-MeshGrowth-success.png|400px]] |
|||
{{Caption|Sensible mesh growing due to the additional edge in the middle of the cylindrical area}} |
|||
===Element Recombination=== |
|||
Elements can be recombined in two ways, on the surface of objects so that triangles will be recombined into quadrangles if possible and in the volume of objects so that tetrahedra will be recombined into prisms, hexahedra or pyramids if possible. Thinking about the geometry, it becomes clear that the recombination result depends strongly on the geometry of the body and that recombining a 3D body only at the surface will mostly lead to strange results. |
|||
To illustrate this, look at the image below. A cuboid body is meshed using the standard settings (tetrahedra, 2nd order mesh). This is the subimage at the upper left. The image at the upper right shows the result, when additionally the elements are recombined only at the surface of the body. The result is bad because the changed surface elements don't fit to the unchanged volume elements. So {{PropertyData|Recombine All}} alone usually only makes sense for 2D meshes. </br>When we use now also {{PropertyData|Recombine 3D All}}, the result is better, see the lower left subimage. However, the result doesn't show a great difference compared to the mesh without recombinations. Since our body is a cuboid, it is therefore sensible to use a recombination algorithm that tries to create cuboids as well. And this result is shown in the subimage at the lower right. |
|||
The ''Simple'' recombination algorithm will leave some triangles in the mesh in case the recombining leads to badly shaped quads. In such cases use a ''full-quad'' recombination algorithm, which will automatically perform a coarser mesh followed by the recombination, smoothing and subdividing. See [https://forum.freecadweb.org/viewtopic.php?f=18&t=20351#p520392 forum topic] |
|||
[[Image:FEM_Gmsh-Recombination.png|600px]] |
|||
{{Caption|Effect of mesh element recombination.<br> |
|||
Upper left: standard mesh.<br> |
|||
Upper right: recombination only at the surface using the '''Simple''' algorithm.<br> |
|||
Lower left: recombination at the surface and in the volume using the '''Simple''' algorithm.<br> |
|||
Lower right: recombination at the surface and in the volume using the '''Simple full-quad''' algorithm}} |
|||
{{Docnav |
{{Docnav |
||
|[[FEM_MeshNetgenFromShape|FEM mesh from shape by Netgen]] |
|[[FEM_MeshNetgenFromShape|FEM mesh from shape by Netgen]] |
||
|[[FEM_MeshBoundaryLayer|FEM mesh boundary layer]] |
|[[FEM_MeshBoundaryLayer|FEM mesh boundary layer]] |
||
|[[ |
|[[FEM_Workbench|FEM]] |
||
|IconL=FEM_MeshNetgenFromShape. |
|IconL=FEM_MeshNetgenFromShape.svg |
||
|IconR=FEM_MeshBoundaryLayer.svg |
|||
|IconC=Workbench_FEM.svg |
|IconC=Workbench_FEM.svg |
||
|IconR=Fem-femmesh-boundary-layer.svg |
|||
}} |
}} |
||
Latest revision as of 09:54, 21 April 2024
|
Menu location |
---|
Mesh → FEM mesh from shape by Gmsh |
Workbenches |
FEM |
Default shortcut |
None |
Introduced in version |
- |
See also |
FEM tutorial |
Description
For a finite elements analysis the geometry needs to be discretized into a FEM Mesh. This command uses the software Gmsh (which needs to be installed on the system) to generate the mesh.
Depending on your operating system and your installation package, Gmsh might be bundled with FreeCAD or not. For further information see FEM Install.
Usage
- Select the shape you want to analyze. For volume FEM this needs to be a solid or compsolid. A compsolid is necessary if your part is made from multiple materials. (A compsolid can be created with the BooleanFragments command.)
- Press the
FEM mesh from shape by Gmsh button.
- Select the Mesh →
FEM mesh from shape by Gmsh option from the menu.
- Press the
- Optionally edit the minimal and maximal element size (autodetection often creates meshes that are too coarse).
- Click the Apply button and wait for the generation of the mesh to complete.
- Close the task. You now should see a new FEMMeshGMSH object in your active analysis container.
After the mesh has been created, you can change its properties using the property editor. After you change a property, you must reopen the Gmsh dialog again and click the Apply button (you can leave the dialog open while changing properties).
Properties
- DataAlgorithm2D: The algorithm to create 2D meshes. The different algorithms are explained here. For Delaunay, see Delaunay triangulation.
- DataAlgorithm3D: The algorithm to create 3D meshes. The different algorithms are explained here.
- DataCharacteristic Length Max: The maximal size of the mesh elements. If set to 0.0, the size will be set automatically. This property can also be changed in the Gmsh dialog in the field Max element size.
- DataCharacteristic Length Min: The minimal size of the mesh elements. If set to 0.0, the size will be set automatically. This property can also be changed in the Gmsh dialog in the field Min element size.
- DataCoherence Mesh:
- true (default); duplicate mesh nodes will be removed
- false
- DataElement Dimension: The dimension of the mesh elements. This property can also be changed in the Gmsh dialog in the field Mesh element dimension.
- From Shape (default); the dimension will be determined from the dimension of the object that is meshed
- 1D
- 2D
- 3D
- DataElement Order: The mesh element order. This property can also be changed in the Gmsh dialog in the field Mesh order. introduced in version 0.20
- 1st
- 2nd (default)
Note: If you use the solver Elmer you may get this error: ERROR:: GetEdgeBasis: Can't handle but linear elements, sorry. This means the solver equation cannot handle 2nd order meshes. Use either 1st order meshes then, or check the FreeCAD Wiki page for the solver equation for possible options to handle 2nd order meshes.
- DataGeometrical Tolerance: The geometrical tolerance for the mesh to match the object edges. The default 0.0 means that Gmsh's default of 1e-8 is used.
- DataGroups Of Nodes: All nodes and not only the elements will be saved for each physical mesh group. Physical groups are collections of mesh entities (points, curves, surfaces and volumes). They and are identified by their dimension and by a tag. For example a mesh of the same object region is internally tagged the same. So all surfaces of this region will form one physical group.
- DataHigh Order Optimize: If and how meshes with DataElement Order = 2nd are optimized. The optimization is done by a deformation of the element borders.
introduced in version 0.20 Gmsh supports different optimization algorithms. Elastic is an algorithm in which the mesh elements are treated as a collection of deformable viscoelastic solids. 1st order meshes cannot be optimized because their element borders are linear an cannot be deformed. - DataMesh Size From Curvature introduced in version 0.20: The number of mesh elements per times the radius of the curvature. To get a finer mesh at small corners or holes, this value can be increased for better results
Effect of Mesh Size From Curvature'; left: set to 12, right: deactivated
- DataOptimize Netgen: Whether the mesh will be optimized using the 3D mesh generator Netgen to improve the quality of tetrahedral elements. Note: since Netgen can only create tetrahedral elements, this option is ignored for meshes whose DataElement Dimension is not 3D.
- DataRecombination Algorithm introduced in version 0.20: The algorithm used for DataRecombine 3D All and also for DataRecombine All. For more info, see section Element Recombination and for technical details see the Gmsh documentation.
- DataRecombine 3D All introduced in version 0.20: Applies a recombination 3D-algorithm to all volumes. Tetrahedra will be recombined into prisms, hexahedra or pyramids if possible.
- DataRecombine All: Applies a recombination algorithm to all surfaces. Triangles will be recombined into quadrangles when possible.
- DataOptimize Std Optimizes the mesh to improve the quality of tetrahedral elements.
- DataSecond Order Linear: Option if second order nodes (if DataElement Order set to 2nd) and/or mesh refinement points are created by linear interpolation.
- true; linear interpolation is used
- false (default); curvilinear interpolation is used
- DataSubdivision Algorithm introduced in version 1.0: allows the creation of quadrilateral and hexahedral elements by subdivision
- None; doesn't use any subdivision algorithm
- All Quadrangles; creates quadrilateral elements by subdivision
- All Hexahedra; creates hexahedral elements by subdivision
- Barycentric; creates triangular elements by barycentric subdivision
Notes
Nonpositive Jacobians
When you get a meshing error about nonpositive Jacobians, you can try out the following strategies:
- Set DataSecond Order Linear to true but keep DataElement Order at 2nd.
- Set DataElement Order to 1st.
- Use a smaller element size by reducing the DataCharacteristic Length Max.
- If solver ccxtools is used and the run button is used (not the task panel) the nodes of nonpositive jacobian elements will be green.
Mesh Growth
At edges and small geometric entities, the mesh has to be smaller than in areas without edges. So the mesh element size grows away from the edges. The growing strategy of Gmsh is to grow between edges of different sizes. So the growing fails when an area has the same sized edges like for example this tube:
Failing mesh growing because the cylindrical area is surrounded by the same edges
To enable a sensible mesh growing, you must in this case add an edge to the area. In the example, this would be a circle in the middle of the cylinder. The circle is added as part of a BooleanFragments compound (to form a CompSolid), see the project file of the example.
Sensible mesh growing due to the additional edge in the middle of the cylindrical area
Element Recombination
Elements can be recombined in two ways, on the surface of objects so that triangles will be recombined into quadrangles if possible and in the volume of objects so that tetrahedra will be recombined into prisms, hexahedra or pyramids if possible. Thinking about the geometry, it becomes clear that the recombination result depends strongly on the geometry of the body and that recombining a 3D body only at the surface will mostly lead to strange results.
To illustrate this, look at the image below. A cuboid body is meshed using the standard settings (tetrahedra, 2nd order mesh). This is the subimage at the upper left. The image at the upper right shows the result, when additionally the elements are recombined only at the surface of the body. The result is bad because the changed surface elements don't fit to the unchanged volume elements. So DataRecombine All alone usually only makes sense for 2D meshes.
When we use now also DataRecombine 3D All, the result is better, see the lower left subimage. However, the result doesn't show a great difference compared to the mesh without recombinations. Since our body is a cuboid, it is therefore sensible to use a recombination algorithm that tries to create cuboids as well. And this result is shown in the subimage at the lower right.
The Simple recombination algorithm will leave some triangles in the mesh in case the recombining leads to badly shaped quads. In such cases use a full-quad recombination algorithm, which will automatically perform a coarser mesh followed by the recombination, smoothing and subdividing. See forum topic
Effect of mesh element recombination.
Upper left: standard mesh.
Upper right: recombination only at the surface using the Simple algorithm.
Lower left: recombination at the surface and in the volume using the Simple algorithm.
Lower right: recombination at the surface and in the volume using the Simple full-quad algorithm
- Materials: Solid, Fluid, Nonlinear mechanical, Reinforced (concrete); Material editor
- Element geometry: Beam (1D), Beam rotation (1D), Shell (2D), Fluid flow (1D)
Constraints
- Electromagnetic: Electrostatic potential, Current density, Magnetization
- Geometrical: Plane rotation, Section print, Transform
- Mechanical: Fixed, Displacement, Contact, Tie, Spring, Force, Pressure, Centrif, Self weight
- Thermal: Initial temperature, Heat flux, Temperature, Body heat source
- Overwrite Constants: Constant vacuum permittivity
- Solve: CalculiX Standard, Elmer, Mystran, Z88; Equations: Deformation, Elasticity, Electrostatic, Electricforce, Magnetodynamic, Magnetodynamic 2D, Flow, Flux, Heat; Solver: Solver control, Solver run
- Results: Purge, Show; Postprocessing: Apply changes, Pipeline from result, Warp filter, Scalar clip filter, Function cut filter, Region clip filter, Contours filter, Line clip filter, Stress linearization plot, Data at point clip filter, Filter function plane, Filter function sphere, Filter function cylinder, Filter function box
- Additional: Preferences; FEM Install, FEM Mesh, FEM Solver, FEM CalculiX, FEM Concrete; FEM Element Types
![](/images/thumb/9/94/User_hub.png/24px-User_hub.png)
- Getting started
- Installation: Download, Windows, Linux, Mac, Additional components, Docker, AppImage, Ubuntu Snap
- Basics: About FreeCAD, Interface, Mouse navigation, Selection methods, Object name, Preferences, Workbenches, Document structure, Properties, Help FreeCAD, Donate
- Help: Tutorials, Video tutorials
- Workbenches: Std Base, Assembly, BIM, CAM, Draft, FEM, Inspection, Mesh, OpenSCAD, Part, PartDesign, Points, Reverse Engineering, Robot, Sketcher, Spreadsheet, Surface, TechDraw, Test Framework
- Hubs: User hub, Power users hub, Developer hub