From 37dd0f44ff2bbb8217c1468919fca27fe937c95e Mon Sep 17 00:00:00 2001 From: Cameron <71239694+AiredaleDev@users.noreply.github.com> Date: Wed, 19 Jun 2024 16:36:53 -0400 Subject: [PATCH] Hotfix: Allow certain case parameters to be analytic expressions again (#473) --- CMakeLists.txt | 1 + toolchain/mfc/case.py | 2 ++ toolchain/mfc/run/case_dicts.py | 23 +++++++++++++++++------ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 66db9b7b9..5b72a285d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -465,6 +465,7 @@ function(MFC_SETUP_TARGET) PRIVATE -gpu=unified ) endif() + if (CMAKE_BUILD_TYPE STREQUAL "Debug") target_compile_options(${ARGS_TARGET} PRIVATE -gpu=autocompare,debug diff --git a/toolchain/mfc/case.py b/toolchain/mfc/case.py index f90775cd0..3117af577 100644 --- a/toolchain/mfc/case.py +++ b/toolchain/mfc/case.py @@ -83,6 +83,8 @@ def __get_ndims(self) -> int: return 1 + min(int(self.params.get("n", 0)), 1) + min(int(self.params.get("p", 0)), 1) def __is_ic_analytical(self, key: str, val: str) -> bool: + '''Is this initial condition analytical? + More precisely, is this an arbitrary expression or a string representing a number?''' if common.is_number(val) or not isinstance(val, str): return False diff --git a/toolchain/mfc/run/case_dicts.py b/toolchain/mfc/run/case_dicts.py index 80c77f3e0..ad5f2875b 100644 --- a/toolchain/mfc/run/case_dicts.py +++ b/toolchain/mfc/run/case_dicts.py @@ -1,5 +1,4 @@ from enum import Enum - from ..state import ARG class ParamType(Enum): @@ -8,6 +7,16 @@ class ParamType(Enum): LOG = {"enum": ["T", "F"]} STR = {"type": "string"} + _ANALYTIC_INT = {"type": ["integer", "string"]} + _ANALYTIC_REAL = {"type": ["number", "string"]} + + def analytic(self): + if self == self.INT: + return self._ANALYTIC_INT + if self == self.REAL: + return self._ANALYTIC_REAL + return self.STR + COMMON = { 'hypoelasticity': ParamType.LOG, 'cyl_coord': ParamType.LOG, @@ -105,9 +114,10 @@ class ParamType(Enum): PRE_PROCESS[f"patch_icpp({p_id})%{attribute}"] = ty for real_attr in ["radius", "radii", "epsilon", "beta", "normal", "alpha_rho", - "smooth_coeff", "rho", "vel", "pres", "alpha", "gamma", + "smooth_coeff", "rho", "vel", "alpha", "gamma", "pi_inf", "r0", "v0", "p0", "m0", "cv", "qv", "qvp", "cf_val"]: PRE_PROCESS[f"patch_icpp({p_id})%{real_attr}"] = ParamType.REAL + PRE_PROCESS[f"patch_icpp({p_id})%pres"] = ParamType.REAL.analytic() # (cameron): This parameter has since been removed. # for i in range(100): @@ -127,15 +137,16 @@ class ParamType(Enum): PRE_PROCESS[f'patch_icpp({p_id})%{cmp}_centroid'] = ParamType.REAL PRE_PROCESS[f'patch_icpp({p_id})%length_{cmp}'] = ParamType.REAL - for append in ["radii", "normal", "vel"]: + for append in ["radii", "normal"]: PRE_PROCESS[f'patch_icpp({p_id})%{append}({cmp_id})'] = ParamType.REAL + PRE_PROCESS[f'patch_icpp({p_id})%vel({cmp_id})'] = ParamType.REAL.analytic() for arho_id in range(1, 10+1): - PRE_PROCESS[f'patch_icpp({p_id})%alpha({arho_id})'] = ParamType.REAL - PRE_PROCESS[f'patch_icpp({p_id})%alpha_rho({arho_id})'] = ParamType.REAL + PRE_PROCESS[f'patch_icpp({p_id})%alpha({arho_id})'] = ParamType.REAL.analytic() + PRE_PROCESS[f'patch_icpp({p_id})%alpha_rho({arho_id})'] = ParamType.REAL.analytic() for taue_id in range(1, 6+1): - PRE_PROCESS[f'patch_icpp({p_id})%tau_e({taue_id})'] = ParamType.REAL + PRE_PROCESS[f'patch_icpp({p_id})%tau_e({taue_id})'] = ParamType.REAL.analytic() if p_id >= 2: PRE_PROCESS[f'patch_icpp({p_id})%alter_patch'] = ParamType.LOG