Geometry & Meshing¶
PalaceToolkit uses Gmsh with its OpenCASCADE kernel to create parametric 3D finite-element meshes entirely from Python scripts.
The Entity abstraction¶
Every geometric region — conductors, dielectrics, air boxes, ports — is
represented as an Entity:
from palacetoolkit.mesh import Entity, run_meshing_pipeline
conductor = Entity(name="conductor", dim=3, mesh_order=0, tags=[1])
dielectric = Entity(name="dielectric", dim=3, mesh_order=1, tags=[2])
air = Entity(name="air", dim=3, mesh_order=2, tags=[3])
| Parameter | Description |
|---|---|
name |
Becomes the physical group label that Palace references. |
dim |
Geometric dimension (3 = volume, 2 = surface, …). |
mesh_order |
Priority for the boolean pipeline (lower = higher priority). |
tags |
Gmsh geometry tags returned by gmsh.model.occ.* calls. |
Boolean pipeline¶
After defining entities, call run_meshing_pipeline to perform automatic
priority-based cuts and fragmentation:
The pipeline:
- Groups entities by dimension (3 → 0).
- Sorts within each dimension by
mesh_order(ascending = higher priority). - Cuts each entity against all previously processed entities in the
same dimension (
removeObject=True,removeTool=False). - Fragments lower-dimensional entities against higher-dimensional ones so that boundary surfaces are shared.
- Assigns physical groups — volumes get their entity name; surfaces
at material interfaces are auto-labelled (e.g.
"conductor__dielectric").
Tip
The mesh_order controls which material wins at overlapping regions.
Think of it as a z-index: small number = highest priority = never cut.
Mesh generation¶
After the pipeline runs, generate the mesh and write it to disk:
Mesh topology verification¶
Before running Palace, verify the mesh is valid:
This checks that:
- Every boundary element maps to an existing volume face (totality).
- No two boundary elements map to the same face (injectivity).
Mesh visualisation¶
For static HTML exports (used in the docs site):