-
Notifications
You must be signed in to change notification settings - Fork 123
Make fluid variables uniform through the code #1063
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
Conversation
Complete version of the SG EoS
The following PR comprises changes to the code in order to call fluid variables uniformly through the code. The main changes for this PR is to change all the fluid_pp(i)% to their respective, which are defined on src/common/m_variables_conversion.fpp. For instance, substituting fluid_pp(i)%pi_inf by pi_infs(i), and so on. In certain cases, variable indices are also replaced to be uniform The importance of this PR is that, if these variables change through the code for whatever reason, they will be followed through the rest of the code
|
CodeAnt AI is reviewing your PR. |
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughThis PR centralizes EOS parameter usage by replacing per-fluid Changes
Sequence Diagram(s)(Skipped — changes are parameter-source substitutions and small refactors; control flow and component interactions remain unchanged.) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. Comment |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
There was a problem hiding this 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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/pre_process/m_assign_variables.fpp (1)
213-221: Tait exponentn_taitlikely initialized from the wrong parameter
n_taitis now set fromgs_min(1)and then transformed vian_tait = 1._wp/n_tait + 1._wp. This transformation appears to assumen_taitinitially holdsgamma, not “little gamma”/gs_min(1). Ifgs_min(1)is, as elsewhere, the precomputedlit_gamma, this change alters both the effective Tait exponent and the derivedB_taitcompared to the original formulation.To preserve the original behavior while still using the conversion arrays, you likely want:
- n_tait = gs_min(1) - B_tait = pi_infs(1) + n_tait = gammas(1) + B_tait = pi_infs(1) n_tait = 1._wp/n_tait + 1._wp B_tait = B_tait*(n_tait - 1._wp)/n_taitPlease confirm the intended meaning of
gs_min(1)here and adjust accordingly so that the Tait parameters remain consistent with the rest of the EOS handling.
🧹 Nitpick comments (2)
src/pre_process/m_data_output.fpp (1)
276-279: Assignments togamma,lit_gamma,pi_inf, andqvappear unused.Given that
gamma/pi_infare immediately overwritten bys_convert_to_mixture_variablesandlit_gammais recomputed inside the 1D loop, the initial values fromgammas(1),gs_min(1),pi_infs(1), andqvs(1)are never actually used. Consider dropping these four lines to reduce noise now that EOS parameters are fetched on demand.src/simulation/m_data_output.fpp (1)
410-416: Several EOS scalars (gamma,lit_gamma,pi_inf,qv) are now written but never read.In
s_write_serial_data_files,gamma,lit_gamma,pi_inf, andqvare initialized fromgammas(1),gs_min(1),pi_infs(1), andqvs(1)but not used later in the subroutine; similarly,lit_gammaassignments ins_write_probe_filesare unused. They’re harmless, but you can safely remove these locals and their assignments now that the oldfluid_pplookups are gone.Also applies to: 510-513, 1241-1243, 1355-1357
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
src/common/m_variables_conversion.fpp(3 hunks)src/post_process/m_data_output.fpp(3 hunks)src/post_process/m_derived_variables.fpp(1 hunks)src/pre_process/m_assign_variables.fpp(2 hunks)src/pre_process/m_data_output.fpp(1 hunks)src/pre_process/m_icpp_patches.fpp(6 hunks)src/simulation/m_data_output.fpp(3 hunks)src/simulation/m_global_parameters.fpp(0 hunks)src/simulation/m_pressure_relaxation.fpp(3 hunks)src/simulation/m_start_up.fpp(1 hunks)
💤 Files with no reviewable changes (1)
- src/simulation/m_global_parameters.fpp
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{fpp,f90}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{fpp,f90}: Use 2-space indentation; continuation lines align beneath &
Use lower-case keywords and intrinsics (do, end subroutine, etc.)
Name modules with m_ pattern (e.g., m_transport)
Name public subroutines with s_ pattern (e.g., s_compute_flux)
Name public functions with f_ pattern
Keep subroutine size ≤ 500 lines, helper subroutines ≤ 150 lines, functions ≤ 100 lines, files ≤ 1000 lines
Limit routine arguments to ≤ 6; use derived-type params struct if more are needed
Forbid goto statements (except in legacy code), COMMON blocks, and save globals
Every argument must have explicit intent; use dimension/allocatable/pointer as appropriate
Call s_mpi_abort() for errors, never use stop or error stop
**/*.{fpp,f90}: Indent 2 spaces; continuation lines align under&
Use lower-case keywords and intrinsics (do,end subroutine, etc.)
Name modules withm_<feature>prefix (e.g.,m_transport)
Name public subroutines ass_<verb>_<noun>(e.g.,s_compute_flux) and functions asf_<verb>_<noun>
Keep private helpers in the module; avoid nested procedures
Enforce size limits: subroutine ≤ 500 lines, helper ≤ 150, function ≤ 100, module/file ≤ 1000
Limit subroutines to ≤ 6 arguments; otherwise pass a derived-type 'params' struct
Avoidgotostatements (except unavoidable legacy); avoid global state (COMMON,save)
Every variable must haveintent(in|out|inout)specification and appropriatedimension/allocatable/pointer
Uses_mpi_abort(<msg>)for error termination instead ofstop
Use!>style documentation for header comments; follow Doxygen Fortran format with!! @paramand!! @returntags
Useimplicit nonestatement in all modules
Useprivatedeclaration followed by explicitpublicexports in modules
Use derived types with pointers for encapsulation (e.g.,pointer, dimension(:,:,:) => null())
Usepureandelementalattributes for side-effect-free functions; combine them for array ...
Files:
src/post_process/m_derived_variables.fppsrc/simulation/m_start_up.fppsrc/pre_process/m_data_output.fppsrc/simulation/m_pressure_relaxation.fppsrc/pre_process/m_icpp_patches.fppsrc/common/m_variables_conversion.fppsrc/simulation/m_data_output.fppsrc/post_process/m_data_output.fppsrc/pre_process/m_assign_variables.fpp
src/**/*.fpp
📄 CodeRabbit inference engine (.cursor/rules/mfc-agent-rules.mdc)
src/**/*.fpp: Use.fppfile extension for Fypp preprocessed files; CMake transpiles them to.f90
Start module files with Fypp include for macros:#:include 'macros.fpp'
Use the fyppASSERTmacro for validating conditions:@:ASSERT(predicate, message)
Use fypp macro@:ALLOCATE(var1, var2)for device-aware allocation instead of standard Fortranallocate
Use fypp macro@:DEALLOCATE(var1, var2)for device-aware deallocation instead of standard Fortrandeallocate
Files:
src/post_process/m_derived_variables.fppsrc/simulation/m_start_up.fppsrc/pre_process/m_data_output.fppsrc/simulation/m_pressure_relaxation.fppsrc/pre_process/m_icpp_patches.fppsrc/common/m_variables_conversion.fppsrc/simulation/m_data_output.fppsrc/post_process/m_data_output.fppsrc/pre_process/m_assign_variables.fpp
src/simulation/**/*.{fpp,f90}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/simulation/**/*.{fpp,f90}: Wrap tight GPU loops with !$acc parallel loop gang vector default(present) reduction(...); add collapse(n) when safe; declare loop-local variables with private(...)
Allocate large GPU arrays with managed memory or move them into persistent !$acc enter data regions at start-up
Avoid stop/error stop inside GPU device code
Ensure GPU code compiles with Cray ftn, NVIDIA nvfortran, GNU gfortran, and Intel ifx/ifort compilers
src/simulation/**/*.{fpp,f90}: Mark GPU-callable helpers with$:GPU_ROUTINE(function_name='...', parallelism='[seq]')immediately after declaration
Do not use OpenACC or OpenMP directives directly; use Fypp macros fromsrc/common/include/parallel_macros.fppinstead
Wrap tight loops with$:GPU_PARALLEL_FOR(private='[...]', copy='[...]')macro; addcollapse=nfor safe nested loop merging
Declare loop-local variables withprivate='[...]'in GPU parallel loop macros
Allocate large arrays withmanagedor move them into a persistent$:GPU_ENTER_DATA(...)region at start-up
Do not placestoporerror stopinside device code
Files:
src/simulation/m_start_up.fppsrc/simulation/m_pressure_relaxation.fppsrc/simulation/m_data_output.fpp
🧠 Learnings (15)
📚 Learning: 2025-11-24T21:50:16.684Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T21:50:16.684Z
Learning: Applies to src/simulation/**/*.{fpp,f90} : Wrap tight GPU loops with !$acc parallel loop gang vector default(present) reduction(...); add collapse(n) when safe; declare loop-local variables with private(...)
Applied to files:
src/simulation/m_start_up.fppsrc/simulation/m_pressure_relaxation.fppsrc/pre_process/m_icpp_patches.fppsrc/common/m_variables_conversion.fppsrc/simulation/m_data_output.fpp
📚 Learning: 2025-11-24T21:50:46.879Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .cursor/rules/mfc-agent-rules.mdc:0-0
Timestamp: 2025-11-24T21:50:46.879Z
Learning: Applies to src/simulation/**/*.{fpp,f90} : Wrap tight loops with `$:GPU_PARALLEL_FOR(private='[...]', copy='[...]')` macro; add `collapse=n` for safe nested loop merging
Applied to files:
src/simulation/m_start_up.fppsrc/simulation/m_pressure_relaxation.fppsrc/pre_process/m_icpp_patches.fppsrc/common/m_variables_conversion.fppsrc/simulation/m_data_output.fpp
📚 Learning: 2025-11-24T21:50:46.879Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .cursor/rules/mfc-agent-rules.mdc:0-0
Timestamp: 2025-11-24T21:50:46.879Z
Learning: Applies to src/simulation/**/*.{fpp,f90} : Declare loop-local variables with `private='[...]'` in GPU parallel loop macros
Applied to files:
src/simulation/m_start_up.fppsrc/simulation/m_pressure_relaxation.fppsrc/pre_process/m_icpp_patches.fppsrc/common/m_variables_conversion.fppsrc/pre_process/m_assign_variables.fpp
📚 Learning: 2025-11-24T21:50:46.879Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .cursor/rules/mfc-agent-rules.mdc:0-0
Timestamp: 2025-11-24T21:50:46.879Z
Learning: Applies to src/simulation/**/*.{fpp,f90} : Allocate large arrays with `managed` or move them into a persistent `$:GPU_ENTER_DATA(...)` region at start-up
Applied to files:
src/simulation/m_start_up.fppsrc/simulation/m_pressure_relaxation.fppsrc/simulation/m_data_output.fpp
📚 Learning: 2025-11-24T21:50:16.684Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T21:50:16.684Z
Learning: Applies to src/simulation/**/*.{fpp,f90} : Allocate large GPU arrays with managed memory or move them into persistent !$acc enter data regions at start-up
Applied to files:
src/simulation/m_start_up.fppsrc/simulation/m_pressure_relaxation.fppsrc/simulation/m_data_output.fpp
📚 Learning: 2025-11-24T21:50:46.879Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .cursor/rules/mfc-agent-rules.mdc:0-0
Timestamp: 2025-11-24T21:50:46.879Z
Learning: Applies to src/simulation/**/*.{fpp,f90} : Do not use OpenACC or OpenMP directives directly; use Fypp macros from `src/common/include/parallel_macros.fpp` instead
Applied to files:
src/simulation/m_start_up.fppsrc/simulation/m_pressure_relaxation.fppsrc/pre_process/m_icpp_patches.fpp
📚 Learning: 2025-11-24T21:50:16.684Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T21:50:16.684Z
Learning: Applies to src/simulation/**/*.{fpp,f90} : Ensure GPU code compiles with Cray ftn, NVIDIA nvfortran, GNU gfortran, and Intel ifx/ifort compilers
Applied to files:
src/simulation/m_start_up.fppsrc/simulation/m_pressure_relaxation.fppsrc/pre_process/m_icpp_patches.fppsrc/simulation/m_data_output.fpp
📚 Learning: 2025-11-24T21:50:16.684Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T21:50:16.684Z
Learning: Applies to src/simulation/**/*.{fpp,f90} : Avoid stop/error stop inside GPU device code
Applied to files:
src/simulation/m_start_up.fppsrc/simulation/m_pressure_relaxation.fppsrc/simulation/m_data_output.fpp
📚 Learning: 2025-11-24T21:50:46.879Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .cursor/rules/mfc-agent-rules.mdc:0-0
Timestamp: 2025-11-24T21:50:46.879Z
Learning: Applies to **/*.{fpp,f90} : Favor array operations over explicit loops when possible; use `collapse=N` directive to optimize nested loops
Applied to files:
src/simulation/m_start_up.fpp
📚 Learning: 2025-11-24T21:50:46.879Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .cursor/rules/mfc-agent-rules.mdc:0-0
Timestamp: 2025-11-24T21:50:46.879Z
Learning: Applies to src/simulation/**/*.{fpp,f90} : Mark GPU-callable helpers with `$:GPU_ROUTINE(function_name='...', parallelism='[seq]')` immediately after declaration
Applied to files:
src/simulation/m_start_up.fppsrc/simulation/m_pressure_relaxation.fppsrc/pre_process/m_icpp_patches.fppsrc/simulation/m_data_output.fpp
📚 Learning: 2025-11-24T21:50:46.879Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .cursor/rules/mfc-agent-rules.mdc:0-0
Timestamp: 2025-11-24T21:50:46.879Z
Learning: Applies to **/*.{fpp,f90} : Use `wp` (working precision) parameter from `m_precision_select` instead of hardcoded precision like `real*8`
Applied to files:
src/pre_process/m_data_output.fppsrc/pre_process/m_icpp_patches.fppsrc/simulation/m_data_output.fppsrc/pre_process/m_assign_variables.fpp
📚 Learning: 2025-11-24T21:50:46.879Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .cursor/rules/mfc-agent-rules.mdc:0-0
Timestamp: 2025-11-24T21:50:46.879Z
Learning: Applies to **/*.{fpp,f90} : Use `private` declaration followed by explicit `public` exports in modules
Applied to files:
src/simulation/m_pressure_relaxation.fppsrc/pre_process/m_icpp_patches.fpp
📚 Learning: 2025-11-24T21:50:46.879Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .cursor/rules/mfc-agent-rules.mdc:0-0
Timestamp: 2025-11-24T21:50:46.879Z
Learning: Applies to **/*.{fpp,f90} : Use lower-case keywords and intrinsics (`do`, `end subroutine`, etc.)
Applied to files:
src/pre_process/m_icpp_patches.fpp
📚 Learning: 2025-11-24T21:50:46.879Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .cursor/rules/mfc-agent-rules.mdc:0-0
Timestamp: 2025-11-24T21:50:46.879Z
Learning: Applies to **/*.{fpp,f90} : Keep private helpers in the module; avoid nested procedures
Applied to files:
src/pre_process/m_icpp_patches.fppsrc/post_process/m_data_output.fpp
📚 Learning: 2025-11-24T21:50:46.879Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .cursor/rules/mfc-agent-rules.mdc:0-0
Timestamp: 2025-11-24T21:50:46.879Z
Learning: Applies to **/*.{fpp,f90} : Each variable should have one clear purpose; do not use the same variable for multiple purposes
Applied to files:
src/pre_process/m_assign_variables.fpp
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
- GitHub Check: Detect File Changes
- GitHub Check: Detect File Changes
- GitHub Check: Github (ubuntu, mpi, no-debug, false)
- GitHub Check: Github (macos, mpi, no-debug, false)
- GitHub Check: Github (macos, mpi, debug, false)
- GitHub Check: Github (ubuntu, no-mpi, single, no-debug, false)
- GitHub Check: Github (ubuntu, mpi, no-debug, true)
- GitHub Check: Github (ubuntu, mpi, debug, true)
- GitHub Check: Github (ubuntu, mpi, debug, false)
- GitHub Check: Code Cleanliness Check
- GitHub Check: Coverage Test on CodeCov
- GitHub Check: cubic · AI code reviewer
- GitHub Check: Build & Publish
🔇 Additional comments (9)
src/simulation/m_pressure_relaxation.fpp (1)
159-196: Use ofpi_infs,ps_inf, andgs_minin Newton solver looks consistent; please re‑check the pressure floor constant.The replacement of
fluid_pp/module‑local EOS storage withpi_infs(i),ps_inf(i), andgs_min(i)inpres_K_init,rho_K_s, anddf_presis algebraically consistent with the stiffened‑gas form and the later(pres_relax + ps_inf(i))factors. The only thing I’d ask you to double‑check is the bound in Line [179]–[180]:pres_relaxis clamped to-(1._wp - 1.e-8_wp)*ps_inf(i) + 1._wpwhereaspres_K_inituses+ 1.e-8_wp; if these were meant to be identical floors, you may want to harmonize them.src/common/m_variables_conversion.fpp (2)
1309-1328: Energy and per‑fluid internal energy now consistent withs_compute_pressureand shared EOS arrays.The updated expressions for
q_cons_vf(E_idx)%sfand the model_eqns==3 internal energies correctly switch fromfluid_pp(i)%{gamma,pi_inf,qv}togammas(i),pi_infs(i), andqvs(i), and the non‑bubbles energy formulagamma*p + dyn_pres + pi_inf + qvnow exactly inverts the(energy - dyn_p - pi_inf - qv)/gammabranch ins_compute_pressure. Indices (intxb/advxb/contxb) are preserved, so this looks like a purely data‑source refactor.
1627-1639: Sound‑speed mix rule correctly migrated togammas,pi_infs, andgs_min.In
s_compute_speed_of_sound, both thealt_soundspeedtwo‑fluid bulk‑modulus computation and the model_eqns==3 mixture branch now pull EOS parameters fromgammas,pi_infs, andgs_mininstead offluid_pp, without changing the underlying formulas. This keeps all EOS data centralized while preserving previous behavior.src/post_process/m_derived_variables.fpp (1)
191-213: Alt‑sound‑speed path cleanly switched to shared EOS arrays.The
blkmod1/blkmod2computation ins_derive_sound_speednow usesgammas(1:2)andpi_infs(1:2), aligning post‑process sound‑speed evaluation with the centralized EOS arrays. As long ass_initialize_variables_conversion_module(or equivalent) runs before any calls into this routine, this looks good.src/simulation/m_start_up.fpp (1)
1054-1056: Internal energy update correctly switched to per-fluid arraysThe new RHS for
v_vf(i + intxb - 1)usesgammas(i),pi_infs(i), andqvs(i)with the same indexing pattern as before, so the change is a straightforward replacement offluid_pp(i)%...without altering loop structure or offsets.Please double-check at runtime (e.g., with a small test) that
gammas,pi_infs, andqvsare initialized for alli = 1..num_fluidsbefores_initialize_internal_energy_equationsis called, to avoid silent misuse of default values.src/post_process/m_data_output.fpp (1)
24-25: Energy diagnostics now consistently use conversion-module EOS arraysImporting
m_variables_conversionand replacingfluid_pp(l)%gamma/pi_inf/qvwithgammas(l),pi_infs(l), andqvs(l)ins_write_energy_data_filekeeps the structure of the energy and speed-of-sound calculations intact, while centralizing EOS data in the new arrays.Please confirm that:
gammas,pi_infs, andqvsare initialized in the post-process path befores_write_energy_data_fileruns, andgammas(2)/q_prim_vf(E_idx + 2)indeed correspond to the phase whose internal energy you intend to track inEgint.Also applies to: 1617-1632
src/pre_process/m_assign_variables.fpp (1)
566-573: Model 4 Tait EOS density now correctly sourced from EOS arraysFor the
model_eqns == 4branch,pi_inf,gamma, andlit_gammaare now taken frompi_infs(1),gammas(1), andgs_min(1), and the density is recomputed via the existing Tait relation using1/lit_gamma. This matches the usage pattern in other modules that switched fromfluid_pp(1)%...to the conversion arrays and keeps the formula structurally unchanged.src/pre_process/m_icpp_patches.fpp (2)
34-35: Consistent use of conversion-module EOS arrays in patch helpersAcross the various ICPP patch routines,
pi_inf,gamma, andlit_gammaare now initialized frompi_infs(1),gammas(1), andgs_min(1)after addinguse m_variables_conversion. This mirrors the prior use offluid_pp(1)%...while centralizing EOS data in the new arrays, without altering geometry logic or patch-selection behavior.Also applies to: 215-218, 753-756, 916-919, 1002-1005
798-803: Density reinit for model 4 rectangle patch dropsrhoreffactor—verify intentWhen
q_prim_vf(1)%sf(i, j, 0) < 1.e-10andmodel_eqns == 4, the rectangle patch now recomputes density via Tait EOS as:q_prim_vf(1)%sf(i, j, 0) = (((q_prim_vf(E_idx)%sf(i, j, 0) + pi_inf) / (pref + pi_inf))**(1._wp/lit_gamma)) * & (1._wp - q_prim_vf(alf_idx)%sf(i, j, 0))without a
rhoreffactor, whereas the similar formula ins_assign_patch_species_primitive_variablesstill multiplies byrhoref.Please confirm whether omitting
rhorefhere is intentional (e.g., due to a different normalization choice for this special patch) or whether the two Tait-based density resets should be kept consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 issues found across 10 files
Prompt for AI agents (all 3 issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="src/pre_process/m_icpp_patches.fpp">
<violation number="1" location="src/pre_process/m_icpp_patches.fpp:802">
Zero-density fixup now drops the `rhoref` factor, producing densities off by the reference density whenever this path executes.</violation>
</file>
<file name="src/pre_process/m_assign_variables.fpp">
<violation number="1" location="src/pre_process/m_assign_variables.fpp:216">
Initialize n_tait with gammas(1) so the existing transformation still yields the correct Tait exponent (1+γ)/γ.</violation>
</file>
<file name="src/simulation/m_pressure_relaxation.fpp">
<violation number="1" location="src/simulation/m_pressure_relaxation.fpp:180">
Lower-bounding `pres_relax` with a `+ 1._wp` shift raises the enforced minimum by an entire pressure unit, sabotaging the consistency with the initialization clamp and producing artificially high partial pressures. Use the same 1e-8 offset that was applied when capping `pres_K_init` to keep the clamp near the physically admissible minimum.</violation>
</file>
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
|
CodeAnt AI finished reviewing your PR. |
Co-authored-by: qodo-merge-pro[bot] <151058649+qodo-merge-pro[bot]@users.noreply.github.com>
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
There was a problem hiding this 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
♻️ Duplicate comments (1)
src/pre_process/m_assign_variables.fpp (1)
216-216: Incorrect EOS parameter: usegammas(1)instead ofgs_min(1)for Tait exponent.The Tait exponent formula at line 248 uses
1/n_tait, expectingn_taitto be γ. Based on the past review and the formula((1 + B_tait)/(p + B_tait))^(1/n_tait),n_taitshould be initialized with the specific heat ratio γ, not the Grüneisen parameter (1+γ)/γ.Apply this diff:
- n_tait = gs_min(1) + n_tait = gammas(1)
🧹 Nitpick comments (1)
src/pre_process/m_assign_variables.fpp (1)
563-565: Consider computinglit_gammadirectly for clarity.Since
gammais already assigned on line 564, computinglit_gamma = (1._wp + gamma)/gammadirectly would make the relationship explicit and reduce dependency on the pre-computedgs_minarray. This improves code clarity and makes the Tait EOS formula self-documenting.Apply this diff:
pi_inf = pi_infs(1) gamma = gammas(1) - lit_gamma = gs_min(1) + lit_gamma = (1._wp + gamma)/gamma
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/pre_process/m_assign_variables.fpp(2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{fpp,f90}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{fpp,f90}: Use 2-space indentation; continuation lines align beneath &
Use lower-case keywords and intrinsics (do, end subroutine, etc.)
Name modules with m_ pattern (e.g., m_transport)
Name public subroutines with s_ pattern (e.g., s_compute_flux)
Name public functions with f_ pattern
Keep subroutine size ≤ 500 lines, helper subroutines ≤ 150 lines, functions ≤ 100 lines, files ≤ 1000 lines
Limit routine arguments to ≤ 6; use derived-type params struct if more are needed
Forbid goto statements (except in legacy code), COMMON blocks, and save globals
Every argument must have explicit intent; use dimension/allocatable/pointer as appropriate
Call s_mpi_abort() for errors, never use stop or error stop
**/*.{fpp,f90}: Indent 2 spaces; continuation lines align under&
Use lower-case keywords and intrinsics (do,end subroutine, etc.)
Name modules withm_<feature>prefix (e.g.,m_transport)
Name public subroutines ass_<verb>_<noun>(e.g.,s_compute_flux) and functions asf_<verb>_<noun>
Keep private helpers in the module; avoid nested procedures
Enforce size limits: subroutine ≤ 500 lines, helper ≤ 150, function ≤ 100, module/file ≤ 1000
Limit subroutines to ≤ 6 arguments; otherwise pass a derived-type 'params' struct
Avoidgotostatements (except unavoidable legacy); avoid global state (COMMON,save)
Every variable must haveintent(in|out|inout)specification and appropriatedimension/allocatable/pointer
Uses_mpi_abort(<msg>)for error termination instead ofstop
Use!>style documentation for header comments; follow Doxygen Fortran format with!! @paramand!! @returntags
Useimplicit nonestatement in all modules
Useprivatedeclaration followed by explicitpublicexports in modules
Use derived types with pointers for encapsulation (e.g.,pointer, dimension(:,:,:) => null())
Usepureandelementalattributes for side-effect-free functions; combine them for array ...
Files:
src/pre_process/m_assign_variables.fpp
src/**/*.fpp
📄 CodeRabbit inference engine (.cursor/rules/mfc-agent-rules.mdc)
src/**/*.fpp: Use.fppfile extension for Fypp preprocessed files; CMake transpiles them to.f90
Start module files with Fypp include for macros:#:include 'macros.fpp'
Use the fyppASSERTmacro for validating conditions:@:ASSERT(predicate, message)
Use fypp macro@:ALLOCATE(var1, var2)for device-aware allocation instead of standard Fortranallocate
Use fypp macro@:DEALLOCATE(var1, var2)for device-aware deallocation instead of standard Fortrandeallocate
Files:
src/pre_process/m_assign_variables.fpp
🧠 Learnings (1)
📚 Learning: 2025-11-24T21:50:46.879Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .cursor/rules/mfc-agent-rules.mdc:0-0
Timestamp: 2025-11-24T21:50:46.879Z
Learning: Applies to **/*.{fpp,f90} : Use `wp` (working precision) parameter from `m_precision_select` instead of hardcoded precision like `real*8`
Applied to files:
src/pre_process/m_assign_variables.fpp
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
- GitHub Check: Code Cleanliness Check
- GitHub Check: Coverage Test on CodeCov
- GitHub Check: Github (ubuntu, no-mpi, single, no-debug, false)
- GitHub Check: Github (ubuntu, mpi, no-debug, false)
- GitHub Check: Github (ubuntu, mpi, no-debug, true)
- GitHub Check: Github (ubuntu, mpi, debug, false)
- GitHub Check: Github (ubuntu, mpi, debug, true)
- GitHub Check: cubic · AI code reviewer
- GitHub Check: Build & Publish
🔇 Additional comments (1)
src/pre_process/m_assign_variables.fpp (1)
216-217: I'll verify the definitions and purpose of these variables by searching the codebase. Let me start by examining the definitions inm_variables_conversion.fpp.
<function_calls>
#!/bin/bashFirst, locate the m_variables_conversion.fpp file
echo "=== Locating m_variables_conversion.fpp ==="
find . -name "m_variables_conversion.fpp" -type fecho ""
echo "=== Searching for gs_min, ps_inf, gammas, pi_infs definitions ==="Search in common/m_variables_conversion.fpp for these variable declarations
rg -n -A 3 -B 2 "gs_min|ps_inf|gammas|pi_infs" src/common/m_variables_conversion.fpp 2>/dev/null | head -150
</function_calls>Wait, let me refine this search to be more thorough and check the entire codebase structure first:
<function_calls>
#!/bin/bashLocate the file and search for variable definitions
echo "=== Finding m_variables_conversion.fpp ==="
fd "m_variables_conversion" --type fecho ""
echo "=== Searching for array declarations with gs_min, ps_inf, gammas, pi_infs ==="
rg -n "gs_min|ps_inf" src/ --type fpp --type f90 -B 3 -A 3 | head -200
</function_calls>Let me use a more targeted approach:
<function_calls>
#!/bin/bashFind and examine m_variables_conversion.fpp
echo "=== Locating variables conversion file ==="
find src -name "variablesconversion*" -type fecho ""
echo "=== Searching for gs_min definition ==="
rg -n "gs_min" src/ -B 2 -A 2echo ""
echo "=== Searching for ps_inf definition ==="
rg -n "ps_inf" src/ -B 2 -A 2
</function_calls>Let me search more broadly:
<function_calls>
#!/bin/bashList all files in src/common to find the right file
echo "=== Files in src/common ==="
ls -la src/common/ | grep -E "variables|conversion"echo ""
echo "=== Searching all .fpp files for gs_min ==="
find src -name "*.fpp" -exec rg -l "gs_min" {} ;echo ""
echo "=== Searching all .fpp files for ps_inf ==="
find src -name "*.fpp" -exec rg -l "ps_inf" {} ;
</function_calls>Let me try a more direct search:
<function_calls>
#!/bin/bashSearch for these variables in the entire src directory
echo "=== All occurrences of gs_min ==="
rg -rn "gs_min" src/ 2>/dev/nullecho ""
echo "=== All occurrences of ps_inf ==="
rg -rn "ps_inf" src/ 2>/dev/nullecho ""
echo "=== All occurrences of gammas ==="
rg -rn "gammas" src/ 2>/dev/null | head -50echo ""
echo "=== All occurrences of pi_infs ==="
rg -rn "pi_infs" src/ 2>/dev/null | head -50
</function_calls>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1063 +/- ##
==========================================
- Coverage 44.35% 44.33% -0.03%
==========================================
Files 71 71
Lines 20587 20580 -7
Branches 1993 1992 -1
==========================================
- Hits 9132 9124 -8
- Misses 10310 10312 +2
+ Partials 1145 1144 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
User description
User description
Description
The following PR comprises changes to the code to call fluid variables uniformly throughout the code. The main changes for this PR is to change all the fluid_pp(i)% to their respective variables, defined on src/common/m_variables_conversion.fpp. For instance, substituting fluid_pp(i)%pi_inf by pi_infs(i), and so on.
Type of change
Scope
If you cannot check the above box, please split your PR into multiple PRs that each have a common goal.
./mfc.sh formatbefore committing my codeIf your code changes any code source files (anything in
src/simulation)To make sure the code is performing as expected on GPU devices, I have:
nvtxranges so that they can be identified in profiles./mfc.sh run XXXX --gpu -t simulation --nsys, and have attached the output file (.nsys-rep) and plain text results to this PR./mfc.sh run XXXX --gpu -t simulation --rsys --hip-trace, and have attached the output file and plain text results to this PR.PR Type
Enhancement
Description
Replace
fluid_pp(i)%struct accesses with uniform variable arraysSubstitute
gamma,pi_inf,qvwithgammas(i),pi_infs(i),qvs(i)Replace index calculations with shorthand variables (
intxb,advxb,contxb,gs_min,ps_inf)Remove redundant local variable allocations from pressure relaxation module
Add missing module imports for variable conversion support
Diagram Walkthrough
File Walkthrough
9 files
Replace fluid_pp struct with uniform variable arraysUpdate fluid variable access to use uniform arraysStandardize fluid property variable referencesReplace fluid_pp struct with uniform variable arraysUpdate fluid variable access patterns uniformlyAdd module import and standardize variable accessReplace fluid_pp struct with uniform variable arraysRemove redundant local arrays use global variablesStandardize internal energy calculation variable access1 files
Remove debug print statementsCodeAnt-AI Description
Ensure derived outputs use shared EOS parameters
What Changed
Impact
✅ Consistent EOS-driven energy and sound-speed reports✅ Valid pressure and volume-fraction recovery during relaxation✅ Accurate EOS-based initial conditions and diagnostics💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.
Summary by CodeRabbit
Refactor
Chores
✏️ Tip: You can customize this high-level summary in your review settings.