Note
Go to the end to download the full example code.
Gmsh: Mesh a .geo file¶
Mesh the existing case17.geo plate with a hole in mm. Its named bc-base and bc-top boundaries match case17.i’s weak plane stress model. Gmsh DefineConstant entries let CLI parameters change the mesh resolution; the geometry is unchanged. The Python API runs in an isolated worker without opening a graphical window.
from pathlib import Path
import pyvale.data as dataset
import pyvale.mooseherder as mh
Create the standard output directory so generated files stay together under pyvale-output rather than alongside the packaged input files.
Case17: 2D plate with a hole, weak plane stress; mm, MPa and seconds. These paths point to pyvale/data/simulation/simcases/case17.i and case17.geo.
Mesh the packaged geometry with coarser subdivision counts supplied as input parameters. The runner writes the mesh in its own directory without editing the original .geo file.
runner: mh.GmshRunner = mh.GmshRunner(geo_file=geo_file)
result: mh.RunResult = runner.run(
input_params={"hole_sect_nodes": 7, "plate_rad_nodes": 7},
output_dir=mh.get_next_run_path(output_path / "mooseherder_ex03a_mesh"),
)
print(f"Mesh: {result.output_file}")