Skip to content

Commit f5bf7a6

Browse files
committed
fix xyz
1 parent 4ffc182 commit f5bf7a6

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

gplugins/gmsh/get_mesh.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def get_mesh(
2323
type: str,
2424
layer_stack: LayerStack,
2525
layer_physical_map: dict | None = None,
26+
layer_meshbool_map: dict | None = None,
2627
z: float | None = None,
2728
xsection_bounds=None,
2829
wafer_padding: float = 0.0,
@@ -37,6 +38,7 @@ def get_mesh(
3738
type: one of "xy", "uz", or "3D". Determines the type of mesh to return.
3839
layer_stack: LayerStack object containing layer information.
3940
layer_physical_map: by default, physical are tagged with layername; this dict allows you to specify custom mappings.
41+
layer_meshbool_map: by default, all polygons on layer_stack layers are meshed; this dict allows you set True of False to the meshing of given layers.
4042
z: used to define z-slice for xy meshing.
4143
xsection_bounds: used to define in-plane line for uz meshing.
4244
wafer_padding: padding beyond bbox to add to WAFER layers.
@@ -85,6 +87,16 @@ def get_mesh(
8587
if layer_name not in layer_physical_map.keys():
8688
layer_physical_map[layer_name] = layer_name
8789

90+
# Default meshing flags (all True)
91+
if layer_meshbool_map is None:
92+
layer_meshbool_map = {}
93+
for layer_name in layer_stack.layers.keys():
94+
layer_meshbool_map[layer_name] = True
95+
else:
96+
for layer_name in layer_stack.layers.keys():
97+
if layer_name not in layer_physical_map.keys():
98+
layer_meshbool_map[layer_name] = True
99+
88100
if type == "xy":
89101
if z is None:
90102
raise ValueError(

gplugins/gmsh/xyz_mesh.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def define_edgeport(
7575
def define_prisms(
7676
layer_polygons_dict: dict,
7777
layer_stack: LayerStack,
78+
layer_physical_map: dict,
7879
model: Any,
7980
resolutions: dict,
8081
scale_factor: float = 1,
@@ -84,6 +85,7 @@ def define_prisms(
8485
Args:
8586
layer_polygons_dict: dictionary of polygons for each layer
8687
layer_stack: gdsfactory LayerStack to parse
88+
layer_physical_map: map layer names to physical names
8789
model: meshwell Model object
8890
resolutions: Pairs {"layername": {"resolution": float, "distance": "float}} to roughly control mesh refinement.
8991
scale_factor: scaling factor to apply to the polygons (default: 1)
@@ -120,7 +122,9 @@ def define_prisms(
120122
model=model,
121123
resolution=resolutions.get(layername, None),
122124
mesh_order=buffered_layer_stack.layers.get(layername).mesh_order,
123-
physical_name=layername,
125+
physical_name=layer_physical_map[layername]
126+
if layername in layer_physical_map
127+
else layername,
124128
)
125129
)
126130

@@ -255,6 +259,7 @@ def xyz_mesh(
255259
model=model,
256260
scale_factor=global_scaling_premesh,
257261
resolutions=resolutions,
262+
layer_physical_map=layer_physical_map,
258263
)
259264

260265
# Add edgeports

0 commit comments

Comments
 (0)