-
Notifications
You must be signed in to change notification settings - Fork 66
fix(rf): validate port mesh refinement compatibility with GridSpec #2994
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(rf): validate port mesh refinement compatibility with GridSpec #2994
Conversation
|
@weiliangjin2021 I noticed that tidy3d/tidy3d/components/grid/grid_spec.py Lines 2301 to 2329 in 2ce5542
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
7 files reviewed, no comments
both internal_snapping points and internal_override_structures are not used. The design at that time is that LayerRefinement should only take effect for AutoGrid. QuasiUniformGrid is almost uniform, and should only be used for very basic grid setup. |
Diff CoverageDiff: origin/develop...HEAD, staged and unstaged changes
Summary
|
Very well, then I think I will change validator to check for |
momchil-flex
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
2a36422 to
59172b9
Compare
weiliangjin2021
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
fac9fbf to
7577865
Compare
7577865 to
1699eb3
Compare
Greptile Overview
Greptile Summary
This PR adds validation to ensure that port mesh refinement options are only used with compatible
GridSpectypes inTerminalComponentModeler. The validation prevents users from enabling mesh refinement features (likeenable_snapping_pointsornum_grid_cells) when usingUniformGrid, which doesn't support these features.Key Changes:
_validate_port_refinement_usage()validator inTerminalComponentModelerthat checks if ports have mesh refinement enabled when the simulation uses a non-snapping grid_is_using_mesh_refinementproperty on bothAbstractLumpedPortandWavePortto detect if refinement options are enabledQuasiUniformGridfor wave port teststest_validate_port_refinement_with_uniform_grid()to verify the validation catches the incompatibilityThe validation improves user experience by catching configuration errors early with a clear error message explaining how to fix the issue.
Confidence Score: 5/5
Important Files Changed
File Analysis
Sequence Diagram
sequenceDiagram participant User participant TerminalComponentModeler participant Port as AbstractPort participant GridSpec User->>TerminalComponentModeler: Create with simulation & ports TerminalComponentModeler->>TerminalComponentModeler: _validate_port_refinement_usage() TerminalComponentModeler->>GridSpec: Check snapped_grid_used alt Grid supports snapping (AutoGrid/QuasiUniform) GridSpec-->>TerminalComponentModeler: True TerminalComponentModeler-->>User: Validation passes else Uniform grid (no snapping support) GridSpec-->>TerminalComponentModeler: False loop For each port TerminalComponentModeler->>Port: Check _is_using_mesh_refinement alt LumpedPort with refinement Port-->>TerminalComponentModeler: enable_snapping_points=True OR num_grid_cells set TerminalComponentModeler-->>User: ValidationError else WavePort with refinement Port-->>TerminalComponentModeler: num_grid_cells set TerminalComponentModeler-->>User: ValidationError else No refinement options Port-->>TerminalComponentModeler: False TerminalComponentModeler-->>User: Validation passes end end end