Skip to content

Set a safe default number of iterations for AMR grid generation#1611

Merged
BenWibking merged 2 commits intodevelopmentfrom
BenWibking/gridgen-default-iter
Jan 27, 2026
Merged

Set a safe default number of iterations for AMR grid generation#1611
BenWibking merged 2 commits intodevelopmentfrom
BenWibking/gridgen-default-iter

Conversation

@BenWibking
Copy link
Copy Markdown
Collaborator

@BenWibking BenWibking commented Jan 25, 2026

Description

Sets a safe default for the number of iterations to perform when tagging and re-gridding AMR levels.
This is an example of why this is required: https://github.com/BenWibking/amrex-gridgen-test

Related issues

See AMReX-Codes/amrex#4903.

Checklist

Before this pull request can be reviewed, all of these tasks should be completed. Denote completed tasks with an x inside the square brackets [ ] in the Markdown source below:

  • I have added a description (see above).
  • I have added a link to any related issues (if applicable; see above).
  • I have read the Contributing Guide.
  • I have added tests for any new physics that this PR adds to the code.
  • (For quokka-astro org members) I have manually triggered the GPU tests with the magic comment /azp run.

Sets a safe default for the number of iterations to perform when tagging and re-gridding AMR levels.

See AMReX-Codes/amrex#4903.
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jan 25, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @BenWibking, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the Adaptive Mesh Refinement (AMR) grid generation process by introducing a robust default for the number of iterations. This ensures that the system performs an adequate number of refinement steps, especially critical for complex simulations involving deeply nested AMR levels, thereby preventing potential issues arising from insufficient iteration counts.

Highlights

  • AMR Grid Iterations Default: A default value for the amr.max_grid_iterations parameter is now set in src/main.cpp if it's not explicitly defined.
  • Dynamic Default Calculation: The default number of iterations is dynamically calculated as std::max(4, amr_max_level), ensuring sufficient iterations for deeply nested Adaptive Mesh Refinement (AMR).
  • Improved Robustness: This change aims to improve the robustness of grid generation, particularly when refining small regions within deeply nested AMR structures, addressing an issue noted in MakeNewGrids: param to set number of grid iterations AMReX-Codes/amrex#4903.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@BenWibking
Copy link
Copy Markdown
Collaborator Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 2 pipeline(s).

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a sensible default for the number of AMR grid generation iterations, which is important for correctness when using deeply nested grids. The implementation is straightforward. I've found one issue with the use of amrex::ParmParse where the namespace prefix is incorrectly included in parameter names, which would prevent the feature from working as intended. My suggestion corrects this.

Comment thread src/main.cpp Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d7cc596beb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/main.cpp Outdated
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@BenWibking
Copy link
Copy Markdown
Collaborator Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 2 pipeline(s).

@sonarqubecloud
Copy link
Copy Markdown

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 27, 2026
@BenWibking BenWibking added this pull request to the merge queue Jan 27, 2026
Merged via the queue into development with commit bf2202e Jan 27, 2026
51 checks passed
@BenWibking BenWibking deleted the BenWibking/gridgen-default-iter branch February 9, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants