Skip to content

Add WENO/MUSCL parameter guards with corresponding recon_type#1391

Open
Cowsreal wants to merge 15 commits intoMFlowCode:masterfrom
Cowsreal:minorChanges
Open

Add WENO/MUSCL parameter guards with corresponding recon_type#1391
Cowsreal wants to merge 15 commits intoMFlowCode:masterfrom
Cowsreal:minorChanges

Conversation

@Cowsreal
Copy link
Copy Markdown
Contributor

@Cowsreal Cowsreal commented May 1, 2026

Description

Add various guards for cases running MUSCL/WENO reconstruction with their corresponding recon_type value. Previously, this wasn't checked very tightly, and setting recon_type=2 while having WENO parameters such as weno_order, weno_eps, etc set. This would be overrided by the recon_type parameter and result in a MUSCL order 0 run.

Type of change

  • Bug fix

AI code reviews

Reviews are not triggered automatically. To request a review, comment on the PR:

  • @coderabbitai review — incremental review (new changes only)
  • @coderabbitai full review — full review from scratch
  • /review — Qodo review
  • /improve — Qodo code suggestions
  • @claude full review — Claude full review (also triggers on PR open/reopen/ready)
  • Add label claude-full-review — Claude full review via label

@qodo-code-review
Copy link
Copy Markdown
Contributor

qodo-code-review Bot commented May 1, 2026

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0)

Grey Divider


Remediation recommended

1. Overblocks viscous flags 🐞 Bug ≡ Correctness
Description
check_muscl() now rejects weno_avg and weno_Re_flux when recon_type=2, but the solver’s viscous
routines use these flags independent of recon_type (they still act on MUSCL-reconstructed boundary
values). This changes toolchain behavior by blocking configurations the solver can run with, and the
error message implies an incompatibility that the implementation does not enforce.
Code

toolchain/mfc/case_validator.py[R363-366]

+        weno_log_params = ["mapped_weno", "wenoz", "teno", "mp_weno", "weno_avg", "null_weights", "weno_Re_flux"]
+        for param in weno_log_params:
+            self.prohibit(self.get(param) == "T", f"recon_type = 2 (MUSCL) is not compatible with {param} = T")
+
Evidence
The new validator logic prohibits weno_avg and weno_Re_flux for MUSCL. In the solver, viscous
reconstruction explicitly branches on recon_type to call either MUSCL or WENO reconstruction, and
then applies weno_Re_flux logic without any recon_type guard—meaning the flag is consumed regardless
of reconstruction type. Similarly, weno_avg feeds wa_flg globally and is used in viscous gradient
computations regardless of recon_type.

toolchain/mfc/case_validator.py[363-373]
src/simulation/m_viscous.fpp[851-899]
src/simulation/m_viscous.fpp[900-943]
src/simulation/m_global_parameters.fpp[1153-1156]
src/simulation/m_viscous.fpp[1074-1119]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`CaseValidator.check_muscl()` currently prohibits `weno_avg` and `weno_Re_flux` when `recon_type = 2 (MUSCL)`. In the solver implementation, these flags are consumed in viscous computations without being guarded by `recon_type`, and viscous reconstruction already follows `recon_type` (WENO vs MUSCL).
This makes the toolchain validator stricter than the solver behavior and can reject configurations that the solver can execute.
### Issue Context
- `weno_Re_flux` is checked and used in the viscous code path independent of `recon_type`.
- `weno_avg` influences `wa_flg` and is used in viscous gradient calculations.
### Fix Focus Areas
- Remove `weno_avg` and `weno_Re_flux` from the MUSCL-incompatible list, or gate them on `viscous` instead of `recon_type`.
- Alternatively, if these flags are intended to be WENO-only, add corresponding `recon_type` guards in the solver and update docs accordingly.
- toolchain/mfc/case_validator.py[363-373]
- src/simulation/m_viscous.fpp[851-943]
- src/simulation/m_global_parameters.fpp[1153-1156]
- src/simulation/m_viscous.fpp[1074-1119]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Previous review results

Review updated until commit 9b2af1d

Results up to commit 9b2af1d


🐞 Bugs (1) 📘 Rule violations (0)


Remediation recommended
1. Overblocks viscous flags 🐞 Bug ≡ Correctness
Description
check_muscl() now rejects weno_avg and weno_Re_flux when recon_type=2, but the solver’s viscous
routines use these flags independent of recon_type (they still act on MUSCL-reconstructed boundary
values). This changes toolchain behavior by blocking configurations the solver can run with, and the
error message implies an incompatibility that the implementation does not enforce.
Code

toolchain/mfc/case_validator.py[R363-366]

+        weno_log_params = ["mapped_weno", "wenoz", "teno", "mp_weno", "weno_avg", "null_weights", "weno_Re_flux"]
+        for param in weno_log_params:
+            self.prohibit(self.get(param) == "T", f"recon_type = 2 (MUSCL) is not compatible with {param} = T")
+
Evidence
The new validator logic prohibits weno_avg and weno_Re_flux for MUSCL. In the solver, viscous
reconstruction explicitly branches on recon_type to call either MUSCL or WENO reconstruction, and
then applies weno_Re_flux logic without any recon_type guard—meaning the flag is consumed regardless
of reconstruction type. Similarly, weno_avg feeds wa_flg globally and is used in viscous gradient
computations regardless of recon_type.

toolchain/mfc/case_validator.py[363-373]
src/simulation/m_viscous.fpp[851-899]
src/simulation/m_viscous.fpp[900-943]
src/simulation/m_global_parameters.fpp[1153-1156]
src/simulation/m_viscous.fpp[1074-1119]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`CaseValidator.check_muscl()` currently prohibits `weno_avg` and `weno_Re_flux` when `recon_type = 2 (MUSCL)`. In the solver implementation, these flags are consumed in viscous computations without being guarded by `recon_type`, and viscous reconstruction already follows `recon_type` (WENO vs MUSCL).

This makes the toolchain validator stricter than the solver behavior and can reject configurations that the solver can execute.

### Issue Context
- `weno_Re_flux` is checked and used in the viscous code path independent of `recon_type`.
- `weno_avg` influences `wa_flg` and is used in viscous gradient calculations.

### Fix Focus Areas
- Remove `weno_avg` and `weno_Re_flux` from the MUSCL-incompatible list, or gate them on `viscous` instead of `recon_type`.
- Alternatively, if these flags are intended to be WENO-only, add corresponding `recon_type` guards in the solver and update docs accordingly.

- toolchain/mfc/case_validator.py[363-373]
- src/simulation/m_viscous.fpp[851-943]
- src/simulation/m_global_parameters.fpp[1153-1156]
- src/simulation/m_viscous.fpp[1074-1119]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Qodo Logo

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 1, 2026

📝 Walkthrough

Walkthrough

The changes implement reconstruction-mode-specific parameter validation and filtering across the codebase. The validator now enforces mutual exclusivity between MUSCL and WENO reconstruction modes: MUSCL parameters are disallowed when recon_type=2, and WENO parameters are disallowed when recon_type=1. Simulation-stage validation includes early returns based on reconstruction type to prevent mode-specific checks from running inappropriately. Test case generation has been updated to propagate incompatible parameters as None values, with filtering logic ensuring they are removed during initialization, creating consistent mutual exclusivity throughout the validation pipeline.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description is incomplete: the bug fix checkbox is unchecked despite the change being a bug fix, the Testing and Checklist sections are empty, and documentation updates are not specified. Check the bug fix box, describe testing approach, confirm test additions/documentation updates, and fill out the complete template sections.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add WENO/MUSCL parameter guards with corresponding recon_type' directly summarizes the main change: adding validation guards to ensure WENO/MUSCL parameters match the chosen reconstruction type.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

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

Copy link
Copy Markdown
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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 614490c0-438f-46c6-8a88-5bb09f2183aa

📥 Commits

Reviewing files that changed from the base of the PR and between a314b0b and 9b2af1d.

📒 Files selected for processing (3)
  • toolchain/mfc/case_validator.py
  • toolchain/mfc/test/case.py
  • toolchain/mfc/test/cases.py

Comment on lines +734 to +737
recon_type = self.get("recon_type", 1)
# WENO_TYPE = 1
if recon_type != 1:
return
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Validate recon_type domain before mode-specific early returns.

Line 736 and Line 775 return early for non-target modes, but there is no explicit guard that recon_type must be 1 or 2. Values like recon_type=3 can bypass both WENO and MUSCL validation paths silently.

Suggested fix
 def check_weno(self):
     """Checks constraints regarding WENO order"""
     recon_type = self.get("recon_type", 1)
+    self.prohibit(recon_type not in [1, 2], "recon_type must be 1 (WENO) or 2 (MUSCL)")

     # WENO_TYPE = 1
     if recon_type != 1:
         return
@@
 def check_muscl(self):
     """Check constraints regarding MUSCL order"""
     recon_type = self.get("recon_type", 1)
+    self.prohibit(recon_type not in [1, 2], "recon_type must be 1 (WENO) or 2 (MUSCL)")
     int_comp = self.get("int_comp", "F") == "T"

Also applies to: 773-776

@qodo-code-review
Copy link
Copy Markdown
Contributor

qodo-code-review Bot commented May 1, 2026

Persistent review updated to latest commit 9b2af1d

@codecov
Copy link
Copy Markdown

codecov Bot commented May 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.76%. Comparing base (a314b0b) to head (8c10099).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1391   +/-   ##
=======================================
  Coverage   64.75%   64.76%           
=======================================
  Files          71       71           
  Lines       18716    18716           
  Branches     1548     1548           
=======================================
+ Hits        12120    12121    +1     
+ Misses       5641     5640    -1     
  Partials      955      955           

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant