Skip to content
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

feat: Adding planar portal link #4044

Merged
merged 9 commits into from
Jan 24, 2025

Conversation

ssdetlab
Copy link
Contributor

@ssdetlab ssdetlab commented Jan 21, 2025

Extending the PortalLinkBase, GridPortalLink, and CompositePortalLink classes to support PlaneSurface.

Summary by CodeRabbit

  • New Features

    • Added support for PlaneSurface in grid portal link functionality.
    • Enhanced merging capabilities for plane surfaces.
    • Improved error handling and consistency checks for surface grid operations.
  • Bug Fixes

    • Resolved issues with surface merging and grid creation for plane surfaces.
    • Added robust validation for surface bounds and axis directions.
  • Tests

    • Introduced comprehensive test cases for plane surface grid merging.
    • Added validation for 1D and 2D grid portal link scenarios.

Copy link

coderabbitai bot commented Jan 21, 2025

Walkthrough

Changes to geometry and grid portal linking, we have! Modifications to handle PlaneSurface with more robustness, the code now does. Error handling improved, surface merging expanded, and consistency checks added, have been. A more flexible and resilient implementation of grid portal links, we now possess. Support for plane surfaces in various grid configurations, the developers have crafted.

Changes

File Change Summary
Core/include/Acts/Geometry/GridPortalLink.hpp Added error handling for PlaneSurface, new checkConsistency method, updated factory methods with direction validation
Core/src/Geometry/CompositePortalLink.cpp Enhanced merging logic for PlaneSurface, updated grid creation method
Core/src/Geometry/GridPortalLink.cpp Implemented support for PlaneSurface, added dynamic bounds casting, new consistency checks
Core/src/Geometry/GridPortalLinkMerging.cpp Replaced throw statement with mergedWith method for PlaneSurface merging
Core/src/Geometry/PortalLinkBase.cpp Added precondition checks for PlaneSurface and RectangleBounds
Tests/UnitTests/Core/Geometry/PortalLinkTests.cpp New test suites for 1D and 2D plane surface grid portal merging

Sequence Diagram

sequenceDiagram
    participant GridPortalLink
    participant PlaneSurface
    participant RectangleBounds
    
    GridPortalLink->>PlaneSurface: checkConsistency()
    PlaneSurface->>RectangleBounds: validate bounds
    GridPortalLink->>GridPortalLink: extendTo2dImpl
    GridPortalLink->>PlaneSurface: retrieve surface properties
    GridPortalLink-->>GridPortalLink: create grid
Loading

Possibly related PRs

Suggested Labels

automerge

Suggested Reviewers

  • paulgessinger
  • asalzburger

Poem

Grid portals dance, surfaces align,
Plane meets bounds with geometric design,
Merging edges, axes intertwine,
Code's geometry, now more divine! 🌐✨
A Jedi's grid, precise and fine!

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the Component - Core Affects the Core module label Jan 21, 2025
@github-actions github-actions bot added this to the next milestone Jan 21, 2025
@ssdetlab ssdetlab marked this pull request as ready for review January 22, 2025 18:37
Copy link

github-actions bot commented Jan 22, 2025

📊: Physics performance monitoring for 867a11a

Full contents

physmon summary

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
Tests/UnitTests/Core/Geometry/PortalLinkTests.cpp (1)

2374-2378: Redundant debug output calls, I detect.

Multiple calls to printContents() you have. In test code, these should be guarded or removed unless needed for debugging.

Consider this change:

-  grid1X->printContents(std::cout);
-  grid2->printContents(std::cout);
-  grid3->printContents(std::cout);
-  mergedX->printContents(std::cout);
-  mergedY->printContents(std::cout);
+  #ifdef ACTS_VERBOSE_DEBUG
+    grid1X->printContents(std::cout);
+    grid2->printContents(std::cout);
+    grid3->printContents(std::cout);
+    mergedX->printContents(std::cout);
+    mergedY->printContents(std::cout);
+  #endif
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bbd3fcc and 3138b68.

📒 Files selected for processing (6)
  • Core/include/Acts/Geometry/GridPortalLink.hpp (8 hunks)
  • Core/src/Geometry/CompositePortalLink.cpp (3 hunks)
  • Core/src/Geometry/GridPortalLink.cpp (4 hunks)
  • Core/src/Geometry/GridPortalLinkMerging.cpp (3 hunks)
  • Core/src/Geometry/PortalLinkBase.cpp (2 hunks)
  • Tests/UnitTests/Core/Geometry/PortalLinkTests.cpp (6 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: merge-sentinel
  • GitHub Check: linux_physmon
  • GitHub Check: linux_examples_test
  • GitHub Check: missing_includes
  • GitHub Check: linux_ubuntu_extra (ubuntu2204, 20, clang++)
  • GitHub Check: build_debug
🔇 Additional comments (22)
Core/src/Geometry/CompositePortalLink.cpp (3)

18-18: Necessary includes added, appropriate they are.

Includes for RectangleBounds, AxisDefinitions, and <cstddef> added you have. Essential for PlaneSurface handling, they are.

Also applies to: 21-21, 24-24


54-56: Merging logic for PlaneSurfaces, correctly implemented it is.

In the mergedSurface function, support for merging PlaneSurfaces, added you have. Properly handling the merge, the code is.


297-345: Support for PlaneSurface in grid creation, wisely added you have.

Implementation of grid creation for PlaneSurfaces, this adds. Checks for binning direction and edge calculations, correctly included they are. Enhance functionality, this does.

Core/src/Geometry/GridPortalLink.cpp (4)

13-14: Additional includes for PlaneSurface support, added they are.

Includes for RectangleBounds, AxisDefinitions, and <iostream> necessary they are. Ensure proper functionality, they will.

Also applies to: 16-16


72-84: Handling of PlaneSurface in make method, appropriate it is.

Logic for PlaneSurface in GridPortalLink::make, added you have. Validating binning directions and setting up axes, correctly you are.


218-250: Consistency check for PlaneSurface, well implemented it is.

Method checkConsistency for PlaneSurface, added you have. Ensures grid matches bounds of PlaneSurface, this does. Important for correctness, it is.


469-505: Extension to 2D grid for PlaneSurface, correctly added it is.

In extendTo2dImpl, handling of PlaneSurface to extend to 2D grid, implemented you have. Logic for axes and grid filling, proper it is.

Core/src/Geometry/PortalLinkBase.cpp (2)

17-17: Include for RectangleBounds, necessary it is.

For PlaneSurface support, required this include is.


60-71: Preconditions for merging PlaneSurfaces, added you have.

In checkMergePreconditions, support for PlaneSurfaces, included it is. Assertions for surface types and bounds, correctly added they are.

Core/src/Geometry/GridPortalLinkMerging.cpp (3)

260-261: Hmm, good implementation this is!

Consistent with other surface types, the merging of plane surfaces is. Follow the established pattern, it does.


459-462: Wise addition to the merging logic, this is!

Handle plane surfaces with proper axes, it does. Consistent with the surface's coordinate system, it remains.


446-446: Hmm, proper type checking, added it has been!

Follow the established pattern of surface type detection, it does.

Core/include/Acts/Geometry/GridPortalLink.hpp (6)

70-72: Strong with validation, this code is!

Check the binning direction for plane surfaces, it does. Throw proper exceptions when invalid directions are used, it will.


361-364: Hmm, consistency check for plane surfaces, declared it has been!

Follow the ways of other surface types, it does. Essential for grid configuration validation, this is.


382-389: Well documented and consistent, this implementation is!

Follow the path of other surface types in grid extension, it does.


471-481: Strong with the Force, this constructor implementation is!

Handle plane surfaces with proper projections and error checks, it does. Follow the ways of other surface types, it does.


521-523: Hmm, wise addition to grid extension, this is!

Handle plane surfaces in dimension extension, it does. Follow the established patterns, it does.


573-574: Improved error handling, this change brings!

Use exceptions instead of assertions, it now does. More robust at runtime, this makes the code.

Tests/UnitTests/Core/Geometry/PortalLinkTests.cpp (4)

470-575: Comprehensive test coverage for 1D plane surface merging, I see!

Well structured test cases for merging plane surfaces in both X and Y directions, these are. Good validation of axis bounds and bin counts, you have included.


2447-2590: Thorough bin filling tests for plane surfaces, you have written!

Clever use of checkerboard pattern to verify correct bin assignments and volume resolution. The force is strong with these tests.


Line range hint 2844-3115: Well-crafted portal merging tests for plane surfaces, these are!

Good coverage of both X and Y directions with proper volume transformations and boundary checks. Strong test cases for the portal linking system, you have created.


2366-2372: ⚠️ Potential issue

A bug in the test assertions, I sense.

The test checks mergedY but uses mergedPtrX to get the pointer. Incorrect this is!

Apply this fix, you must:

-  const auto* mergedY = dynamic_cast<const merged_type*>(mergedPtrX.get());
+  const auto* mergedY = dynamic_cast<const merged_type*>(mergedPtrY.get());

Likely invalid or redundant comment.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
Core/src/Geometry/CompositePortalLink.cpp (1)

305-345: Additional validation checks, we should consider.

Hmm, missing some checks, this implementation is:

  • Validate consistent surface orientations, we must
  • Check for overlapping bounds between adjacent surfaces, we should
  • Verify alignment of surfaces along the binning direction, important it is

Add these checks before edge calculation, you should:

 bool dirX = m_direction == AxisDirection::AxisX;

+// Validate surface orientations and alignment
+const auto& refTransform = trivialLinks[0]->surface().transform(gctx);
+const Vector3 refNormal = refTransform.rotation().col(2);
+for (const auto* link : trivialLinks) {
+  const auto& transform = link->surface().transform(gctx);
+  const Vector3 normal = transform.rotation().col(2);
+  if (!normal.isApprox(refNormal)) {
+    throw std::runtime_error{"Inconsistent surface orientations in plane grid"};
+  }
+}
+
 std::vector<double> edges;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3138b68 and 5610456.

📒 Files selected for processing (1)
  • Core/src/Geometry/CompositePortalLink.cpp (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: unused_files
  • GitHub Check: missing_includes
  • GitHub Check: linux_ubuntu_extra (ubuntu2204, 20, clang++)
  • GitHub Check: linux_ubuntu_extra (ubuntu2204, 20, g++)
  • GitHub Check: linux_ubuntu
  • GitHub Check: macos
  • GitHub Check: build_debug
🔇 Additional comments (2)
Core/src/Geometry/CompositePortalLink.cpp (2)

18-18: Approve these changes, I do!

Wisely added, the new includes are. Elegant and consistent with existing patterns, the PlaneSurface merging implementation is. The Force is strong with this code!

Also applies to: 21-21, 54-56


297-303: Wise direction validation, you have implemented!

Clear and precise, the error handling for unsupported binning directions is. Strong boundaries, a Jedi must maintain!

Copy link
Member

@paulgessinger paulgessinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good! I didn't check the test cases in detail, but they seem comprehensive to me. Sonar suggests using using enum to reduce complexity in two cases.

@kodiakhq kodiakhq bot merged commit c98e878 into acts-project:main Jan 24, 2025
42 checks passed
@acts-project-service acts-project-service added the Breaks Athena build This PR breaks the Athena build label Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaks Athena build This PR breaks the Athena build Component - Core Affects the Core module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants