variable density floor feature: simplified test problem#1551
variable density floor feature: simplified test problem#1551chongchonghe wants to merge 16 commits into
Conversation
for more information, see https://pre-commit.ci
Summary of ChangesHello @chongchonghe, 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 introduces a flexible variable density floor mechanism, allowing problem generators to define spatially varying density floors. This enhances the simulation's ability to handle complex physical scenarios where a uniform density floor might be insufficient. The changes involve modifying core simulation classes and updating the Highlights
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces a valuable feature for a variable density floor, which can be customized for specific problems. The implementation is well-structured, primarily by templating the EnforceLimits function to accept a function object for the density floor calculation and adding a virtual densityFloor method in QuokkaSimulation for problem-specific specializations. The new test case in StarCluster effectively demonstrates and validates this new capability. My review includes a few suggestions to enhance code quality by removing dead code, simplifying coordinate calculations for better readability, and correcting a potential logic error in the new test case.
| { | ||
| amrex::Real r = std::sqrt(x * x + y * y + z * z); | ||
| const Real rho_base_floor = 0.001; | ||
| const Real rho_peak = 1.0; |
There was a problem hiding this comment.
There is an inconsistency between the comment for the custom density floor and its implementation. The comment on line 227 states the function is max(0.001, 0.1 - 0.01 * r), but the implementation with rho_peak = 1.0 results in max(0.001, 1.0 - 0.1 * r). To match the comment, rho_peak should be 0.1.
const Real rho_peak = 0.1;| // if (this->useDensityFloorParser_) { | ||
| // auto const density_floor_parser = this->densityFloorParserExe_.value(); | ||
| // auto const density_floor_func = [=] AMREX_GPU_HOST_DEVICE(amrex::Real x, amrex::Real y, amrex::Real z, | ||
| // amrex::Real base_density_floor) -> amrex::Real { | ||
| // return density_floor_parser(x, y, z, base_density_floor); | ||
| // }; | ||
| // HydroSystem<problem_t>::EnforceLimits(densityFloor_, tempFloor_, state_mf, geom[lev].data(), density_floor_func); | ||
| // } else { | ||
| // auto const density_floor_func = [this] AMREX_GPU_HOST_DEVICE(amrex::Real x, amrex::Real y, amrex::Real z, | ||
| // amrex::Real base_density_floor) -> amrex::Real { | ||
| // return densityFloor(x, y, z, base_density_floor); | ||
| // }; | ||
| // HydroSystem<problem_t>::EnforceLimits(densityFloor_, tempFloor_, state_mf, geom[lev].data(), density_floor_func); | ||
| // } |
| amrex::Real const x = prob_lo[0] + (static_cast<amrex::Real>(i) + static_cast<amrex::Real>(0.5)) * dx[0]; | ||
| #if (AMREX_SPACEDIM >= 2) | ||
| amrex::Real const y = prob_lo[1] + (static_cast<amrex::Real>(j) + static_cast<amrex::Real>(0.5)) * dx[1]; | ||
| #else | ||
| amrex::Real const y = 0.0; | ||
| #endif | ||
| #if (AMREX_SPACEDIM == 3) | ||
| amrex::Real const z = prob_lo[2] + (static_cast<amrex::Real>(k) + static_cast<amrex::Real>(0.5)) * dx[2]; | ||
| #else | ||
| amrex::Real const z = 0.0; | ||
| #endif |
There was a problem hiding this comment.
The calculation of cell-center coordinates is a bit verbose with explicit static_cast. This can be simplified by relying on implicit type promotion, which improves readability.
amrex::Real const x = prob_lo[0] + (i + 0.5) * dx[0];
#if (AMREX_SPACEDIM >= 2)
amrex::Real const y = prob_lo[1] + (j + 0.5) * dx[1];
#else
amrex::Real const y = 0.0;
#endif
#if (AMREX_SPACEDIM == 3)
amrex::Real const z = prob_lo[2] + (k + 0.5) * dx[2];
#else
amrex::Real const z = 0.0;
#endifThere was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ 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".
| // (e.g., caused by the flux register or from interpolation) | ||
| virtual void FixupState(int level) = 0; | ||
|
|
||
| virtual void enforceDensityFloor(int lev, amrex::MultiFab &state_mf) = 0; |
There was a problem hiding this comment.
Pure virtual floor method not implemented by AdvectionSimulation
Making enforceDensityFloor(int, amrex::MultiFab&) pure virtual in AMRSimulation now requires every subclass to override it. AdvectionSimulation (src/linear_advection/AdvectionSimulation.hpp lines 32–75) derives from AMRSimulation but defines no enforceDensityFloor, so the class becomes abstract and any advection problem (e.g., testAdvection*.cpp) will fail to compile or instantiate. Provide an override or a base implementation to restore buildability.
Useful? React with 👍 / 👎.
for more information, see https://pre-commit.ci
…/quokka-astro/quokka into chong/copy/variable-den-floor-v2
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
|
Is this PR still needed? |
1 similar comment
|
Is this PR still needed? |




Description
Simplified version of #1520
Related issues
None.
Checklist
Before this pull request can be reviewed, all of these tasks should be completed. Denote completed tasks with an
xinside the square brackets[ ]in the Markdown source below:/azp run.