Skip to content

Commit 15a4a9a

Browse files
sbryngelsonclaude
andcommitted
Add _is_numeric guards for domain bounds in check_patch_within_domain
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f89ab2e commit 15a4a9a

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

toolchain/mfc/case_validator.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2207,6 +2207,14 @@ def check_patch_within_domain(self): # pylint: disable=too-many-locals
22072207
z_beg = self.get('z_domain%beg') if self._is_numeric(p) and p > 0 else None
22082208
z_end = self.get('z_domain%end') if self._is_numeric(p) and p > 0 else None
22092209

2210+
# Pre-check domain bounds are numeric (could be analytical expressions)
2211+
x_bounds_ok = (x_beg is not None and x_end is not None
2212+
and self._is_numeric(x_beg) and self._is_numeric(x_end))
2213+
y_bounds_ok = (y_beg is not None and y_end is not None
2214+
and self._is_numeric(y_beg) and self._is_numeric(y_end))
2215+
z_bounds_ok = (z_beg is not None and z_end is not None
2216+
and self._is_numeric(z_beg) and self._is_numeric(z_end))
2217+
22102218
for i in range(1, num_patches + 1):
22112219
geometry = self.get(f'patch_icpp({i})%geometry')
22122220
if geometry is None:
@@ -2220,16 +2228,16 @@ def check_patch_within_domain(self): # pylint: disable=too-many-locals
22202228
xc = self.get(f'patch_icpp({i})%x_centroid')
22212229
lx = self.get(f'patch_icpp({i})%length_x')
22222230

2223-
has_x = (xc is not None and lx is not None
2224-
and x_beg is not None and x_end is not None)
2225-
if has_x and self._is_numeric(xc) and self._is_numeric(lx):
2231+
has_x = xc is not None and lx is not None
2232+
if (has_x and x_bounds_ok
2233+
and self._is_numeric(xc) and self._is_numeric(lx)):
22262234
patch_x_lo = xc - lx / 2.0
22272235
patch_x_hi = xc + lx / 2.0
22282236
self.prohibit(patch_x_hi < x_beg or patch_x_lo > x_end,
22292237
f"patch_icpp({i}): x-extent [{patch_x_lo}, {patch_x_hi}] "
22302238
f"is entirely outside domain [{x_beg}, {x_end}]")
22312239

2232-
if geometry in [3, 9] and y_beg is not None and y_end is not None:
2240+
if geometry in [3, 9] and y_bounds_ok:
22332241
yc = self.get(f'patch_icpp({i})%y_centroid')
22342242
ly = self.get(f'patch_icpp({i})%length_y')
22352243
if (yc is not None and ly is not None
@@ -2240,7 +2248,7 @@ def check_patch_within_domain(self): # pylint: disable=too-many-locals
22402248
f"patch_icpp({i}): y-extent [{patch_y_lo}, {patch_y_hi}] "
22412249
f"is entirely outside domain [{y_beg}, {y_end}]")
22422250

2243-
if geometry == 9 and z_beg is not None and z_end is not None:
2251+
if geometry == 9 and z_bounds_ok:
22442252
zc = self.get(f'patch_icpp({i})%z_centroid')
22452253
lz = self.get(f'patch_icpp({i})%length_z')
22462254
if (zc is not None and lz is not None

0 commit comments

Comments
 (0)