Geo

Use geo to generate a mesh from the geometry input in a 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:

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:

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 templating. The project keys fill the .jcmt input before JCMgeo runs:

jcmsuite.geo(
    project_dir="examples/mie2d",
    keys={"radius": 0.5},
)

The keys value supplies project keys. See Templating for project-key substitution.

Select A Suffix Pattern

Use jcmt_pattern= when the project directory contains suffixed geometry inputs. This option is a JCMT pattern. The selection checks the suffixed template or file before the unsuffixed input:

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:

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:

jcmsuite.geo(project_dir="examples/mie2d", show=True)

To open the generated grid file explicitly, use View:

jcmsuite.view("examples/mie2d/grid.jcm")

See these complete runnable tutorials:

Runtime Conditions

geo requires a working JCMsuite context with the JCMgeo binary. It raises InvalidConfigurationError when the project or working directory is invalid. It raises RuntimeContextError when JCMgeo is unavailable.