Skip to content

Commit 8b7b1d7

Browse files
committed
feat(FXC-5402): Option to remove fragments before meshing in unstructured grids
1 parent 7464a49 commit 8b7b1d7

5 files changed

Lines changed: 39 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
- Added `GaussianPort` and `AstigmaticGaussianPort` for S-matrix calculations using Gaussian beam sources and overlap monitors.
1818
- Added `symmetric_pseudo` option for `s_param_def` in `TerminalComponentModeler` which applies a scaling factor that ensures the S-matrix is symmetric in reciprocal systems.
1919
- Added deprecation warning for ``TemperatureMonitor`` and ``SteadyPotentialMonitor`` when ``unstructured`` parameter is not explicitly set. The default value of ``unstructured`` will change from ``False`` to ``True`` after the 2.11 release.
20+
- Added flag `remove_fragments` to the base `UnstructuredGrid` to remove fragments in unstructured grids. This can ease meshing by eliminating internal boundaries in overlapping structures.
21+
- Added deprecation warning for `conformal` in TCAD heat/charge monitors when explicitly set; this option is ignored (treated as `False`) when meshing with `remove_fragments=True`.
2022

2123
### Breaking Changes
2224
- Added optional automatic extrusion of structures at the simulation boundaries into/through PML/Absorber layers via `extrude_structures` field in class `AbsorberSpec`.

schemas/HeatChargeSimulation.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3322,6 +3322,10 @@
33223322
"minimum": 0,
33233323
"type": "number"
33243324
},
3325+
"remove_fragments": {
3326+
"default": false,
3327+
"type": "boolean"
3328+
},
33253329
"sampling": {
33263330
"default": 100,
33273331
"exclusiveMinimum": 0,
@@ -9516,6 +9520,10 @@
95169520
"minimum": 0,
95179521
"type": "number"
95189522
},
9523+
"remove_fragments": {
9524+
"default": false,
9525+
"type": "boolean"
9526+
},
95199527
"type": {
95209528
"default": "UniformUnstructuredGrid",
95219529
"enum": [

schemas/HeatSimulation.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3322,6 +3322,10 @@
33223322
"minimum": 0,
33233323
"type": "number"
33243324
},
3325+
"remove_fragments": {
3326+
"default": false,
3327+
"type": "boolean"
3328+
},
33253329
"sampling": {
33263330
"default": 100,
33273331
"exclusiveMinimum": 0,
@@ -9516,6 +9520,10 @@
95169520
"minimum": 0,
95179521
"type": "number"
95189522
},
9523+
"remove_fragments": {
9524+
"default": false,
9525+
"type": "boolean"
9526+
},
95199527
"type": {
95209528
"default": "UniformUnstructuredGrid",
95219529
"enum": [

tidy3d/components/tcad/grid.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ class UnstructuredGrid(Tidy3dBaseModel, ABC):
2525
"Use ``relative_min_dl=0`` to remove this constraint.",
2626
)
2727

28+
remove_fragments: bool = pd.Field(
29+
False,
30+
title="Remove Fragments",
31+
description="Whether to remove fragments before meshing. This is useful when overlapping structures generate internal boundaries that can lead to very small cell volumes.",
32+
)
33+
2834

2935
class UniformUnstructuredGrid(UnstructuredGrid):
3036
"""Uniform grid.

tidy3d/components/tcad/monitors/abstract.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from tidy3d.components.base_sim.monitor import AbstractMonitor
1010
from tidy3d.components.types import ArrayFloat1D
11+
from tidy3d.log import log
1112

1213
BYTES_REAL = 4
1314

@@ -29,9 +30,22 @@ class HeatChargeMonitor(AbstractMonitor, ABC):
2930
"significance for the latter ones. Effectively, setting ``conformal = True`` for "
3031
"unstructured monitors (``unstructured = True``) ensures that returned values "
3132
"will not be obtained by interpolation during postprocessing but rather directly "
32-
"transferred from the computational grid.",
33+
"transferred from the computational grid. Note: if the simulation mesh uses "
34+
"``remove_fragments=True``, this option is ignored (treated as ``False``). "
35+
"Deprecated: this field will be removed in version 2.12.",
3336
)
3437

38+
@pd.root_validator(pre=True)
39+
def _warn_conformal_deprecated(cls, values):
40+
"""Warn if deprecated ``conformal`` field is provided."""
41+
# Note: Only warn when the deprecated flag is actually enabled.
42+
if isinstance(values, dict) and values.get("conformal"):
43+
log.warning(
44+
"The `conformal` flag is deprecated and will be removed in version 2.12. "
45+
"It has no effect when the simulation mesh is created with `remove_fragments=True`.",
46+
)
47+
return values
48+
3549
def storage_size(self, num_cells: int, tmesh: ArrayFloat1D) -> int:
3650
"""Size of monitor storage given the number of points after discretization."""
3751
# stores 1 real number per grid cell, per time step, per field

0 commit comments

Comments
 (0)