-
Notifications
You must be signed in to change notification settings - Fork 70
feat(FXC-5154) Warn gmsh min cylinder radii #3217
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
base: develop
Are you sure you want to change the base?
Conversation
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.
2 files reviewed, 1 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.
Pull request overview
This pull request adds validation to warn users when cylinder radii are too small for gmsh meshing in heat-charge simulations. The feature helps prevent meshing issues by alerting users to geometries that may cause problems during the meshing process.
Changes:
- Added
MIN_GMSH_RADIUSconstant (1e-6) representing OpenCASCADE tolerance - Implemented
_warn_small_cylinder_radiusvalidator that checks cylinder radii and warns when they fall below meshing thresholds - Added comprehensive tests covering both non-tapered and tapered cylinder scenarios
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tidy3d/components/tcad/simulation/heat_charge.py | Added imports for Cylinder and traverse_geometries, defined MIN_GMSH_RADIUS constant, and implemented validator to warn about small cylinder radii |
| tests/test_components/test_heat_charge.py | Added test function to verify warnings are issued for small cylinder radii in both non-tapered and tapered cases |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
12b4bef to
c91f81b
Compare
c91f81b to
61e8eb7
Compare
Diff CoverageDiff: origin/develop...HEAD, staged and unstaged changes
Summary
tidy3d/components/tcad/simulation/heat_charge.pyLines 388-396 388
389 # Warn if radii are below minimum
390 if is_tapered:
391 if r_bottom < min_radius:
! 392 log.warning(
393 f"Cylinder 'radius_bottom' ({r_bottom:.3e}) is below the minimum "
394 f"radius for meshing ({min_radius:.3e}). The sidewall angle may be "
395 f"too steep. Will be clamped to minimum radius or mesh size, whichever is larger."
396 ) |
61e8eb7 to
9b429c9
Compare
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.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
9b429c9 to
1c79e74
Compare
1c79e74 to
0a0063e
Compare
Note
Low Risk
Adds logging-only validation warnings and a small geometry traversal tweak; no simulation behavior changes beyond additional warnings.
Overview
Adds validation-time warnings in
HeatChargeSimulationwhen anyCylinderinstructureshas an effective radius below the OpenCASCADE/gmsh meshing tolerance, including checks for tapered cylinders (radius_bottom/radius_top) and nested/translated cylinders viatraverse_geometries.Extends
traverse_geometriesto recurse intobase.Transformedgeometries, and adds tests asserting the new warnings for tiny-radius cylinders and steeply-tapered cylinders that produce too-small/negative top radii.Written by Cursor Bugbot for commit 0a0063e. This will update automatically on new commits. Configure here.
Greptile Overview
Greptile Summary
This PR adds validation-time warnings for
HeatChargeSimulationwhenCylindergeometries have radii below the minimum threshold required for gmsh/OpenCASCADE meshing. The implementation correctly traverses nested geometries and checks both tapered and non-tapered cylinders.Key Changes:
MIN_GMSH_RADIUSconstant (1e-6) to define OpenCASCADE tolerance_warn_small_cylinder_radiusvalidator that checksradius_bottomandradius_topagainst computed minimumIssues Found:
!=) which can be unreliable; should use tolerance-based comparison withnp.iscloseConfidence Score: 3/5
is_tapereddetection in edge cases. Missing CHANGELOG is a process violation but doesn't affect code quality.tidy3d/components/tcad/simulation/heat_charge.pyline 379 for the float comparison fixImportant Files Changed
Sequence Diagram
sequenceDiagram participant User participant HeatChargeSimulation participant Validator as _warn_small_cylinder_radius participant GeomUtils as traverse_geometries participant Cylinder participant Logger as log.warning User->>HeatChargeSimulation: Create simulation with structures HeatChargeSimulation->>Validator: Validate structures field loop For each structure Validator->>GeomUtils: traverse_geometries(structure.geometry) GeomUtils-->>Validator: Yields nested geometries loop For each geometry alt geometry is Cylinder Validator->>Cylinder: Get radius_bottom Cylinder-->>Validator: r_bottom Validator->>Cylinder: Get radius_top Cylinder-->>Validator: r_top Validator->>Validator: Check if tapered (r_bottom != r_top) Validator->>Validator: Compute min_radius = max(MIN_GMSH_RADIUS, 0.01*max(abs(r_bottom), abs(r_top))) alt is_tapered alt r_bottom < min_radius Validator->>Logger: Warn about radius_bottom end alt r_top < min_radius Validator->>Logger: Warn about radius_top end else not tapered alt r_bottom < min_radius Validator->>Logger: Warn about radius end end end end end Validator-->>HeatChargeSimulation: Return validated structures HeatChargeSimulation-->>User: Simulation created (with warnings)Context used:
dashboard- Use a tolerance-based comparison (e.g., np.isclose) for floating-point numbers instead of direct equ... (source)dashboard- Update the CHANGELOG.md file when making changes that affect user-facing functionality or fix bugs. (source)