Skip to content

simplify toFieldBox usage#1018

Merged
nicolasaunai merged 4 commits intoPHAREHUB:masterfrom
nicolasaunai:fieldbox
Jun 10, 2025
Merged

simplify toFieldBox usage#1018
nicolasaunai merged 4 commits intoPHAREHUB:masterfrom
nicolasaunai:fieldbox

Conversation

@nicolasaunai
Copy link
Member

attempts to #1013

@coderabbitai
Copy link

coderabbitai bot commented Jun 8, 2025

📝 Walkthrough

"""

Walkthrough

The changes refactor box conversion logic throughout the field data and geometry classes by removing the withGhost boolean parameter from FieldGeometry::toFieldBox. All relevant code now explicitly uses ghost boxes obtained from patch data where needed, simplifying and unifying box handling. Variable naming is improved and some const correctness is enhanced in grid layout implementations. Test code is updated to align with these changes.

Changes

File(s) Change Summary
src/amr/data/field/field_geometry.hpp Refactored FieldGeometry::toFieldBox to remove withGhost parameter; simplified box conversion logic; updated usages accordingly; constructor and overlap setup updated.
src/amr/data/field/field_data.hpp Replaced getBox() with getGhostBox() in box conversions; updated comments accordingly.
src/amr/data/field/coarsening/field_coarsen_operator.hpp Updated to use ghost boxes and new box conversion logic; improved variable naming and aliases.
src/amr/data/field/refine/field_refine_operator.hpp Switched to using ghost boxes for source/destination; updated variable names for clarity.
src/amr/data/field/time_interpolate/field_linear_time_interpolate.hpp Removed withGhost flag; now explicitly uses ghost boxes for interpolation regions.
src/core/data/grid/gridlayout.hpp Removed extraneous blank line; no functional changes.
src/core/data/grid/gridlayoutimplyee.hpp Made centering arrays and variables const; reordered qualifiers for style and const-correctness.
tests/amr/data/field/time_interpolate/test_field_data_time_interpolate.cpp Refactored tests to use explicit ghost box construction instead of withGhost flag; replaced fixed ghost width with dynamic query.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant FieldData
    participant FieldGeometry
    participant GridLayout

    User->>FieldData: copy/pack/unpack/operate(...)
    FieldData->>FieldGeometry: toFieldBox(ghostBox, qty, layout)
    FieldGeometry->>GridLayout: isPrimal(qty, direction)
    FieldGeometry-->>FieldData: fieldBox
    FieldData-->>User: result
Loading

Possibly related issues


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 27af871 and 0c4d94f.

📒 Files selected for processing (3)
  • src/amr/data/field/field_geometry.hpp (7 hunks)
  • src/core/data/grid/gridlayout.hpp (0 hunks)
  • src/core/data/grid/gridlayoutimplyee.hpp (2 hunks)
💤 Files with no reviewable changes (1)
  • src/core/data/grid/gridlayout.hpp
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/amr/data/field/field_geometry.hpp
  • src/core/data/grid/gridlayoutimplyee.hpp
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: build (macos-13)
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (macos-14)
  • GitHub Check: Analyze (python)
  • GitHub Check: Analyze (cpp)
  • GitHub Check: build (ubuntu-latest, clang)
  • GitHub Check: build (ubuntu-latest, gcc)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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.

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.

@nicolasaunai
Copy link
Member Author

error TBD

in master field_linear_time_interpolate we have

  auto srcGhostBox = FieldGeometry<GridLayoutT, PhysicalQuantity>::toFieldBox(
            fieldDataSrcNew.getBox(), qty, fieldDataSrcNew.gridLayout, withGhost);

on this branch becomes:

  auto srcGhostBox = FieldGeometry<GridLayoutT, PhysicalQuantity>::toFieldBox(
            fieldDataSrcNew.getGhostBox(), qty, fieldDataSrcNew.gridLayout);

with the new definition of toFieldBox that just upper+1 in primal directions.

gdb tells me that fieldDataSrcNew box and ghost box are 0,20 and -5,25 for the first test case that fails.
seems to be a hard coded 5 ghost test from back in the days...

On master though, toFieldBox results in srcGhostBox being -2,23 whereas this PR it is -5,26.

The -5,26 on this PR is indeed just upper+1 as expected. On master it seems it's resulting in -2,23 because the toFieldBox uses 2 ghosts (leading to -2,22) and upper+1 thus -2,23. This layout ( fieldDataSrcNew.gridLayout), however, is inconsistent with the (it seems) hard coded 5 ghosts.

So I wonder who's wrong at this point.

TBD

@nicolasaunai
Copy link
Member Author

replacing the ghost{5} by ghost{GridYee::nbrGhosts()} makes the test working

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: 1

🔭 Outside diff range comments (2)
src/amr/data/field/field_geometry.hpp (2)

152-159: ⚠️ Potential issue

Update documentation to remove withGhost parameter reference.

The documentation still mentions the withGhost parameter which has been removed from the method signature.

         /**
          * @brief toFieldBox takes an AMR cell-centered box and creates a box
          * that is adequate for the specified quantity. The layout is used to know
-         * the centering, nbr of ghosts of the specified quantity.
-         * @param withGhost true if we want to include the ghost nodes in the field box.
+         * the centering of the specified quantity.
          *
          * Note : precondition : the nbr of physical cells of the layout must correspond
          *  to the nbr of cells of the box.
          */

279-279: ⚠️ Potential issue

Remove unused variable.

The withGhosts variable is no longer used after the refactoring and should be removed.

-            bool withGhosts = true;
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between da447a2 and 12973f8.

📒 Files selected for processing (2)
  • src/amr/data/field/field_geometry.hpp (7 hunks)
  • tests/amr/data/field/time_interpolate/test_field_data_time_interpolate.cpp (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/amr/data/field/time_interpolate/test_field_data_time_interpolate.cpp
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.hpp`: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.

**/*.hpp: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.

  • src/amr/data/field/field_geometry.hpp
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: build (macos-14)
  • GitHub Check: build (ubuntu-latest, gcc)
  • GitHub Check: build (macos-13)
  • GitHub Check: build (ubuntu-latest, clang)
  • GitHub Check: build (macos-latest)
  • GitHub Check: Analyze (cpp)
  • GitHub Check: Analyze (python)
🔇 Additional comments (4)
src/amr/data/field/field_geometry.hpp (4)

92-97: Good refactoring to explicit ghost box handling.

The constructor now explicitly creates a ghost box by growing the input box by the appropriate number of ghost cells. This is cleaner and more explicit than the previous boolean flag approach.


141-141: Correct update to match new toFieldBox signature.

The removal of the withGhost parameter is consistent with the refactoring.


194-206: Clean and correct implementation of field box conversion.

The simplified implementation correctly handles primal/dual centering by adding the appropriate offset to the upper bound. This is much cleaner than the previous conditional logic.


320-320: Consistent update in restriction box handling.

The toFieldBox call correctly follows the new signature without the withGhost parameter.

@nicolasaunai nicolasaunai merged commit 69d7d89 into PHAREHUB:master Jun 10, 2025
13 checks passed
This was referenced Jun 16, 2025
PhilipDeegan pushed a commit to PhilipDeegan/PHARE that referenced this pull request Jul 16, 2025
* simplify field box function
* fix hard coded ghost nbr=5 into regular layout usage in a test
PhilipDeegan pushed a commit to PhilipDeegan/PHARE that referenced this pull request Jul 19, 2025
* simplify field box function
* fix hard coded ghost nbr=5 into regular layout usage in a test
PhilipDeegan pushed a commit to PhilipDeegan/PHARE that referenced this pull request Oct 8, 2025
* simplify field box function
* fix hard coded ghost nbr=5 into regular layout usage in a test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants