Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions toolchain/mfc/case_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,15 @@ def check_igr(self):
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

for param in ["muscl_order", "muscl_lim"]:
self.prohibit(self.is_set(param), f"recon_type = 1 (WENO) is not compatible with {param}")

weno_order = self.get("weno_order")
m = self.get("m", 0)
n = self.get("n", 0)
Expand All @@ -349,6 +353,8 @@ def check_weno(self):
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"

self.prohibit(int_comp and recon_type != 2, "int_comp (THINC interface compression) requires recon_type = 2 (MUSCL)")
Expand All @@ -357,6 +363,17 @@ def check_muscl(self):
if recon_type != 2:
return

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")

weno_numeric_params = ["wenoz_q", "teno_CT", "weno_eps"]
for param in weno_numeric_params:
self.prohibit(self.is_set(param), f"recon_type = 2 (MUSCL) is not compatible with {param}")

weno_order = self.get("weno_order")
self.prohibit(weno_order is not None and weno_order != 0, f"recon_type = 2 (MUSCL) requires weno_order unset or 0, but got {weno_order}")

muscl_order = self.get("muscl_order")
m = self.get("m", 0)
n = self.get("n", 0)
Expand Down Expand Up @@ -717,6 +734,13 @@ def check_finite_difference(self):

def check_weno_simulation(self):
"""Checks WENO-specific constraints for simulation"""
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
Comment on lines +737 to +742
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


weno_order = self.get("weno_order")
weno_eps = self.get("weno_eps")
wenoz = self.get("wenoz", "F") == "T"
Expand Down Expand Up @@ -751,6 +775,13 @@ def check_weno_simulation(self):

def check_muscl_simulation(self):
"""Checks MUSCL-specific constraints for simulation"""
recon_type = self.get("recon_type", 1)
self.prohibit(recon_type not in [1, 2], "recon_type must be 1 (WENO) or 2 (MUSCL)")

# MUSCL_TYPE = 2
if recon_type != 2:
return

muscl_order = self.get("muscl_order")
muscl_lim = self.get("muscl_lim")

Expand Down
4 changes: 3 additions & 1 deletion toolchain/mfc/test/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ def __init__(self, trace: str, mods: dict, ppn: int = None, override_tol: float
self.ppn = ppn or 1
self.override_tol = override_tol
self.restart_check = restart_check
super().__init__({**BASE_CFG.copy(), **mods})
merge = {**BASE_CFG.copy(), **mods}
merge = {key: val for key, val in merge.items() if val is not None}
super().__init__(merge)

def run(self, targets: List[Union[str, MFCTarget]], gpus: Set[int]) -> subprocess.CompletedProcess:
if gpus is not None and len(gpus) != 0:
Expand Down
6 changes: 5 additions & 1 deletion toolchain/mfc/test/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def alter_igr():

def alter_muscl():
for muscl_order in [1, 2]:
stack.push(f"muscl_order={muscl_order}", {"muscl_order": muscl_order, "recon_type": 2, "weno_order": 0})
stack.push(f"muscl_order={muscl_order}", {"muscl_order": muscl_order, "recon_type": 2, "weno_order": 0, "weno_eps": None, "wenoz_q": None, "teno_CT": None})

if muscl_order == 1:
for int_comp in ["T", "F"]:
Expand Down Expand Up @@ -1558,6 +1558,10 @@ def modify_example_case(case: dict):
case["t_step_stop"] = 50
case["t_step_save"] = 50

if case.get("recon_type") == 2:
for k in ("weno_order", "weno_eps", "wenoz_q", "teno_CT"):
case[k] = None

caseSize = case["m"] * max(case["n"], 1) * max(case["p"], 1)
if caseSize > 25 * 25:
if case["n"] == 0 and case["p"] == 0:
Expand Down
Loading