Differences in meshing .stl files using default and “HXT” 3D meshing algorithms; discontinuous .stl files
Professor Geuzaine,
I noticed two differences between the default and “HXT” meshing algorithms (Mesh.Algorithm3D = 10;
) with version 4.9.2.
- The first is that the HXT algorithm produces ~10-15% fewer elements for a given .stl or collection of .stl files.
For example, meshing of an stl file attached here Grain_101.stl:
Merge "Grain_101.stl";
Surface Loop(1)={1};
Volume(1)={1};
Physical Volume (1)={1};
Field[1] = Distance;
Field[1].SurfacesList = {1};
Field[1].Sampling = 100;
Field[2] = MathEval;
Field[2].F = "2 + 0.05*F1^1.6";
Background Field = 2;
Mesh.MeshSizeExtendFromBoundary = 0;
produces (with the default algorithm) 3,075 nodes and 12,329 elements.
Using the HXT algorithm code:
Merge "Grain_101.stl";
Surface Loop(1)={1};
Volume(1)={1};
Physical Volume (1)={1};
Field[1] = Distance;
Field[1].SurfacesList = {1};
Field[1].Sampling = 100;
Field[2] = MathEval;
Field[2].F = "2 + 0.05*F1^1.6";
Background Field = 2;
Mesh.MeshSizeExtendFromBoundary = 0;
Mesh.Algorithm3D = 10;
produces 2,869 nodes and 10,931 elements.
This is also the case when meshing multiple .stl files at once (in my case, 204 .stl files that comprise a synthetic microstructure instantiation). The default algorithm produces 1,302,612 nodes and 7,484,882 elements, whereas the HXT algorithm produces 1,163,896 nodes and 6,527,600 elements. Is this expected...? Fewer elements are greatly preferred and I include quality metrics of both meshes here as reference:
Mesh metrics using default algorithm:
Mesh metrics using HXT algorithm:
- The second issue is that the HXT algorithm fails for discontinuous .stl files (example shown below) whereas the default algorithm can still create a mesh that is useful.
Discontinuous .stl file Grain_194_with_defect.stl:
gmsh code:
Merge "Grain_194_with_defect.stl";
Surface Loop(1)={1};
Volume(1)={1};
Physical Volume (1)={1};
Field[1] = Distance;
Field[1].SurfacesList = {1};
Field[1].Sampling = 100;
Field[2] = MathEval;
Field[2].F = "2 + 0.05*F1^1.6";
Background Field = 2;
Mesh.MeshSizeExtendFromBoundary = 0;
Mesh.Algorithm3D = 10;
Output using HXT algorithm:
Info : Running 'C:\Users\kstopka\Documents\gmsh-4.9.2-Windows64\gmsh.exe -3 -order 1 out_temp.geo > meshing.log' [Gmsh 4.9.2, 1 node, max. 1 thread]
Info : Started on Fri Dec 31 14:24:49 2021
Info : Reading 'out_temp.geo'...
Info : Reading 'C:\temp\15_microstructure_files\Instantiation103\INSERT_DEFECTS\LOF_Virgin_32_defect_1_in_SEM_103_Res_2\latest_gmsh\grain_194_HXT_algo\Grain_194.stl'...
Info : Mesh is in binary format
Info : 25896 facets in solid 0 D
Info : Done reading 'C:\temp\15_microstructure_files\Instantiation103\INSERT_DEFECTS\LOF_Virgin_32_defect_1_in_SEM_103_Res_2\latest_gmsh\grain_194_HXT_algo\Grain_194.stl'
Info : Done reading 'out_temp.geo'
Info : Meshing 1D...
Info : Done meshing 1D (Wall 0s, CPU 0s)
Info : Meshing 2D...
Info : Done meshing 2D (Wall 0s, CPU 0s)
Info : Meshing 3D...
Info : 3D Meshing 1 volume with 1 connected component
Info : Creating an empty mesh with 12952 vertices
Info : Initialization of tet. mesh
Info : Delaunay of 12948 points on 1 threads - mesh.nvert: 4
Info : Recovering 2406 missing facet(s)
Info : Recover Delaunay
Info : 1 out of 2 volumes will be refined
Info : some volumes of the BRep were not found
Error : HXT 3D mesh failed
Error : No elements in volume 1
Info : Done meshing 3D (Wall 0.169547s, CPU 0.140625s)
Info : 12952 nodes 25896 elements
Error : ------------------------------
Error : Mesh generation error summary
Error : 0 warnings
Error : 2 errors
Error : Check the full log for details
Error : ------------------------------
Info : Writing 'out_temp.msh'...
Info : Done writing 'out_temp.msh'
Info : Stopped on Fri Dec 31 14:24:49 2021 (From start: Wall 0.250331s, CPU 0.203125s)
Successful mesh when using the default algorithm (removing Mesh.Algorithm3D = 10;
):
Is there anything I can do to "force" the HXT algorithm to mesh discontinuous .stl files? I would prefer this to the default algorithm since it results in significantly fewer elements. Another option is to mesh the discontinuous .stl files with the default algorithm and then somehow "join" the different regions... this sounds like it should be possible. As a final note, when I use the HXT algorithm on all 204 .stl files, it successfully meshes all the .stl files except for the discontinuous ones, and these regions simply appear empty in gmsh.
Thanks again for your help.
Best regards, Kris