Skip to content

Conversation

@Cowsreal
Copy link
Contributor

@Cowsreal Cowsreal commented Nov 25, 2025

User description

User description

Description

This PR adds a total of 3 2D examples cases: Kelvin-Helmholtz Instability, Richtmyer-Meshkov Instability, and Viscous Shock Tube.

Type of change

Please delete options that are not relevant.

  • Something else

Scope

  • This PR comprises a set of related changes with a common goal

If you cannot check the above box, please split your PR into multiple PRs that each have a common goal.

How Has This Been Tested?

See below images of result. These were visually compared to the result diagrams from the paper. (https://arxiv.org/abs/2106.01738)

2D_kelvin_helmholtz:

Kelvin1

2D_richtmyer_meshkov:

Rich1

2D_viscous_shock_tube:

Re = 500:

ViscousShockTube500

Re = 1000:

ViscousShockTube

Test Configuration:

  • What computers and compilers did you use to test this: NCSA Delta + nvhpc v24.1

Checklist

  • I have added comments for the new code
  • I added Doxygen docstrings to the new code
  • I have made corresponding changes to the documentation (docs/)
  • I have added regression tests to the test suite so that people can verify in the future that the feature is behaving as expected
  • I have added example cases in examples/ that demonstrate my new feature performing as expected.
    They run to completion and demonstrate "interesting physics"
  • I ran ./mfc.sh format before committing my code
  • This PR does not introduce any repeated code (it follows the DRY principle)
  • I cannot think of a way to condense this code and reduce any introduced additional line count

PR Type

Enhancement

Description

  • Add three new 2D example cases for multiphase flow simulations

    • Kelvin-Helmholtz Instability with velocity perturbations
    • Richtmyer-Meshkov Instability with interface smoothing
    • Viscous Shock Tube with viscous effects
  • Implement hardcoded initial conditions (hcid 207, 208) in Fortran preprocessor

  • Include complete case configurations with Python setup scripts

  • Add README documentation for each example with references

Diagram Walkthrough

flowchart LR
  A["Hardcoded IC Module"] -->|Add cases 207, 208| B["2D Initial Conditions"]
  B -->|Configure| C["Kelvin-Helmholtz"]
  B -->|Configure| D["Richtmyer-Meshkov"]
  B -->|Configure| E["Viscous Shock Tube"]
  C -->|Setup script| F["case.py + README"]
  D -->|Setup script| G["case.py + README"]
  E -->|Setup script| H["case.py + README"]
Loading

File Walkthrough

Relevant files
Enhancement
2dHardcodedIC.fpp
Add hardcoded initial conditions for two instability cases

src/common/include/2dHardcodedIC.fpp

  • Add variable declarations for Kelvin-Helmholtz case (sigma, gauss1,
    gauss2)
  • Add variable declarations for Richtmyer-Meshkov case (ei, d, fsm,
    alpha_air, alpha_sf6)
  • Implement case 207 with Gaussian-modulated velocity perturbation for
    K-H instability
  • Implement case 208 with smoothed interface and volume fraction
    initialization for R-M instability
+31/-0   
case.py
Kelvin-Helmholtz instability case configuration                   

examples/2D_kelvin_helmholtz/case.py

  • Configure 512x512 computational domain with periodic boundaries
  • Set up two-fluid system with velocity shear (±0.5 m/s)
  • Define simulation parameters including WENO5 reconstruction and
    adaptive CFL
  • Configure fluid properties with gamma = 5/3 for both fluids
+90/-0   
case.py
Richtmyer-Meshkov instability case configuration                 

examples/2D_richtmyer_meshkov/case.py

  • Configure 4096x256 high-resolution domain for shock-interface
    interaction
  • Set up pre-shock and post-shock states with different fluid properties
  • Enable viscous effects with Reynolds number based on viscosity
  • Configure mapped WENO and characteristic-based Riemann solver
+99/-0   
case.py
Viscous shock tube case configuration                                       

examples/2D_viscous_shock_tube/case.py

  • Configure 1280x640 domain for viscous shock tube problem
  • Set up left/right pressure-driven flow with high pressure ratio
    (100:1)
  • Enable viscous effects with configurable Reynolds number
  • Use mapped WENO reconstruction with characteristic-based Riemann
    solver
+92/-0   
Documentation
README.md
Kelvin-Helmholtz example documentation                                     

examples/2D_kelvin_helmholtz/README.md

  • Document Kelvin-Helmholtz instability example with reference to paper
  • Include placeholder sections for initial and evolved state figures
  • Reference Example 4.8 from arXiv:2106.01738
+10/-0   
README.md
Richtmyer-Meshkov example documentation                                   

examples/2D_richtmyer_meshkov/README.md

  • Document Richtmyer-Meshkov instability example with paper reference
  • Include placeholder sections for initial and evolved state figures
  • Reference Example 4.18 from arXiv:2106.01738
+10/-0   
README.md
Viscous shock tube example documentation                                 

examples/2D_viscous_shock_tube/README.md

  • Document viscous shock tube example with paper reference
  • Include placeholder sections for initial and evolved state figures
  • Reference Example 4.13 from arXiv:2106.01738
+10/-0   

CodeAnt-AI Description

Add Kelvin-Helmholtz, Richtmyer-Meshkov, and viscous shock tube 2D demos

What Changed

  • Added hardcoded case IDs for Kelvin-Helmholtz and Richtmyer-Meshkov flows so their initial perturbations and smoothed interfaces are available to the solver
  • Introduced JSON-generating scripts that configure domain size, materials, and solver settings for each of the three new examples
  • Documented every new example with reference info plus initial and evolved state illustrations

Impact

✅ Ready-to-run Kelvin-Helmholtz demo
✅ Richtmyer-Meshkov validation available
✅ Viscous shock tube benchmark documented

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

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

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:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

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

  • New Features

    • Added three new 2D simulation examples (Kelvin–Helmholtz, Richtmyer–Meshkov, Viscous Shock Tube) with JSON configuration generators.
    • Added new built-in 2D initial-condition cases to support these scenarios.
  • Documentation

    • Added README content for each example with references, initial/evolved state descriptions, and placeholder figures.
  • Tests

    • Added new static test metadata artifacts capturing build/run metadata and environment snapshots.

✏️ Tip: You can customize this high-level summary in your review settings.

@Cowsreal Cowsreal requested a review from a team November 25, 2025 21:30
@codeant-ai
Copy link

codeant-ai bot commented Nov 25, 2025

CodeAnt AI is reviewing your PR.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 25, 2025

Note

Other AI code review bot(s) detected

CodeRabbit 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.

Walkthrough

Adds three 2D example cases (Kelvin–Helmholtz, Richtmyer–Meshkov, viscous shock tube): README fragments and Python scripts that emit JSON simulation configurations, extends 2D hardcoded initial-condition switch with two new cases (207, 208), and adds several test metadata artifacts.

Changes

Cohort / File(s) Summary
Example READMEs
examples/2D_kelvin_helmholtz/README.md, examples/2D_richtmyer_meshkov/README.md, examples/2D_viscous_shock_tube/README.md
Added Markdown README fragments with citations and Initial/Evolved State sections referencing placeholder figures.
Example config generators
examples/2D_kelvin_helmholtz/case.py, examples/2D_richtmyer_meshkov/case.py, examples/2D_viscous_shock_tube/case.py
New Python scripts that construct and print JSON configuration objects (logistics, domain/grid, solver/time settings, patch/state definitions, fluid properties).
Hardcoded 2D initial conditions
src/common/include/2dHardcodedIC.fpp
Added new cases 207 (Kelvin–Helmholtz: sinusoidal x-momentum perturbation with Gaussian modulation) and 208 (Richtmyer–Meshkov: erf-based interface smoothing and species distribution); introduced related variables and integrated cases into existing switch.
Test metadata artifacts
tests/70EC99CE/golden-metadata.txt, tests/986BC1A2/golden-metadata.txt, tests/A078904B/golden-metadata.txt
Added static/golden metadata files capturing build/run environment and CMake/test configuration details.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Dev as Developer / CLI
  participant Py as example case.py
  participant STDOUT as STDOUT (JSON)
  participant Runner as Simulation Runner
  participant Fortran as 2dHardcodedIC.fpp

  Dev->>Py: run example case script
  Py->>STDOUT: emit JSON config
  Dev->>Runner: supply JSON config (file/stdin)
  Runner->>Fortran: request initial conditions (case id)
  Fortran-->>Runner: return initialized fields (case 207/208)
  Runner->>Runner: advance timesteps using config

  note right of Fortran `#DDEBF7`: New cases 207 and 208 added
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Review focus:
    • src/common/include/2dHardcodedIC.fpp: verify mathematical expressions (erf, Gaussian), conditional branching, and correct case integration.
    • examples/*/case.py: validate numeric constants, derived computations, JSON shape, and case IDs matching Fortran.
    • Test metadata files: confirm they are intended artifacts and contain no sensitive/environment-specific data.

Suggested labels

Review effort 4/5

Suggested reviewers

  • wilfonba

Poem

🐰 I hopped through code and stitched a seam,
I sprinkled Gaussians where vortices dream.
JSON carrots, erf-cloud delight,
Two new cases dancing into night.
Small patches, big waves — hop, take flight!

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive The description covers the additions but several required template sections remain unchecked and incomplete, including GPU testing, documentation updates, and test verification checkboxes. Complete the template checklist by checking applicable items and clarify GPU testing status, regression test implementation, documentation updates, and code formatting verification.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Three new examples cases' directly and clearly summarizes the main change—adding three new 2D example cases.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 384d0b1 and ee67776.

📒 Files selected for processing (3)
  • tests/70EC99CE/golden-metadata.txt (1 hunks)
  • tests/986BC1A2/golden-metadata.txt (1 hunks)
  • tests/A078904B/golden-metadata.txt (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • tests/A078904B/golden-metadata.txt
  • tests/986BC1A2/golden-metadata.txt
  • tests/70EC99CE/golden-metadata.txt
⏰ 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). (1)
  • GitHub Check: cubic · AI code reviewer

Comment @coderabbitai help to get the list of available commands and usage tips.

@codeant-ai codeant-ai bot added the size:L This PR changes 100-499 lines, ignoring generated files label Nov 25, 2025
@qodo-code-review
Copy link
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

174 - Partially compliant

Compliant requirements:

  • Add Kelvin–Helmholtz instability (2D) example with case configuration.
  • Add Richtmyer–Meshkov instability (2D) example with case configuration.
  • Add Viscous Shock Tube (2D) example with case configuration.
  • Provide references in example READMEs.

Non-compliant requirements:

  • Include small visualization images in the examples directory.
  • Add regression tests to verify example behavior.

Requires further human verification:

  • Validate that the physical results qualitatively match referenced figures (visual inspection).
  • Confirm runtime/memory footprint is acceptable on typical hardware.
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Possible Issue

In case 208, the assignment to q_prim_vf(contxb/contxe)%sf uses hardcoded multipliers (5.04 and 1.0) without clear consistency with alpha_rho density definitions; also alpha_sf6 is computed as 1.0 - alpha_air mixing doubles as mass fraction vs volume fraction. Verify units and that alpha_rho = alpha * rho as expected.

        q_prim_vf(contxb)%sf(i, j, 0) = alpha_sf6 * 5.04
        q_prim_vf(contxe)%sf(i, j, 0) = alpha_air * 1.0
        q_prim_vf(advxb)%sf(i, j, 0) = alpha_sf6
        q_prim_vf(advxe)%sf(i, j, 0) = alpha_air 
end if
Boundary Sensitivity

The RMI interface smoothing uses erf(d/(eisqrt(dxdy))) but is wrapped in an if with x <= 0.7lam, leaving states for x > 0.7lam to patches; ensure patches fully cover and no uninitialized cells occur near the interface due to conditional scope.

if(x_cc(i) <= 0.7 * lam) then
        d = x_cc(i) - lam * (0.4_wp - 0.1_wp * sin(2.0_wp * pi * (y_cc(j) / lam + 0.25_wp)))
        fsm = 0.5_wp * (1.0_wp + erf(d / (ei * sqrt(dx * dy))))
        alpha_air = eps + (1.0_wp - 2.0_wp * eps) * fsm
        alpha_sf6 = 1.0 - alpha_air

        q_prim_vf(contxb)%sf(i, j, 0) = alpha_sf6 * 5.04
        q_prim_vf(contxe)%sf(i, j, 0) = alpha_air * 1.0
        q_prim_vf(advxb)%sf(i, j, 0) = alpha_sf6
        q_prim_vf(advxe)%sf(i, j, 0) = alpha_air 
end if
Incomplete IC

Case 207 only adds a y-localized u-perturbation to q_prim_vf(momxb+1) but does not initialize density/pressure or v-velocity here; relies on patches. Confirm this cannot leave cells without intended perturbation or with inconsistent momentum vs velocity if q_prim_vf expects primitive velocity vs momentum indexing.

case (207) ! Kelvin Helmholtz Instability

    sigma = 0.05_wp / sqrt(2.0_wp)
    gauss1 = exp(- (y_cc(j) - 0.75_wp) ** 2 / (2 * sigma ** 2))
    gauss2 = exp(- (y_cc(j) - 0.25_wp) ** 2 / (2 * sigma ** 2))

    q_prim_vf(momxb + 1)%sf(i, j, 0) = &
            0.1_wp * sin(4.0_wp * pi * x_cc(i)) * (gauss1 + gauss2)

@codeant-ai
Copy link

codeant-ai bot commented Nov 25, 2025

Pull Request Feedback 🔍

🔒 No security issues identified
⚡ Recommended areas for review

  • Incomplete KH init
    Case 207 only touches momxb+1, leaving the rest of the primitive variables unchanged. Because the initialization never sets densities, pressures, or volume fractions, the "Kelvin‑Helmholtz" patch inherits whatever values happen to be left in the arrays, so the example starts from a garbage state. The case should set the base fluid state (e.g., the patch's densities/pressures/alphas) before adding the velocity perturbation so that the interface is well defined in every cell.

  • Partial RM init
    Case 208 assigns contxb, contxe, and advxb/advxe only when x_cc(i) <= 0.7*lam. For x > 0.7*lam those fields stay at previous values (likely zero), so the mass fractions/alphas on half the domain are undefined and the intended Richtmyer–Meshkov interface is never created. Populate the same primitives for the entire domain (e.g., add an else block that sets the base air values) to ensure consistency across the patch.

@codeant-ai
Copy link

codeant-ai bot commented Nov 25, 2025

CodeAnt AI finished reviewing your PR.

Copy link
Contributor

@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: 6

🧹 Nitpick comments (2)
src/common/include/2dHardcodedIC.fpp (2)

7-10: Improve variable documentation and naming clarity.

The variable declarations follow the working precision guideline (wp) but could be more maintainable:

  • Use descriptive comments explaining the purpose of each variable group.
  • Consider more descriptive names (e.g., eiinterface_width, ddistance, fsmsmoothing_factor).

Apply this diff:

-    ! # 207
+    ! Case 207: Kelvin-Helmholtz instability
     real(wp) :: sigma, gauss1, gauss2
-    ! # 208
+    ! Case 208: Richtmyer-Meshkov instability
     real(wp) :: ei, d, fsm, alpha_air, alpha_sf6

145-161: Address variable shadowing and precision suffix.

The Richtmyer-Meshkov interface smoothing implementation is generally correct, but has minor issues:

  1. Line 148: Local eps shadows the outer declaration (line 12), which could cause confusion. Consider using a distinct name like eps_local or alpha_eps.
  2. Line 155: Missing _wp precision suffix on 1.0.

Apply this diff:

     case (208) ! Richtmeyer Meshkov Instability
 
         lam = 1.0_wp
-        eps = 1.0e-6_wp
+        ! Note: using local epsilon for this case
+        eps = 1.0e-6_wp
         ei = 5.0_wp
         ! Smoothening function to smooth out sharp discontinuity in the interface
         if(x_cc(i) <= 0.7 * lam) then
                 d = x_cc(i) - lam * (0.4_wp - 0.1_wp * sin(2.0_wp * pi * (y_cc(j) / lam + 0.25_wp)))
                 fsm = 0.5_wp * (1.0_wp + erf(d / (ei * sqrt(dx * dy))))
                 alpha_air = eps + (1.0_wp - 2.0_wp * eps) * fsm
-                alpha_sf6 = 1.0 - alpha_air
+                alpha_sf6 = 1.0_wp - alpha_air
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 11375f3 and 22e3756.

⛔ Files ignored due to path filters (6)
  • examples/2D_kelvin_helmholtz/figure0.png is excluded by !**/*.png
  • examples/2D_kelvin_helmholtz/figure1.png is excluded by !**/*.png
  • examples/2D_richtmyer_meshkov/figure0.png is excluded by !**/*.png
  • examples/2D_richtmyer_meshkov/figure1.png is excluded by !**/*.png
  • examples/2D_viscous_shock_tube/figure0.png is excluded by !**/*.png
  • examples/2D_viscous_shock_tube/figure1.png is excluded by !**/*.png
📒 Files selected for processing (7)
  • examples/2D_kelvin_helmholtz/README.md (1 hunks)
  • examples/2D_kelvin_helmholtz/case.py (1 hunks)
  • examples/2D_richtmyer_meshkov/README.md (1 hunks)
  • examples/2D_richtmyer_meshkov/case.py (1 hunks)
  • examples/2D_viscous_shock_tube/README.md (1 hunks)
  • examples/2D_viscous_shock_tube/case.py (1 hunks)
  • src/common/include/2dHardcodedIC.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 with m_<feature> prefix (e.g., m_transport)
Name public subroutines as s_<verb>_<noun> (e.g., s_compute_flux) and functions as f_<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
Avoid goto statements (except unavoidable legacy); avoid global state (COMMON, save)
Every variable must have intent(in|out|inout) specification and appropriate dimension / allocatable / pointer
Use s_mpi_abort(<msg>) for error termination instead of stop
Use !> style documentation for header comments; follow Doxygen Fortran format with !! @param and !! @return tags
Use implicit none statement in all modules
Use private declaration followed by explicit public exports in modules
Use derived types with pointers for encapsulation (e.g., pointer, dimension(:,:,:) => null())
Use pure and elemental attributes for side-effect-free functions; combine them for array ...

Files:

  • src/common/include/2dHardcodedIC.fpp
src/**/*.fpp

📄 CodeRabbit inference engine (.cursor/rules/mfc-agent-rules.mdc)

src/**/*.fpp: Use .fpp file extension for Fypp preprocessed files; CMake transpiles them to .f90
Start module files with Fypp include for macros: #:include 'macros.fpp'
Use the fypp ASSERT macro for validating conditions: @:ASSERT(predicate, message)
Use fypp macro @:ALLOCATE(var1, var2) for device-aware allocation instead of standard Fortran allocate
Use fypp macro @:DEALLOCATE(var1, var2) for device-aware deallocation instead of standard Fortran deallocate

Files:

  • src/common/include/2dHardcodedIC.fpp
🧠 Learnings (1)
📚 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: Update in-code comments and documentation (README or docs site) when making significant changes

Applied to files:

  • examples/2D_kelvin_helmholtz/README.md
  • examples/2D_richtmyer_meshkov/README.md
🪛 markdownlint-cli2 (0.18.1)
examples/2D_viscous_shock_tube/README.md

6-6: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)


7-7: Images should have alternate text (alt text)

(MD045, no-alt-text)


10-10: Images should have alternate text (alt text)

(MD045, no-alt-text)

examples/2D_kelvin_helmholtz/README.md

6-6: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)


7-7: Images should have alternate text (alt text)

(MD045, no-alt-text)


10-10: Images should have alternate text (alt text)

(MD045, no-alt-text)

examples/2D_richtmyer_meshkov/README.md

6-6: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)


7-7: Images should have alternate text (alt text)

(MD045, no-alt-text)


10-10: Images should have alternate text (alt text)

(MD045, no-alt-text)

🪛 Ruff (0.14.5)
examples/2D_kelvin_helmholtz/case.py

1-1: Shebang is present but file is not executable

(EXE001)

examples/2D_richtmyer_meshkov/case.py

1-1: Shebang is present but file is not executable

(EXE001)

examples/2D_viscous_shock_tube/case.py

1-1: Shebang is present but file is not executable

(EXE001)

🔇 Additional comments (4)
examples/2D_viscous_shock_tube/case.py (1)

55-91: LGTM: Well-configured viscous shock tube setup.

The patch definitions correctly tile the domain, with a 100:1 pressure ratio between left (120.0) and right (1.2) states. The species separation using epsilon, Reynolds number calculation, and fluid parameters are appropriate for the viscous shock tube case.

src/common/include/2dHardcodedIC.fpp (1)

136-144: LGTM: Kelvin-Helmholtz perturbation correctly implemented.

The sinusoidal perturbation modulated by two Gaussian lobes (centered at y=0.25 and y=0.75) correctly initializes the instability. The hardcoded case works in conjunction with the patch-defined base flow velocities.

examples/2D_kelvin_helmholtz/case.py (1)

53-89: LGTM: Proper Kelvin-Helmholtz configuration with shear and density stratification.

The two-patch setup correctly creates:

  • Shear layer: outer regions (u=-0.5) vs. center strip (u=+0.5)
  • Density stratification: outer regions (ρ=1) vs. center strip (ρ=2)
  • Sinusoidal perturbation via hcid=207 at the shear interfaces

The configuration aligns well with the hardcoded case 207 implementation.

examples/2D_richtmyer_meshkov/case.py (1)

57-98: LGTM: Proper Richtmyer-Meshkov shock-interface configuration.

The two-patch setup correctly implements:

  • Pre-shock region (x ≤ 0.7λ) with perturbed SF6-air interface via hcid=208
  • Post-shock region with Rankine-Hugoniot jump conditions
  • Appropriate fluid properties (SF6 γ=1.093, air γ=1.4) and Reynolds number for viscous effects

The configuration aligns well with the hardcoded case 208 implementation.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 13 files

Copy link
Contributor

@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

♻️ Duplicate comments (3)
examples/2D_viscous_shock_tube/case.py (1)

1-4: Unused import and shebang issue already flagged.

examples/2D_kelvin_helmholtz/case.py (1)

1-4: Unused import and shebang issue already flagged.

examples/2D_richtmyer_meshkov/case.py (1)

1-4: Unused import and shebang issue already flagged.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 22e3756 and 6f6e3d3.

📒 Files selected for processing (4)
  • examples/2D_kelvin_helmholtz/case.py (1 hunks)
  • examples/2D_richtmyer_meshkov/case.py (1 hunks)
  • examples/2D_viscous_shock_tube/case.py (1 hunks)
  • src/common/include/2dHardcodedIC.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 with m_<feature> prefix (e.g., m_transport)
Name public subroutines as s_<verb>_<noun> (e.g., s_compute_flux) and functions as f_<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
Avoid goto statements (except unavoidable legacy); avoid global state (COMMON, save)
Every variable must have intent(in|out|inout) specification and appropriate dimension / allocatable / pointer
Use s_mpi_abort(<msg>) for error termination instead of stop
Use !> style documentation for header comments; follow Doxygen Fortran format with !! @param and !! @return tags
Use implicit none statement in all modules
Use private declaration followed by explicit public exports in modules
Use derived types with pointers for encapsulation (e.g., pointer, dimension(:,:,:) => null())
Use pure and elemental attributes for side-effect-free functions; combine them for array ...

Files:

  • src/common/include/2dHardcodedIC.fpp
src/**/*.fpp

📄 CodeRabbit inference engine (.cursor/rules/mfc-agent-rules.mdc)

src/**/*.fpp: Use .fpp file extension for Fypp preprocessed files; CMake transpiles them to .f90
Start module files with Fypp include for macros: #:include 'macros.fpp'
Use the fypp ASSERT macro for validating conditions: @:ASSERT(predicate, message)
Use fypp macro @:ALLOCATE(var1, var2) for device-aware allocation instead of standard Fortran allocate
Use fypp macro @:DEALLOCATE(var1, var2) for device-aware deallocation instead of standard Fortran deallocate

Files:

  • src/common/include/2dHardcodedIC.fpp
🪛 Ruff (0.14.5)
examples/2D_kelvin_helmholtz/case.py

1-1: Shebang is present but file is not executable

(EXE001)

examples/2D_richtmyer_meshkov/case.py

1-1: Shebang is present but file is not executable

(EXE001)

examples/2D_viscous_shock_tube/case.py

1-1: Shebang is present but file is not executable

(EXE001)

🔇 Additional comments (4)
src/common/include/2dHardcodedIC.fpp (1)

136-141: LGTM!

The Kelvin-Helmholtz perturbation implementation correctly applies a sinusoidal y-velocity perturbation modulated by two Gaussian lobes centered at y = 0.25 and y = 0.75. The precision literals are consistent with _wp.

examples/2D_viscous_shock_tube/case.py (1)

12-91: LGTM!

The viscous shock tube configuration is well-structured with appropriate density and pressure ratios (100:1), viscous parameters enabled, and proper boundary conditions. The two-fluid formulation with eps separation follows the project's conventions.

examples/2D_kelvin_helmholtz/case.py (1)

53-86: LGTM!

The Kelvin-Helmholtz configuration correctly establishes:

  • Velocity shear of 1.0 across the interface (±0.5)
  • Density ratio 2:1 between the center strip and background
  • Uniform pressure with periodic boundaries
  • Reference to hcid: 207 for the sinusoidal y-velocity perturbation
examples/2D_richtmyer_meshkov/case.py (1)

57-95: LGTM!

The Richtmyer-Meshkov configuration is well-structured with:

  • Appropriate pre/post-shock conditions matching shock jump relations
  • SF6 (γ ≈ 1.093) and air (γ = 1.4) fluid properties
  • Reference to hcid: 208 for the smoothed interface with sinusoidal perturbation
  • Long domain (16λ) suitable for observing vortex development

Comment on lines 143 to 157
case (208) ! Richtmeyer Meshkov Instability
lam = 1.0_wp
eps = 1.0e-6_wp
ei = 5.0_wp
! Smoothening function to smooth out sharp discontinuity in the interface
if(x_cc(i) <= 0.7 * lam) then
d = x_cc(i) - lam * (0.4_wp - 0.1_wp * sin(2.0_wp * pi * (y_cc(j) / lam + 0.25_wp)))
fsm = 0.5_wp * (1.0_wp + erf(d / (ei * sqrt(dx * dy))))
alpha_air = eps + (1.0_wp - 2.0_wp * eps) * fsm
alpha_sf6 = 1.0 - alpha_air
q_prim_vf(contxb)%sf(i, j, 0) = alpha_sf6 * 5.04
q_prim_vf(contxe)%sf(i, j, 0) = alpha_air * 1.0
q_prim_vf(advxb)%sf(i, j, 0) = alpha_sf6
q_prim_vf(advxe)%sf(i, j, 0) = alpha_air
end if
Copy link
Contributor

@coderabbitai coderabbitai bot Nov 25, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Case 208 overwrites the shared eps variable and uses inconsistent precision literals.

  1. Line 145 reassigns eps = 1.0e-6_wp, which shadows the module-level eps initialized at Line 12. If another case runs after case 208 in the same execution context, the modified eps value could cause unexpected behavior.

  2. Several literals lack the _wp suffix for working precision: 1.0 on lines 152, 154; 5.04 on line 153. Per coding guidelines, use wp for consistent precision.

Apply this diff to fix precision consistency:

     case (208) ! Richtmeyer Meshkov Instability
         lam = 1.0_wp
-        eps = 1.0e-6_wp
         ei = 5.0_wp
         ! Smoothening function to smooth out sharp discontinuity in the interface
-        if(x_cc(i) <= 0.7 * lam) then
+        if(x_cc(i) <= 0.7_wp * lam) then
                 d = x_cc(i) - lam * (0.4_wp - 0.1_wp * sin(2.0_wp * pi * (y_cc(j) / lam + 0.25_wp)))
                 fsm = 0.5_wp * (1.0_wp + erf(d / (ei * sqrt(dx * dy))))
                 alpha_air = eps + (1.0_wp - 2.0_wp * eps) * fsm
-                alpha_sf6 = 1.0 - alpha_air
-                q_prim_vf(contxb)%sf(i, j, 0) = alpha_sf6 * 5.04
-                q_prim_vf(contxe)%sf(i, j, 0) = alpha_air * 1.0
+                alpha_sf6 = 1.0_wp - alpha_air
+                q_prim_vf(contxb)%sf(i, j, 0) = alpha_sf6 * 5.04_wp
+                q_prim_vf(contxe)%sf(i, j, 0) = alpha_air * 1.0_wp
                 q_prim_vf(advxb)%sf(i, j, 0) = alpha_sf6
                 q_prim_vf(advxe)%sf(i, j, 0) = alpha_air 
         end if

Note: If you need a local epsilon distinct from the module-level eps, consider using a differently named variable (e.g., eps_local) to avoid shadowing.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In src/common/include/2dHardcodedIC.fpp around lines 143-157, avoid shadowing
the module-level eps by introducing a locally named variable (e.g., eps_local)
instead of reassigning eps; set eps_local = 1.0e-6_wp and replace uses of eps in
this case with eps_local. Also make all numeric literals use working precision
suffix _wp (change 1.0 -> 1.0_wp and 5.04 -> 5.04_wp and any other plain
literals in these lines), and ensure any derived computations (erf argument,
alpha assignments, q_prim_vf values) use the new eps_local and _wp-suffixed
literals for consistent precision.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Cowsreal The comments about missing _wp are worth fixing here. The others aren't important.

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link
Contributor

Choose a reason for hiding this comment

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

Code Implementation 🛠️

Implementation: In case (208), remove the reassignment of eps and ensure all numeric literals use the working precision suffix. Replace plain literals with _wp variants and adjust the comparison constant 0.7 to 0.7_wp. Keep using the existing eps variable without modifying its value.

Suggested change
case (208) ! Richtmeyer Meshkov Instability
lam = 1.0_wp
eps = 1.0e-6_wp
ei = 5.0_wp
! Smoothening function to smooth out sharp discontinuity in the interface
if(x_cc(i) <= 0.7 * lam) then
d = x_cc(i) - lam * (0.4_wp - 0.1_wp * sin(2.0_wp * pi * (y_cc(j) / lam + 0.25_wp)))
fsm = 0.5_wp * (1.0_wp + erf(d / (ei * sqrt(dx * dy))))
alpha_air = eps + (1.0_wp - 2.0_wp * eps) * fsm
alpha_sf6 = 1.0 - alpha_air
q_prim_vf(contxb)%sf(i, j, 0) = alpha_sf6 * 5.04
q_prim_vf(contxe)%sf(i, j, 0) = alpha_air * 1.0
q_prim_vf(advxb)%sf(i, j, 0) = alpha_sf6
q_prim_vf(advxe)%sf(i, j, 0) = alpha_air
end if
case (208) ! Richtmeyer Meshkov Instability
lam = 1.0_wp
ei = 5.0_wp
! Smoothening function to smooth out sharp discontinuity in the interface
if (x_cc(i) <= 0.7_wp * lam) then
d = x_cc(i) - lam * (0.4_wp - 0.1_wp * sin(2.0_wp * pi * (y_cc(j) / lam + 0.25_wp)))
fsm = 0.5_wp * (1.0_wp + erf(d / (ei * sqrt(dx * dy))))
alpha_air = eps + (1.0_wp - 2.0_wp * eps) * fsm
alpha_sf6 = 1.0_wp - alpha_air
q_prim_vf(contxb)%sf(i, j, 0) = alpha_sf6 * 5.04_wp
q_prim_vf(contxe)%sf(i, j, 0) = alpha_air * 1.0_wp
q_prim_vf(advxb)%sf(i, j, 0) = alpha_sf6
q_prim_vf(advxe)%sf(i, j, 0) = alpha_air
end if

See review comment here

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 13 files

Prompt for AI agents (all 2 issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="examples/2D_viscous_shock_tube/case.py">

<violation number="1" location="examples/2D_viscous_shock_tube/case.py:66">
Fluid 2’s density in the left patch is set to 120 instead of 1.2, so the supposedly light species becomes 100× heavier in that region and the initial state is incorrect.</violation>

<violation number="2" location="examples/2D_viscous_shock_tube/case.py:77">
Fluid 1’s density on the right patch uses 1.2 rather than 120, so the heavy species becomes 100× lighter in the transition zone and the initial condition is wrong.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 13 files

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 13 files

@wilfonba
Copy link
Contributor

@Cowsreal You need to add golden files for the new example cases by runing ./mfc.sh test -o <UIUD> --generate. That's why the tests failed.

@codeant-ai
Copy link

codeant-ai bot commented Nov 27, 2025

CodeAnt AI is running Incremental review

@codeant-ai codeant-ai bot added size:L This PR changes 100-499 lines, ignoring generated files and removed size:L This PR changes 100-499 lines, ignoring generated files labels Nov 27, 2025
@codeant-ai
Copy link

codeant-ai bot commented Nov 27, 2025

CodeAnt AI Incremental review completed.

@codecov
Copy link

codecov bot commented Nov 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 44.36%. Comparing base (11375f3) to head (ee67776).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1060   +/-   ##
=======================================
  Coverage   44.35%   44.36%           
=======================================
  Files          71       71           
  Lines       20587    20587           
  Branches     1993     1993           
=======================================
+ Hits         9132     9134    +2     
+ Misses      10310    10307    -3     
- Partials     1145     1146    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sbryngelson sbryngelson merged commit 76250b7 into MFlowCode:master Nov 27, 2025
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review effort 3/5 size:L This PR changes 100-499 lines, ignoring generated files

Development

Successfully merging this pull request may close these issues.

4 participants