# mesh-generator v3.2.3 **Mercurial revision 5803:7164e00e8f3d | 2026-08-18** --- ## Description `mesh-generator` is a tool that **generates a 2D mesh** based on a given **criteria file** (`.crt`). It is designed to create high-quality meshes for oceanographic, coastal, or other geospatial applications. --- ## Usage ```bash mesh-generator [OPTIONS] criteria.crt ``` --- ## Options ### **General Options** | Option | Description | | ------------------- | --------------------------------------------------------------- | | `-h`, `--help` | Display help and exit. | | `--limits-only` | Generate density and limits but **not** the mesh. | | `--rootname ` | Root name for intermediate output files (default: `anonymous`). | | `--debug` | Generate extra output files for debugging purposes. | | `--check-limits` | Check the sanity of mesh limits polygons. | | `--no-reshape` | Skip the mesh reshaping step. | | `--show-map` | Save mesh densities to `-criteria*.nc`. | --- ### **Input/Output Options** | Option | Description | | ----------- | ---------------------------------------------------------------------------------------------- | | `-b ` | Path to the bathymetry file. Can also be specified in the criteria file via `TOPOGRAPHY_FILE`. | | `-f ` | Path to the mesh boundaries file (trigrid format). **Disables `-d` and `-p`**. | | `-d ` | Path to the genesis boundary descriptor. **Disables `-p`**. | | `-p ` | Path to raw polygons for boundaries. | | `-m ` | Path to a mesh file to **merge** with the generated mesh. | | `-o ` | Path to the output mesh file (default: `-mesh.nei`). | | `-s ` | Path to the mesh density file. | | `-z ` | Path to a local mesh density prescription file. | | `-n ` | Path to a node file (used for triangulation). | --- ### **Mesh Generation Options** | Option | Description | | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | | `-r ` | Resolution in kilometers. Used **only** when a node file is provided and no criteria file is given. | | `--line-mode ` | Line definition mode between polygon vertices. `` can be: `ORTHODROMIC`, `LOXODROMIC`, or `CARTESIAN` (default: `LOXODROMIC`). | | `--smoothing-rate ` | Smoothing rate for mesh optimization. | | `--polar` | Enable polar grid mode. | --- ## Examples ### **Basic Mesh Generation** Generate a mesh using a criteria file: ```bash mesh-generator criteria.crt ``` ### **Generate Mesh with Custom Output Name** Generate a mesh and specify a root name for output files: ```bash mesh-generator --rootname my_mesh criteria.crt ``` ### **Generate Mesh with Bathymetry** Generate a mesh using a custom bathymetry file: ```bash mesh-generator -b bathymetry.nc criteria.crt ``` ### **Generate Mesh with Boundaries** Generate a mesh using a boundaries file: ```bash mesh-generator -f boundaries.trg criteria.crt ``` ### **Generate Mesh with Raw Polygons** Generate a mesh using raw polygons for boundaries: ```bash mesh-generator -p polygons.plg criteria.crt ``` ### **Generate Mesh with Node File** Generate a mesh using a node file and a resolution: ```bash mesh-generator -n nodes.txt -r 1000 criteria.crt ``` ### **Generate Density and Limits Only** Generate density and limits without creating the mesh: ```bash mesh-generator --limits-only criteria.crt ``` ### **Merge with Existing Mesh** Generate a mesh and merge it with an existing mesh: ```bash mesh-generator -m existing_mesh.nei criteria.crt ``` ### **Debug Mode** Generate a mesh with extra debugging output: ```bash mesh-generator --debug criteria.crt ``` ### **Custom Line Mode** Generate a mesh with a specific line mode (e.g., `ORTHODROMIC`): ```bash mesh-generator --line-mode ORTHODROMIC criteria.crt ``` ### **Local Mesh Density Prescription** Generate a mesh with a local mesh density prescription: ```bash mesh-generator -z local_density.txt criteria.crt ``` ### **Check Mesh Limits** Check the sanity of mesh limits polygons: ```bash mesh-generator --check-limits criteria.crt ``` ### **Skip Mesh Reshaping** Generate a mesh without reshaping: ```bash mesh-generator --no-reshape criteria.crt ``` ### **Save Mesh Densities** Save mesh densities to a NetCDF file: ```bash mesh-generator --show-map criteria.crt ``` --- ## Environment Variables `mesh-generator` uses **OpenMP** for parallelization. Key environment variables: | Variable | Description | | ----------------- | ----------------------------------------- | | `OMP_NUM_THREADS` | Number of threads to use. | | `OMP_SCHEDULE` | Runtime schedule type and chunk size. | | `OMP_DYNAMIC` | Enable/disable dynamic thread adjustment. | | `OMP_NESTED` | Enable/disable nested parallelism. | **Example:** ```bash OMP_NUM_THREADS=4 mesh-generator criteria.crt ``` --- ## Notes 1. **Criteria File:** - The criteria file (`.crt`) defines the **mesh resolution**, **bathymetry**, and other parameters. - If no criteria file is provided, a **node file** and **resolution** (`-r`) must be specified. 2. **Boundary Files:** - Use `-f` for **mesh boundaries files** (trigrid format). - Use `-d` for **genesis boundary descriptors**. - Use `-p` for **raw polygons**. - **Priority:** `-f` > `-d` > `-p`. 3. **Bathymetry:** - Can be specified via `-b` or in the criteria file using `TOPOGRAPHY_FILE`. 4. **Output:** - The default output mesh file is `-mesh.nei`. - Use `-o` to specify a custom output path. 5. **Mesh Merging:** - Use `-m` to merge the generated mesh with an existing mesh. 6. **Debugging:** - Use `--debug` to generate additional output files for troubleshooting. 7. **Line Modes:** - `ORTHODROMIC`: Great-circle lines (default). - `LOXODROMIC`: Rhumb lines. - `CARTESIAN`: Straight lines in a projected coordinate system. 8. **Polar Grids:** - Use `--polar` for polar grid generation. --- ## See Also - [OpenMP Documentation](https://www.openmp.org/) (for parallelization options) - [NetCDF Format](https://www.unidata.ucar.edu/software/netcdf/) (for input/output files)