STL to Gmsh: 3-D Volume Mesh Command
Generate a tetrahedral volume mesh directly from one closed STL surface. No OneFLOW executable or Case staging is needed; Python and Gmsh are required.
Run the default unit-sphere example
The command is intentionally usable without entering a list of parameters:
python grid/stl_to_gmsh/generate_volume_mesh.py
This uses the repository’s unit-sphere STL, a target mesh size of 0.20,
Physical Surface wall, Physical Volume fluid_domain, and writes the
mesh and supporting artifacts under the user’s OneFLOW data directory:
%USERPROFILE%\\.oneflow\\mesh-generation\\sphere\\sphere.mshon Windows.$HOME/.oneflow/mesh-generation/sphere/sphere.mshon Linux and macOS.
Set ONEFLOW_HOME to move the OneFLOW data root. The output directory is
created automatically. Gmsh is discovered from GMSH_EXECUTABLE, PATH,
or common installation directories; use --gmsh when it is installed in
a non-standard location.
One mesh size
python grid/stl_to_gmsh/generate_volume_mesh.py --stl path/to/sphere.stl --output "$HOME/.oneflow/mesh-generation/sphere/sphere.msh" --mesh-size 0.20
The command sets both Gmsh size limits to 0.20. A mesh size is a target characteristic length, not an exact tetrahedron edge length or element count.
Mesh-size range
python grid/stl_to_gmsh/generate_volume_mesh.py --stl path/to/sphere.stl --output "$HOME/.oneflow/mesh-generation/sphere/sphere.msh" --mesh-size-min 0.10 --mesh-size-max 0.20
Sphere refinement examples
Use the same STL input for each run and change only the size:
python grid/stl_to_gmsh/generate_volume_mesh.py --mesh-size 0.40 --output "$HOME/.oneflow/mesh-generation/sphere/sphere_coarse.msh"
python grid/stl_to_gmsh/generate_volume_mesh.py --mesh-size 0.20 --output "$HOME/.oneflow/mesh-generation/sphere/sphere_medium.msh"
python grid/stl_to_gmsh/generate_volume_mesh.py --mesh-size 0.10 --output "$HOME/.oneflow/mesh-generation/sphere/sphere_fine.msh"
Outputs
For sphere.msh, the command writes:
sphere.msh— MSH 4.1 tetrahedral volume mesh generated by native Gmsh.sphere.geo— generated native Gmsh geometry script, independently inspectable and executable.sphere.report.json— input topology, Gmsh executable, mesh counts, Physical Groups and validation summary.
The command validates one connected, closed, consistently oriented,
genus-zero STL shell and checks that the generated mesh contains TETRA_4
volume cells, TRI_3 boundary facets, and the requested Physical Groups.
Default group names are wall (surface) and fluid_domain (volume);
override them with --boundary-name and --volume-name.
This command generates a volume inside the closed STL shell. It does not create an external-flow domain around the STL body. For a full OneFLOW Case and CFD smoke workflow, see STL Unit Sphere to Gmsh 3D Tetrahedral Mesh.