Skip to content

Commit 1033ff6

Browse files
authored
Add WENO/MUSCL parameter guards with corresponding recon_type (#1391)
1 parent 02eb4ec commit 1033ff6

3 files changed

Lines changed: 39 additions & 2 deletions

File tree

toolchain/mfc/case_validator.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,11 +328,15 @@ def check_igr(self):
328328
def check_weno(self):
329329
"""Checks constraints regarding WENO order"""
330330
recon_type = self.get("recon_type", 1)
331+
self.prohibit(recon_type not in [1, 2], "recon_type must be 1 (WENO) or 2 (MUSCL)")
331332

332333
# WENO_TYPE = 1
333334
if recon_type != 1:
334335
return
335336

337+
for param in ["muscl_order", "muscl_lim"]:
338+
self.prohibit(self.is_set(param), f"recon_type = 1 (WENO) is not compatible with {param}")
339+
336340
weno_order = self.get("weno_order")
337341
m = self.get("m", 0)
338342
n = self.get("n", 0)
@@ -349,6 +353,8 @@ def check_weno(self):
349353
def check_muscl(self):
350354
"""Check constraints regarding MUSCL order"""
351355
recon_type = self.get("recon_type", 1)
356+
self.prohibit(recon_type not in [1, 2], "recon_type must be 1 (WENO) or 2 (MUSCL)")
357+
352358
int_comp = self.get("int_comp", "F") == "T"
353359

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

366+
weno_log_params = ["mapped_weno", "wenoz", "teno", "mp_weno", "weno_avg", "null_weights", "weno_Re_flux"]
367+
for param in weno_log_params:
368+
self.prohibit(self.get(param) == "T", f"recon_type = 2 (MUSCL) is not compatible with {param} = T")
369+
370+
weno_numeric_params = ["wenoz_q", "teno_CT", "weno_eps"]
371+
for param in weno_numeric_params:
372+
self.prohibit(self.is_set(param), f"recon_type = 2 (MUSCL) is not compatible with {param}")
373+
374+
weno_order = self.get("weno_order")
375+
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}")
376+
360377
muscl_order = self.get("muscl_order")
361378
m = self.get("m", 0)
362379
n = self.get("n", 0)
@@ -717,6 +734,13 @@ def check_finite_difference(self):
717734

718735
def check_weno_simulation(self):
719736
"""Checks WENO-specific constraints for simulation"""
737+
recon_type = self.get("recon_type", 1)
738+
self.prohibit(recon_type not in [1, 2], "recon_type must be 1 (WENO) or 2 (MUSCL)")
739+
740+
# WENO_TYPE = 1
741+
if recon_type != 1:
742+
return
743+
720744
weno_order = self.get("weno_order")
721745
weno_eps = self.get("weno_eps")
722746
wenoz = self.get("wenoz", "F") == "T"
@@ -751,6 +775,13 @@ def check_weno_simulation(self):
751775

752776
def check_muscl_simulation(self):
753777
"""Checks MUSCL-specific constraints for simulation"""
778+
recon_type = self.get("recon_type", 1)
779+
self.prohibit(recon_type not in [1, 2], "recon_type must be 1 (WENO) or 2 (MUSCL)")
780+
781+
# MUSCL_TYPE = 2
782+
if recon_type != 2:
783+
return
784+
754785
muscl_order = self.get("muscl_order")
755786
muscl_lim = self.get("muscl_lim")
756787
muscl_eps = self.get("muscl_eps")

toolchain/mfc/test/case.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ def __init__(self, trace: str, mods: dict, ppn: int = None, override_tol: float
161161
self.ppn = ppn or 1
162162
self.override_tol = override_tol
163163
self.restart_check = restart_check
164-
super().__init__({**BASE_CFG.copy(), **mods})
164+
merge = {**BASE_CFG.copy(), **mods}
165+
merge = {key: val for key, val in merge.items() if val is not None}
166+
super().__init__(merge)
165167

166168
def run(self, targets: List[Union[str, MFCTarget]], gpus: Set[int]) -> subprocess.CompletedProcess:
167169
if gpus is not None and len(gpus) != 0:

toolchain/mfc/test/cases.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def alter_igr():
300300

301301
def alter_muscl():
302302
for muscl_order in [1, 2]:
303-
stack.push(f"muscl_order={muscl_order}", {"muscl_order": muscl_order, "recon_type": 2, "weno_order": 0})
303+
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})
304304

305305
if muscl_order == 1:
306306
for int_comp in ["T", "F"]:
@@ -1562,6 +1562,10 @@ def modify_example_case(case: dict):
15621562
case["t_step_stop"] = 50
15631563
case["t_step_save"] = 50
15641564

1565+
if case.get("recon_type") == 2:
1566+
for k in ("weno_order", "weno_eps", "wenoz_q", "teno_CT"):
1567+
case[k] = None
1568+
15651569
caseSize = case["m"] * max(case["n"], 1) * max(case["p"], 1)
15661570
if caseSize > 25 * 25:
15671571
if case["n"] == 0 and case["p"] == 0:

0 commit comments

Comments
 (0)