def __init__(self, argument_adder=None, from_commandline=True, setup_boundaries=None, setup_domain=None, setup_rainfall=None, setup_structures=None, **kwargs): args = parse_args_and_parameters(argument_adder, from_commandline, **kwargs) self.verbose = args.verbose self.outname = args.outname self.partition_dir = args.partition_dir self.checkpoint_dir = args.checkpoint_dir self.alg = args.alg self.args = args self.checkpoint = args.checkpoint self.checkpoint_time = args.checkpoint_time self.setup_boundaries = setup_boundaries self.setup_domain = setup_domain self.setup_rainfall = setup_rainfall self.setup_structures = setup_structures if self.checkpoint: # try to read in from checkpoint file from anuga import load_checkpoint_file try: if myid == 0 and self.verbose: print 'TRYING TO OPEN CHECKPOINT FILES' self.domain = load_checkpoint_file( domain_name=self.outname, checkpoint_dir=self.checkpoint_dir) if myid == 0 and self.verbose: print 'OPENNED CHECKPOINT FILE at time = {}'.format( self.domain.get_time()) except: self.initialize_simulation() self.domain.set_checkpointing(checkpoint_time=self.checkpoint_time) else: self.initialize_simulation()
def __init__(self, argument_adder=None, from_commandline=True, setup_boundaries=None, setup_domain=None, setup_rainfall=None, setup_structures=None, **kwargs): args = parse_args_and_parameters(argument_adder, from_commandline, **kwargs) self.verbose = args.verbose self.outname = args.outname self.partition_dir = args.partition_dir self.checkpoint_dir = args.checkpoint_dir self.alg = args.alg self.args = args self.checkpointing = args.checkpointing self.checkpoint_time = args.checkpoint_time self.setup_boundaries = setup_boundaries self.setup_domain = setup_domain self.setup_rainfall = setup_rainfall self.setup_structures = setup_structures if self.checkpointing: # try to read in from checkpoint file from anuga import load_checkpoint_file try: if myid == 0 and self.verbose: print 'TRYING TO OPEN CHECKPOINT FILES' self.domain = load_checkpoint_file(domain_name = self.outname, checkpoint_dir = self.checkpoint_dir) if myid == 0 and self.verbose: print 'OPENNED CHECKPOINT FILE at time = {}'.format(self.domain.get_time()) except: self.initialize_simulation() self.domain.set_checkpointing(checkpoint_time = self.checkpoint_time) else: self.initialize_simulation()
from math import sin return sin(t/200) #------------------------------------------------------------------------------ # Use a try statement to read in previous checkpoint file and if not possible # just go ahead as normal and produce domain as usual. # # Though in the part of the code where you create the domain as normal, # remember to turn on checkpointing via # domain.set_checkpointing(checkpoint_time = 5) (see code below) #------------------------------------------------------------------------------ try: from anuga import load_checkpoint_file domain = load_checkpoint_file(domain_name = domain_name, checkpoint_dir = checkpoint_dir) except: #-------------------------------------------------------------------------- # Normal Setup of Domain on processor 0 #-------------------------------------------------------------------------- if myid == 0: domain = create_domain_from_file(mesh_filename) domain.set_quantity('stage', Set_Stage(x0, x1, 1.0)) domain.set_name(domain_name) domain.set_store(True) domain.set_store_vertices_smoothly(False) else: domain = None
return sin(t / 200) #------------------------------------------------------------------------------ # Use a try statement to read in previous checkpoint file and if not possible # just go ahead as normal and produce domain as usual. # # Though in the part of the code where you create the domain as normal, # remember to turn on checkpointing via # domain.set_checkpointing(checkpoint_time = 5) (see code below) #------------------------------------------------------------------------------ try: from anuga import load_checkpoint_file domain = load_checkpoint_file(domain_name=domain_name, checkpoint_dir=checkpoint_dir) except: #-------------------------------------------------------------------------- # Normal Setup of Domain on processor 0 #-------------------------------------------------------------------------- if myid == 0: domain = create_domain_from_file(mesh_filename) domain.set_quantity('stage', Set_Stage(x0, x1, 1.0)) domain.set_name(domain_name) domain.set_store(True) domain.set_store_vertices_smoothly(False) else: domain = None