# Geo Use {func}`geo ` to generate a mesh from the geometry input in a {term}`project` directory. The operation runs `JCMgeo` and creates `grid.jcm` in the selected working directory. ## Generate A Mesh The default call uses the current directory as the project directory and the working directory: ```python import jcmsuite jcmsuite.geo(project_dir=".") ``` The project directory must contain `layout.jcm` or `layout.jcmt`. The call returns `None` after successful mesh generation. For a project directory stored elsewhere, pass its path explicitly: ```python from pathlib import Path import jcmsuite project_dir = Path("examples/mie2d") jcmsuite.geo(project_dir=project_dir) ``` ## Use Project Keys Pass `keys=` when the geometry input uses {term}`templating`. The {term}`project keys` fill the `.jcmt` input before `JCMgeo` runs: ```python jcmsuite.geo( project_dir="examples/mie2d", keys={"radius": 0.5}, ) ``` The `keys` value supplies {term}`project keys`. See [Templating](../project_tools/templating.md) for project-key substitution. ## Select A Suffix Pattern Use `jcmt_pattern=` when the project directory contains suffixed geometry inputs. This option is a {term}`JCMT pattern`. The selection checks the suffixed template or file before the unsuffixed input: ```python jcmsuite.geo( project_dir="examples/mie2d", jcmt_pattern="fine", ) ``` For example, the `fine` suffix selects `layout.fine.jcmt` or `layout.fine.jcm` before `layout.jcmt` or `layout.jcm`. ## Stage The Inputs Pass `working_dir=` to stage the selected geometry input and write `grid.jcm` to another directory: ```python jcmsuite.geo( project_dir="examples/mie2d", working_dir="build/mesh", ) ``` When `working_dir` is relative, `jcmsuite` resolves it relative to `project_dir`. When `keys` or `jcmt_pattern` is set, `jcmsuite` prepares the selected `layout` input in the working directory before it runs `JCMgeo`. ## Open The Generated Mesh Set `show=True` to request mesh viewing: ```python jcmsuite.geo(project_dir="examples/mie2d", show=True) ``` To open the generated grid file explicitly, use [View](view.md): ```python jcmsuite.view("examples/mie2d/grid.jcm") ``` See these complete runnable tutorials: - [Generate and view a default mesh](../tutorials/core/geo_view/01_default.md). - [Generate and view a coarse mesh](../tutorials/core/geo_view/02_coarse.md). - [Generate a mesh from a template](../tutorials/core/geo_view/03_template.md). ## Runtime Conditions {func}`geo ` requires a working JCMsuite context with the `JCMgeo` binary. It raises {class}`InvalidConfigurationError ` when the project or working directory is invalid. It raises {class}`RuntimeContextError ` when `JCMgeo` is unavailable.