FEM Geometry Preparation and Meshing: Difference between revisions

From FreeCAD Documentation
No edit summary
mNo edit summary
Line 1: Line 1:
== Background ==
== Background ==

Geometry preparation and meshing are crucial parts of preprocessing of simulations using Finite Element Method (FEM). While easily accessible simulation software connected with CAD environment (such as the [[FEM_Workbench|FEM Workbench]] in FreeCAD) makes it tempting to perform analyses on fresh designs, it is very important to remember that FEM is advanced method and requires properly prepared geometry and mesh to provide reasonable, accurate results. The old [https://en.wikipedia.org/wiki/Garbage_in,_garbage_out|''garbage in, garbage out''] rule is particularly important here. There are also other crucial settings on which FEM accuracy highly depends (such as material properties and boundary conditions) but the first steps and some of the most common sources of issues are geometry preparation and meshing, discussed on this page.
Geometry preparation and meshing are crucial parts of preprocessing of simulations using Finite Element Method (FEM). While easily accessible simulation software connected with CAD environment (such as the [[FEM_Workbench|FEM Workbench]] in FreeCAD) makes it tempting to perform analyses on fresh designs, it is very important to remember that FEM is advanced method and requires properly prepared geometry and mesh to provide reasonable, accurate results. The old [https://en.wikipedia.org/wiki/Garbage_in,_garbage_out|''garbage in, garbage out''] rule is particularly important here. There are also other crucial settings on which FEM accuracy highly depends (such as material properties and boundary conditions) but the first steps and some of the most common sources of issues are geometry preparation and meshing, discussed on this page.


== Types of geometry used for FEM in FreeCAD ==
== Types of geometry used for FEM in FreeCAD ==

* Lines (wires) - used for analyses with beam elements
* Lines (wires) - used for analyses with beam elements
* Surfaces - used for analyses with shell elements
* Surfaces - used for analyses with shell elements
Line 8: Line 10:


== Choice of the type of geometry ==
== Choice of the type of geometry ==

While most designs consist of solids, it's often highly recommended to use wires or surfaces for FEM if the structure allows for thatː
While most designs consist of solids, it's often highly recommended to use wires or surfaces for FEM if the structure allows for thatː
* if a part is slender (long and thin) and beam-like and has a regular cross-section of one of the supported beam section types (rectangular, circular or pipe) then it should be analyzed using beam elements (unless there are some specific forms of loading, response or unavoidable geometry details that invalidate this assumption). Basically, one should draw a centerline (some tips on how to extract it from existing solid geometry can be found in [https://forum.freecad.org/viewtopic.php?t=81589 this forum thread]) and apply proper [[FEM_ElementGeometry1D|beam section]] with optional [[FEM_ElementRotation1D|rotation]]. There's no single rule dictating when beam elements can be used but it's often advised that the cross-section dimensions should be < 1/10 of part's length for the beam assumption to be valid.
* if a part is slender (long and thin) and beam-like and has a regular cross-section of one of the supported beam section types (rectangular, circular or pipe) then it should be analyzed using beam elements (unless there are some specific forms of loading, response or unavoidable geometry details that invalidate this assumption). Basically, one should draw a centerline (some tips on how to extract it from existing solid geometry can be found in [https://forum.freecad.org/viewtopic.php?t=81589 this forum thread]) and apply proper [[FEM_ElementGeometry1D|beam section]] with optional [[FEM_ElementRotation1D|rotation]]. There's no single rule dictating when beam elements can be used but it's often advised that the cross-section dimensions should be < 1/10 of part's length for the beam assumption to be valid.
Line 15: Line 18:


== Geometry validity ==
== Geometry validity ==

Geometry used for FEM has to be valid. Most importantly, there can't be any intersections. It's a common issue often occurring when assemblies are modeled without proper constraints between the parts. The [[Part_SectionCut|Part SectionCut]] tool can help find such interferences between parts. Of course, [[Part_Fuse|Part Fuse]] may help resolve them if they are intentional. Other issues with the geometry (such as non-manifold geometries, redundant edges or faces and so on) also have to be fixed before proceeding to meshing.
Geometry used for FEM has to be valid. Most importantly, there can't be any intersections. It's a common issue often occurring when assemblies are modeled without proper constraints between the parts. The [[Part_SectionCut|Part SectionCut]] tool can help find such interferences between parts. Of course, [[Part_Fuse|Part Fuse]] may help resolve them if they are intentional. Other issues with the geometry (such as non-manifold geometries, redundant edges or faces and so on) also have to be fixed before proceeding to meshing.


== Geometry simplification ==
== Geometry simplification ==

Designs prepared in CAD software are typically too detailed to be suitable for FEM simulations. In many cases, it's necessary to simplify them first. This step is often overlooked but it's very important because it can be hard too obtain a good mesh when the part is too detailed and even if such a mesh is obtained eventually, it might be very dense, leading to unreasonable solving times. Thus, one should always look at the design and try to simplify it as much as possible, leaving only those geometric features that may have a significant impact on the results and thus can't be ignored. The following features are typically omitted:
Designs prepared in CAD software are typically too detailed to be suitable for FEM simulations. In many cases, it's necessary to simplify them first. This step is often overlooked but it's very important because it can be hard too obtain a good mesh when the part is too detailed and even if such a mesh is obtained eventually, it might be very dense, leading to unreasonable solving times. Thus, one should always look at the design and try to simplify it as much as possible, leaving only those geometric features that may have a significant impact on the results and thus can't be ignored. The following features are typically omitted:
* small fillets and chamfers,
* small fillets and chamfers,
Line 36: Line 41:


== Geometry partitioning ==
== Geometry partitioning ==

So-called partitioning is a division of the geometry into smaller segments. In other software, it's commonly used to allow hex meshing but in FreeCAD it can be useful for other reasons too. The main application of partitioning is when a load (or a boundary condition) has to be applied only to a selected region of the part's surface. The easiest way to achieve it is to create a sketch with proper contour on that face and use the [[Part_BooleanFragments|Part Boolean Fragments]] tool to split the face with the sketch. Another reason for partitioning is when multiple materials have to be applied to a single part (without having to use multiple parts connected together). Then partitioning can be done using a [[PartDesign_Plane|datum plane]] and Boolean Fragments tool with the ''Compsolid'' mode.
So-called partitioning is a division of the geometry into smaller segments. In other software, it's commonly used to allow hex meshing but in FreeCAD it can be useful for other reasons too. The main application of partitioning is when a load (or a boundary condition) has to be applied only to a selected region of the part's surface. The easiest way to achieve it is to create a sketch with proper contour on that face and use the [[Part_BooleanFragments|Part Boolean Fragments]] tool to split the face with the sketch. Another reason for partitioning is when multiple materials have to be applied to a single part (without having to use multiple parts connected together). Then partitioning can be done using a [[PartDesign_Plane|datum plane]] and Boolean Fragments tool with the ''Compsolid'' mode.


== Assembly geometries ==
== Assembly geometries ==

One of the current major limitations of the FEM workbench is that multiple meshes are not supported. In practice, this means that one cannot mesh each part of the assembly individually and then connect the parts with proper constraints for the analysis. Instead, it's necessary to create a single object containing all the parts of the assembly and mesh it. There are several different options here, all relying on [[Part_Module#Boolean|Part boolean tools]]. The choice depends on the desired effect - whether the individual parts/volumes and their boundaries should be selectable (e.g. for material assignments or definitions of boundary conditions acting on internal faces) or not:
One of the current major limitations of the FEM workbench is that multiple meshes are not supported. In practice, this means that one cannot mesh each part of the assembly individually and then connect the parts with proper constraints for the analysis. Instead, it's necessary to create a single object containing all the parts of the assembly and mesh it. There are several different options here, all relying on [[Part_Module#Boolean|Part boolean tools]]. The choice depends on the desired effect - whether the individual parts/volumes and their boundaries should be selectable (e.g. for material assignments or definitions of boundary conditions acting on internal faces) or not:
* [[Part_Fuse|Part Fuse]] - merges the parts, making it impossible to select them e.g. for material definitions,
* [[Part_Fuse|Part Fuse]] - merges the parts, making it impossible to select them e.g. for material definitions,
Line 52: Line 59:


== Meshing basics ==
== Meshing basics ==

Too coarse mesh is one of the most common sources of inaccuracies and other issues in FEM. It's often a partial fault of automatic mesher settings - they typically generate very coarse, unsuitable meshes when the element size is not manually specified but left with a default value. One should always know the approximate dimensions of the part, especially the size of the smallest relevant feature ([[Part_Measure_Linear|Part Measure Linear]] tool can help with that) and specify the proper maximum element size based on that. It's better to start with a coarser mesh (taking less time to generate), see what it looks like (some experience is necessary) and refine it if necessary.
Too coarse mesh is one of the most common sources of inaccuracies and other issues in FEM. It's often a partial fault of automatic mesher settings - they typically generate very coarse, unsuitable meshes when the element size is not manually specified but left with a default value. One should always know the approximate dimensions of the part, especially the size of the smallest relevant feature ([[Part_Measure_Linear|Part Measure Linear]] tool can help with that) and specify the proper maximum element size based on that. It's better to start with a coarser mesh (taking less time to generate), see what it looks like (some experience is necessary) and refine it if necessary.



Revision as of 19:40, 28 December 2023

Background

Geometry preparation and meshing are crucial parts of preprocessing of simulations using Finite Element Method (FEM). While easily accessible simulation software connected with CAD environment (such as the FEM Workbench in FreeCAD) makes it tempting to perform analyses on fresh designs, it is very important to remember that FEM is advanced method and requires properly prepared geometry and mesh to provide reasonable, accurate results. The old garbage in, garbage out rule is particularly important here. There are also other crucial settings on which FEM accuracy highly depends (such as material properties and boundary conditions) but the first steps and some of the most common sources of issues are geometry preparation and meshing, discussed on this page.

Types of geometry used for FEM in FreeCAD

  • Lines (wires) - used for analyses with beam elements
  • Surfaces - used for analyses with shell elements
  • Solids - used for analyses with solid elements

Choice of the type of geometry

While most designs consist of solids, it's often highly recommended to use wires or surfaces for FEM if the structure allows for thatː

  • if a part is slender (long and thin) and beam-like and has a regular cross-section of one of the supported beam section types (rectangular, circular or pipe) then it should be analyzed using beam elements (unless there are some specific forms of loading, response or unavoidable geometry details that invalidate this assumption). Basically, one should draw a centerline (some tips on how to extract it from existing solid geometry can be found in this forum thread) and apply proper beam section with optional rotation. There's no single rule dictating when beam elements can be used but it's often advised that the cross-section dimensions should be < 1/10 of part's length for the beam assumption to be valid.
  • if a part is thin-walled (such as sheetmetal parts) then it should be analyzed using shell elements (unless accurate contact results are needed or there are some limitations of shell elements are encountered). This is very important and often overlooked. To obtain proper accuracy of results (especially when bending is involved) for thin-walled parts, one needs a few elements (at least 3-5) in the thickness direction. This usually results in large meshes (especially when tetrahedrons are used since hexahedral elements can't be generated in FreeCAD) and large computational cost - high computer power requirements and long solving time. To obtain the geometry suitable for analysis with shell elements, one should draw a midsurface of the part (some tips on how to extract it from existing solid geometry can be found in this forum thread, this one and this one) and apply proper thickness. Again, there's no single rule but it's usually recommended that the thickness should be < 1/10 of a typical global dimension (length/width) for the shell assumption to be valid.

One should remember that beam and shell elements used in CalculiX are not true beam/shell elements (they don't use the beam/shell element formulations known from literature and other software) - they are internally expanded to solids. Still, their use is recommended in the aforementioned cases.

Geometry validity

Geometry used for FEM has to be valid. Most importantly, there can't be any intersections. It's a common issue often occurring when assemblies are modeled without proper constraints between the parts. The Part SectionCut tool can help find such interferences between parts. Of course, Part Fuse may help resolve them if they are intentional. Other issues with the geometry (such as non-manifold geometries, redundant edges or faces and so on) also have to be fixed before proceeding to meshing.

Geometry simplification

Designs prepared in CAD software are typically too detailed to be suitable for FEM simulations. In many cases, it's necessary to simplify them first. This step is often overlooked but it's very important because it can be hard too obtain a good mesh when the part is too detailed and even if such a mesh is obtained eventually, it might be very dense, leading to unreasonable solving times. Thus, one should always look at the design and try to simplify it as much as possible, leaving only those geometric features that may have a significant impact on the results and thus can't be ignored. The following features are typically omitted:

  • small fillets and chamfers,
  • small holes,
  • other small details,
  • welds,
  • bolts, threads,
  • decorative elements (logos, markings).

Geometry simplification for FEM may also mean cutting it in one of the symmetry planes to make use of the planar symmetry assumption in the analysis. This assumption is valid only when all the following aspects of the model exhibit symmetry in a given plane:

  • geometry,
  • loads,
  • boundary conditions,
  • response (one has to be careful with frequency/buckling analyses utilizing symmetry - antisymmetric mode shapes won't be obtained).

The use of symmetry (1/2, 1/4 or 1/8 of the model) is recommended whenever possible since it can highly reduce the computational cost of the analysis. Another advantage is that it eliminates some rigid body motions, making it easier to constrain the part. A symmetry boundary condition should be applied to the faces belonging to the plane of the cut:

  • translation in the direction normal to the symmetry plane should be blocked for solid parts,
  • translations in the direction normal to the symmetry plane and rotations other than around the axis normal to the symmetry plane should be blocked for shell and beam parts.

Applied force should be properly reduced if the symmetry plane cuts the region to which the force is applied (irrelevant when pressure load is used).

Geometry partitioning

So-called partitioning is a division of the geometry into smaller segments. In other software, it's commonly used to allow hex meshing but in FreeCAD it can be useful for other reasons too. The main application of partitioning is when a load (or a boundary condition) has to be applied only to a selected region of the part's surface. The easiest way to achieve it is to create a sketch with proper contour on that face and use the Part Boolean Fragments tool to split the face with the sketch. Another reason for partitioning is when multiple materials have to be applied to a single part (without having to use multiple parts connected together). Then partitioning can be done using a datum plane and Boolean Fragments tool with the Compsolid mode.

Assembly geometries

One of the current major limitations of the FEM workbench is that multiple meshes are not supported. In practice, this means that one cannot mesh each part of the assembly individually and then connect the parts with proper constraints for the analysis. Instead, it's necessary to create a single object containing all the parts of the assembly and mesh it. There are several different options here, all relying on Part boolean tools. The choice depends on the desired effect - whether the individual parts/volumes and their boundaries should be selectable (e.g. for material assignments or definitions of boundary conditions acting on internal faces) or not:

  • Part Fuse - merges the parts, making it impossible to select them e.g. for material definitions,
  • Part Compound - creates a compound object, making it possible to select individual parts,
  • Part JoinConnect - like Part Fuse, merges the parts, making it impossible to select them individually,
  • Part BooleanFragments - works like Part Compound, making it possible to select individual parts.

It's important to mention that if the parts are touching, a continuous mesh will be created on the boolean object and no constraints will be needed for the simulation. If there's even a small gap between the parts, the mesh won't be continuous and constraints like tie or contact will be needed. Running a frequency analysis is a good way to reveal if the mesh is continuous or not - if the parts are not connected, the first mode shapes with deformation visualized using Warp filter will show separation - the parts will "fly away".

Selection of internal regions (faces/volumes) can be tricky. It might be needed for the application of different materials, body loads or boundary conditions (especially in thermal and electromagnetic analyses). Several ways are possible:

  • enabling clipping plane for the time of selection and picking internal faces,
  • hiding the boolean object, showing only one of the parts it was applied to and selecting it,
  • selecting another, external object and editing the References property in the Data tab of a given analysis feature (requires manual specification of the geometric object's number.

Meshing basics

Too coarse mesh is one of the most common sources of inaccuracies and other issues in FEM. It's often a partial fault of automatic mesher settings - they typically generate very coarse, unsuitable meshes when the element size is not manually specified but left with a default value. One should always know the approximate dimensions of the part, especially the size of the smallest relevant feature (Part Measure Linear tool can help with that) and specify the proper maximum element size based on that. It's better to start with a coarser mesh (taking less time to generate), see what it looks like (some experience is necessary) and refine it if necessary.

The choice of element type is not easy and depends on many factors but the general rule is that hexahedral and quad elements are preferable over tetrahedral and triangular ones. However, complex geometries can't be meshed with hexahedral elements and FreeCAD can't generate them at all (only quad meshes can be generated on surfaces - see this forum thread. Hexahedral elements can be imported from external meshers like Gmsh and used in the FEM workbench as shown in this video.

The choice of element order (first or second) depends on the analysis conditions but in most cases, second order elements are preferred. This is particularly the case with triangular and tetrahedral elements - their first order (linear) versions are normally not recommended for regular usage and they should be used only as filler elements in regions of low importance. However, since FreeCAD can't generate hexahedral elements, linear tetrahedrons can be used in some cases, if the meshes are dense enough. Especially when performing analyses with contact.

Mesh convergence studies