feat(FXC-5154) Warn gmsh min cylinder radii#3217
Open
Conversation
There was a problem hiding this comment.
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
Contributor
Diff CoverageDiff: origin/develop...HEAD, staged and unstaged changes
Summary
tidy3d/components/tcad/simulation/heat_charge.pyLines 392-400 392
393 # Warn if radii are below minimum
394 if is_tapered:
395 if r_bottom < min_radius:
! 396 log.warning(
397 f"Cylinder 'radius_bottom' ({r_bottom:.3e}) is below the minimum "
398 f"radius for meshing ({min_radius:.3e}). The sidewall angle may be "
399 f"too steep. Will be clamped to minimum radius or mesh size, whichever is larger."
400 ) |
61e8eb7 to
9b429c9
Compare
9b429c9 to
1c79e74
Compare
dbochkov-flexcompute
approved these changes
Feb 4, 2026
1c79e74 to
0a0063e
Compare
momchil-flex
approved these changes
Feb 4, 2026
0a0063e to
8a3b819
Compare
There was a problem hiding this comment.
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.
97a95cd to
a01dd6e
Compare
a01dd6e to
a913a74
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Low Risk
Adds validation-time warnings only (no solver behavior changes), but touches geometry traversal during simulation construction which could affect edge-case setups if the validator misfires or is too noisy.
Overview
HeatChargeSimulationnow emits validation-time warnings whenCylindergeometries (including transformed/nested ones) have radii below an OpenCASCADE/gmsh-safe threshold, with separate messages forradius,radius_bottom, andradius_top(tapered cylinders).Adds unit tests covering tiny-radius cylinders (including translated cylinders) and steeply-tapered cylinders that produce an invalid/very small
radius_top, and documents the new warning inCHANGELOG.md.Written by Cursor Bugbot for commit a913a74. 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)