kabuto-mesh: the command line

kabuto-mesh <surface.stl> <case_dir> [options]       mesh a surface
kabuto-mesh --config case.yaml [options]             the same from a settings file
kabuto-mesh inspect <surface.stl> [--scale s]        patches, size, holes; nothing is meshed
kabuto-mesh validate <surface> <case_dir> [options]  check the settings; nothing is meshed
kabuto-mesh sample [DIR]                             copy a sample (a pipe tee, with its settings file) into DIR
kabuto-mesh license [install FILE | renew | remove]  the edition and its license file (licensing.md)
kabuto-mesh version
kabuto-mesh help                                     this text and every meshing option

The mesh is written to <case_dir>/constant/polyMesh (OpenFOAM), with mesh.vtk, a .foam file to open in ParaView, mesh_report.json (the quality numbers) and kabuto_mesh.log (the report as printed).

Options

Every meshing option (--layers, --first, --ratio, --remesh, --zone, ...) is listed by kabuto-mesh help. Two more belong to the command line itself:

option meaning
--config FILE settings from a YAML or JSON file; options on the command line are applied after the file's
--json machine-readable output on stdout

Settings file

The meshing options under their own names, without the dashes (_ or - between words):

schema_version: 1
surface: tee.stl          # relative to this file
case_dir: cases/tee       # relative to this file
layers: 5
first: 0.0002
ratio: 1.2
remesh: 0.004
zone: [rotor]             # a list: joined with commas
patch_size: {impeller: 0.001}
no_imprint: true          # a flag

schema_version is required. It changes when a name in this file changes its meaning; new options do not change it. The same content as JSON (case.json) is read without PyYAML.

Exit status

status meaning
0 mesh written and valid
1 error: a setting, the input, or a tool failed (one line on stderr: error: ...)
2 mesh written, but not valid (negative volumes, open cells or misoriented faces)
3 cancelled (Ctrl-C); the tet filler is stopped too
4 a required external tool is not installed (the message names the package and the command)
5 the mesh has more cells than this edition writes; nothing is written (kabuto-mesh license shows the limit)

The settings are checked before anything is started, so a wrong value or patch name is reported at once and nothing is written.

--json

inspect and validate print one JSON object (see machine_interface.md for the fields).

A meshing run prints one JSON object per line:

event fields when
start version, reportSchemaVersion the run has started
stage name, region a step begins (read, remesh, surface, layers, tetfill, dual, repair, glue, write, check)
log line a line of the report for people
finished state, exit_code, error, case_dir, log_file, report always the last line

state is succeeded, invalid_mesh, failed or cancelled; report is the content of mesh_report.json, or null when no mesh was written. An error before the run starts (a wrong setting, a missing tool) is a single finished object.

External tools

The core of the mesh is filled with tetrahedra by Netgen, and zone surfaces that cross walls are cut in by Manifold. Both run as separate programs in the Python environment kabuto-mesh is installed in (packages netgen-mesher and manifold3d). When one is missing, kabuto-mesh says which and how to install it, and exits with status 4. --tetfill "command" replaces the tet filler with your own program (command <in.surf> <out.tet> <maxh>).