Skip to content

Commit

Permalink
allow set_checkpointing from sequential or parallel domain
Browse files Browse the repository at this point in the history
  • Loading branch information
stoiveroberts committed Dec 20, 2022
1 parent 2f8d0d2 commit e9cc8e2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
13 changes: 9 additions & 4 deletions anuga/shallow_water/shallow_water_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -1294,11 +1294,16 @@ def set_checkpointing(self, checkpoint= True, checkpoint_dir = 'CHECKPOINTS', ch


if checkpoint:
# create checkpoint directory if necessary
if not os.path.exists(checkpoint_dir):
os.mkdir(checkpoint_dir)

assert os.path.exists(checkpoint_dir)
from anuga import myid
# On processor 0 create checkpoint directory if necessary
if myid == 0:
if True:
if not os.path.exists(checkpoint_dir):
os.mkdir(checkpoint_dir)

assert os.path.exists(checkpoint_dir)

self.checkpoint_dir = checkpoint_dir
if checkpoint_time is not None:
#import time
Expand Down
22 changes: 10 additions & 12 deletions validation_tests/case_studies/towradgi/run_towradgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,16 @@ def read_polygon_list(poly_list):
domain = distribute(domain, verbose=verbose)

barrier()

# -----------------------------------------------------------------------------
# Turn on checkpointing every 5 sec (just for testing, more reasonable to
# set to say 15 minutes = 15*60 sec)
# Only set this on process 0 ie within a if myid == 0: structure
# -----------------------------------------------------------------------------
if useCheckpointing:
domain.set_checkpointing(
checkpoint_time=checkpoint_time, checkpoint_dir=checkpoint_dir)


domain.quantities_to_be_stored = {'elevation': 2,
'friction': 1,
Expand Down Expand Up @@ -892,23 +902,11 @@ def read_polygon_list(poly_list):
func(t)[0], 0.0, 0.0])

domain.set_boundary({'west': Bd, 'south': Bd, 'north': Bd, 'east': Bw})




if myid == 0:
print('Start Evolve')



# -----------------------------------------------------------------------------
# Turn on checkpointing every 5 sec (just for testing, more reasonable to
# set to say 15 minutes = 15*60 sec)
# Only set this on process 0 ie within a if myid == 0: structure
# -----------------------------------------------------------------------------
if useCheckpointing:
domain.set_checkpointing(
checkpoint_time=checkpoint_time, checkpoint_dir=checkpoint_dir)

# ------------------------------------------------------------------------------
# EVOLVE SYSTEM THROUGH TIME
Expand Down

0 comments on commit e9cc8e2

Please sign in to comment.