Skip to content

Commit b0129f7

Browse files
sbryngelsonclaude
andcommitted
Fix restart roundtrip, grid stretching, and hypoelasticity test failures
Restart roundtrip: Phase 2 now runs only SIMULATION (skips pre_process) since it reads grid+IC directly from p_all/p0/<mid_step>/. D/ is preserved across phases and intermediate step files are cleaned up so the final output matches a straight run. Grid stretching: Enlarge patches to cover the cosh-stretched domain (which expands beyond [0,1] to ~[0,1.39] with a=2, x_a=0.3, x_b=0.7). Without this, cells beyond the original bounds are uninitialized. Hypoelasticity MPI: Add dt=1e-06 matching other 3D hypoelasticity tests (default dt=0.0005 exceeds CFL for the high speed of sound ~88). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5192054 commit b0129f7

10 files changed

Lines changed: 203 additions & 12 deletions

File tree

tests/0090B316/golden.txt

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/05D092C5/golden.txt

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/0DDE8A87/golden.txt

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/1A379909/golden.txt

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/59C3F366/golden.txt

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/75D7CC39/golden.txt

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/B49877F3/golden.txt

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/C3A4DBAE/golden.txt

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

toolchain/mfc/test/case.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from .. import case, common
66
from ..state import ARG
77
from ..run import input
8-
from ..build import MFCTarget, get_target
8+
from ..build import MFCTarget, SIMULATION, get_target
99

1010
Tend = 0.25
1111
Nt = 50
@@ -158,18 +158,26 @@ def run_restart(self, targets, gpus):
158158
if result1.returncode != 0:
159159
return result1
160160

161-
# Delete output data but keep restart_data/
161+
# Keep D/ (has steps 0 and mid_step) and p_all/ (restart data).
162162
dirpath = self.get_dirpath()
163-
common.delete_directory(os.path.join(dirpath, "D"))
164-
common.delete_directory(os.path.join(dirpath, "p_all"))
165163
common.delete_directory(os.path.join(dirpath, "silo_hdf5"))
166164

167-
# Phase 2: Restart from midpoint
168-
self.params = {**orig, 'old_ic': 'T', 'old_grid': 'T',
169-
't_step_start': mid_step,
165+
# Phase 2: Restart simulation from midpoint. Only the simulation
166+
# is run — it reads grid + IC directly from p_all/p0/<mid_step>/.
167+
self.params = {**orig, 't_step_start': mid_step,
170168
't_step_save': orig['t_step_stop'] - mid_step}
171169
self.create_directory()
172-
return self.run(targets, gpus)
170+
result2 = self.run([SIMULATION], gpus)
171+
172+
# Remove intermediate step files from D/ so only step 0 and
173+
# t_step_stop remain, matching the straight run's output.
174+
if result2.returncode == 0:
175+
d_dir = os.path.join(dirpath, "D")
176+
mid_tag = f"{mid_step:06d}"
177+
for f in glob.glob(os.path.join(d_dir, f"*.{mid_tag}.dat")):
178+
os.remove(f)
179+
180+
return result2
173181
finally:
174182
self.params = orig
175183
self.create_directory()

toolchain/mfc/test/cases.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,6 +1213,7 @@ def mpi_consistency_tests():
12131213

12141214
# Hypoelasticity with 2 MPI ranks
12151215
stack.push('MPI Consistency -> 3D -> Hypoelasticity', {**base_3d,
1216+
'dt': 1e-06,
12161217
'hypoelasticity': 'T', 'riemann_solver': 1, 'fd_order': 4,
12171218
'fluid_pp(1)%gamma': 0.3, 'fluid_pp(1)%pi_inf': 7.8E+05,
12181219
'fluid_pp(1)%G': 1.E+05,
@@ -1321,11 +1322,25 @@ def kernel_golden_tests():
13211322
'patch_icpp(3)%z_centroid': 0.9, 'patch_icpp(3)%length_z': 0.2,
13221323
})
13231324

1324-
# 3D grid stretching in all directions
1325+
# 3D grid stretching in all directions.
1326+
# The cosh-based stretching expands the domain beyond the original
1327+
# bounds (e.g., [0,1] → ~[0,1.39] with a=2, x_a=0.3, x_b=0.7).
1328+
# Patches must be enlarged to cover the stretched domain, otherwise
1329+
# cells beyond the original bounds are uninitialized (zero density),
1330+
# causing ICFL blowup.
13251331
stack.push('Kernel -> 3D -> Grid Stretching', {**base_3d,
1326-
'stretch_x': 'T', 'a_x': 2.0, 'x_a': -0.3, 'x_b': 0.3, 'loops_x': 1,
1327-
'stretch_y': 'T', 'a_y': 2.0, 'y_a': -0.3, 'y_b': 0.3, 'loops_y': 1,
1328-
'stretch_z': 'T', 'a_z': 2.0, 'z_a': -0.3, 'z_b': 0.3, 'loops_z': 1,
1332+
'stretch_x': 'T', 'a_x': 2.0, 'x_a': 0.3, 'x_b': 0.7, 'loops_x': 1,
1333+
'stretch_y': 'T', 'a_y': 2.0, 'y_a': 0.3, 'y_b': 0.7, 'loops_y': 1,
1334+
'stretch_z': 'T', 'a_z': 2.0, 'z_a': 0.3, 'z_b': 0.7, 'loops_z': 1,
1335+
# Enlarge x/y coverage for all patches (stretched domain reaches ~1.39)
1336+
'patch_icpp(1)%x_centroid': 0.75, 'patch_icpp(1)%length_x': 1.5,
1337+
'patch_icpp(1)%y_centroid': 0.75, 'patch_icpp(1)%length_y': 1.5,
1338+
'patch_icpp(2)%x_centroid': 0.75, 'patch_icpp(2)%length_x': 1.5,
1339+
'patch_icpp(2)%y_centroid': 0.75, 'patch_icpp(2)%length_y': 1.5,
1340+
'patch_icpp(3)%x_centroid': 0.75, 'patch_icpp(3)%length_x': 1.5,
1341+
'patch_icpp(3)%y_centroid': 0.75, 'patch_icpp(3)%length_y': 1.5,
1342+
# Extend last z-patch to cover stretched z range
1343+
'patch_icpp(3)%z_centroid': 1.15, 'patch_icpp(3)%length_z': 0.7,
13291344
})
13301345
cases.append(define_case_d(stack, '', {}))
13311346
stack.pop()

0 commit comments

Comments
 (0)