@@ -16,6 +16,9 @@ class MFCInputFile:
1616 case_dirpath : str
1717 case_dict : dict
1818
19+ def __get_ndims (self ) -> int :
20+ return 1 + min (int (self .case_dict .get ("n" , 0 )), 1 ) + min (int (self .case_dict .get ("p" , 0 )), 1 )
21+
1922 def __is_ic_analytical (self , key : str , val : str ) -> bool :
2023 if common .is_number (val ) or not isinstance (val , str ):
2124 return False
@@ -47,7 +50,6 @@ def __generate_inp(self, target_name: str) -> None:
4750 dict_str += f"{ key } = { val } \n "
4851 else :
4952 dict_str += f"{ key } = '{ val } '\n "
50-
5153 continue
5254 else :
5355 ignored .append (key )
@@ -86,21 +88,12 @@ def __generate_pre_fpp(self) -> None:
8688 cons .print (f"Generating [magenta]pre_process/include/case.fpp[/magenta]." )
8789 cons .indent ()
8890
89- DIMS = {
90- 1 : {'ptypes' : [1 , 15 , 16 ], 'sf_idx' : 'i, 0, 0' },
91- 2 : {'ptypes' : [2 , 3 , 4 , 5 , 6 , 7 , 17 , 18 ], 'sf_idx' : 'i, j, 0' },
92- 3 : {'ptypes' : [8 , 9 , 10 , 11 , 12 , 13 , 14 , 19 ], 'sf_idx' : 'i, j, k' }
93- }
94-
95- def get_patchtype_ndims (ptype : int ) -> int :
96- for ndim , info in DIMS .items ():
97- if ptype in info ['ptypes' ]:
98- return ndim
99-
100- raise common .MFCException (f"Patch of type { ptype } cannot be analytically defined." )
101-
102- PTYPES = DIMS [1 ]['ptypes' ] + DIMS [2 ]['ptypes' ] + DIMS [3 ]['ptypes' ]
103-
91+ DATA = {
92+ 1 : {'ptypes' : [1 , 15 , 16 ], 'sf_idx' : 'i, 0, 0' },
93+ 2 : {'ptypes' : [2 , 3 , 4 , 5 , 6 , 7 , 17 , 18 , 21 ], 'sf_idx' : 'i, j, 0' },
94+ 3 : {'ptypes' : [8 , 9 , 10 , 11 , 12 , 13 , 14 , 19 , 21 ], 'sf_idx' : 'i, j, k' }
95+ }[self .__get_ndims ()]
96+
10497 patches = {}
10598
10699 for key , val in self .case_dict .items ():
@@ -119,7 +112,7 @@ def get_patchtype_ndims(ptype: int) -> int:
119112 for pid , items in patches .items ():
120113 ptype = self .case_dict [f"patch_icpp({ pid } )%geometry" ]
121114
122- if ptype not in PTYPES :
115+ if ptype not in DATA [ 'ptypes' ] :
123116 raise common .MFCException (f"Patch #{ pid } of type { ptype } cannot be analytically defined." )
124117
125118 def rhs_replace (match ):
@@ -146,10 +139,9 @@ def rhs_replace(match):
146139 if idx != 0 :
147140 qpvf_idx_offset = f" + { idx } "
148141
149- ndims = get_patchtype_ndims (ptype )
150- sf_idx = DIMS [ndims ]['sf_idx' ]
142+ sf_idx = DATA ['sf_idx' ]
151143
152- cons .print (f"[yellow]INFO:[/yellow] { ndims } D Analytical Patch #{ pid } : Code generation for [magenta]{ varname } [/magenta]..." )
144+ cons .print (f"[yellow]INFO:[/yellow] { self . __get_ndims () } D Analytical Patch #{ pid } : Code generation for [magenta]{ varname } [/magenta]..." )
153145
154146 lhs = f"q_prim_vf({ qpvf_idx_var } { qpvf_idx_offset } )%sf({ sf_idx } )"
155147 rhs = re .sub (r"[a-zA-Z]+" , rhs_replace , expr )
0 commit comments