Skip to content

feat: add MeepMeshSim for GMSH mesh-based photonic simulations#39

Draft
vvahidd wants to merge 5 commits intomainfrom
meep-mesh-sim
Draft

feat: add MeepMeshSim for GMSH mesh-based photonic simulations#39
vvahidd wants to merge 5 commits intomainfrom
meep-mesh-sim

Conversation

@vvahidd
Copy link
Contributor

@vvahidd vvahidd commented Feb 26, 2026

Summary

  • Add MeepMeshSim class — alternative mesh-based workflow for Meep that mirrors Palace's mesh()write_config() pattern
  • Produces GMSH .msh + mesh_config.json that fully describes a photonic problem (materials, source, monitors, domain, solver)
  • Add include_airbox flag to generate_mesh() / add_dielectrics() — defaults to True for Palace (RF), False for Meep (photonics)
  • Add material field to volume groups in mesh config JSON for consistency with layer_volumes
  • New gsim.common.mesh module for solver-agnostic GMSH mesh generation

Test plan

  • uv run pytest tests/meep/test_mesh_sim.py -v — 21 new tests pass
  • uv run pytest tests/common/test_mesh.py -v — common mesh tests pass
  • uv run pytest tests/ — all existing tests still pass
  • Notebook nbs/mesh_ybranch.ipynb produces .msh + mesh_config.json

Add an alternative mesh-based workflow for Meep that mirrors Palace's
mesh() → write_config() pattern. Produces a GMSH .msh + mesh_config.json
that fully describes a photonic problem.

- MeepMeshSim class with geometry/source/domain/solver setters
- mesh_config.py writer for JSON problem definition
- include_airbox flag on generate_mesh (default False for photonics)
- gsim.common.mesh module for solver-agnostic GMSH mesh generation
- 21 new tests + notebook demo
Palace mesh modules import shared utilities from gsim.common.mesh
instead of duplicating them. Also includes auto-generated api.md.
After fragmentation, identify waveguide boundary faces at each
gdsfactory port location and assign them as named surface physical
groups (port_<name>). Port metadata (center, width, orientation,
layer, z_range) is serialized into mesh_config.json. Also hardcode
mesh filename to mesh.msh for consistent cloud runner expectations.
…ation

The previous truncation `[:len(tags)]` dropped dielectric volume fragments
when fragmentation split boxes into more pieces than the original count.
Now layer/metal volume tags are collected first and excluded from dielectric
groups, ensuring all fragments are assigned without double-counting.

Also improved plot_mesh to render per-group with colors by default, with
the largest volume (e.g. cladding) as a transparent wireframe so inner
structures like waveguide cores are visible.
Adjacent dielectric boxes of the same material are now merged into a
single GMSH box (e.g. box+clad SiO2 → one volume), eliminating
coincident faces and sliver tets. Different-material boxes sharing a
z-boundary use removeAllDuplicates() to cleanly resolve the shared face.

Also adds a regression test verifying box/clad XY consistency, improves
the mesh summary in notebooks, and removes the plot_mesh_slice feature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant