diff --git a/hysop/core/checkpoints.py b/hysop/core/checkpoints.py index ef802b7fffefb78a6b78cc9ac0171ef016618858..592ee6dec62e77e589890bdaba48a86c639f7bef 100644 --- a/hysop/core/checkpoints.py +++ b/hysop/core/checkpoints.py @@ -293,6 +293,7 @@ class CheckpointHandler(object): params_group = root.create_group('params') fields_group = root.create_group('fields') simu_group = root.create_group('simulation') + operators_group = root.create_group('operators') else: store = None root = None @@ -303,6 +304,18 @@ class CheckpointHandler(object): # count number of total data bytes without compression nbytes = 0 fmt_key = self._format_zarr_key + + # operators + for op in problem.nodes: + if not op.checkpoint_required(): + continue + key = fmt_key(op.checkpoint_datagroup_key()) + if (key in operators_group): + msg=('Operator checkpoint key \'{}\' has already been taken by another operator, ' + 'consider overriding {}.checkpoint_datagroup_key() or disable checkpointing ' + 'for one of the two operators by tweeking the checkpoint_required() method.') + raise RuntimeError(msg.format(key, op.__class__.__name__)) + operators_group.create_group(key) # Generate parameter arrays # Here we expect that each process store parameters that are in sync @@ -475,6 +488,7 @@ class CheckpointHandler(object): fields_group = root['fields'] params_group = root['params'] simu_group = root['simulation'] + operators_group = root['operators'] nbytes = root.attrs['nbytes'] except: msg='A fatal error occured during checkpoint export, checkpoint template may be illformed.' @@ -487,6 +501,14 @@ class CheckpointHandler(object): # Export simulation data if is_io_leader: simulation.save_checkpoint(simu_group, mpi_params, io_params, checkpoint_compressor) + + # Export operator data + for op in problem.nodes: + if not op.checkpoint_required(): + continue + key = fmt_key(op.checkpoint_datagroup_key()) + operator_group = operators_group[key] + op.save_checkpoint(operator_group, mpi_params, io_params, checkpoint_compressor) # Currently there is no distributed parameter capabilities so io_leader has to dump all parameters if is_io_leader: @@ -589,6 +611,18 @@ class CheckpointHandler(object): msg = ' | importing simulation...' vprint(msg) simulation.load_checkpoint(simu_group, mpi_params, io_params, relax_constraints) + + # Import operator data + for op in problem.nodes: + if not op.checkpoint_required(): + continue + key = fmt_key(op.checkpoint_datagroup_key()) + if (key not in operators_group): + msg='Could not find operator key \'{}\' in checkpoint.' + raise_warning(msg.format(key)) + continue + operator_group = operators_group[key] + op.load_checkpoint(operator_group, mpi_params, io_params, relax_constraints) # Import parameters, hopefully parameter names match the ones in the checkpoint msg = ' | importing parameters...' diff --git a/hysop/core/graph/computational_operator.py b/hysop/core/graph/computational_operator.py index 5655abf61a1317ee38e4a5cb1dfc1144fc9fc2d8..cde43663565605c8fabd2cb2c8bba5dd31e34a32 100644 --- a/hysop/core/graph/computational_operator.py +++ b/hysop/core/graph/computational_operator.py @@ -105,6 +105,15 @@ class ComputationalGraphOperator(ComputationalGraphNode): finalize() (requires self.ready to be set) sets self.ready to False + Operators support checkpointing, ie. continuing a simulation state from a checkpoint stored on disk. + In order for this to work, some operators may store data during checkpoint export and reload data + during checkpoint import. In order for this to work, operators have to override the following methods: + checkpoint_required() should return True + save_checkpoint(self, datagroup, mpi_params, io_params, compressor) + load_checkpoint(self, datagroup, mpi_params, io_params, relax_constraints) + By default, datagroup are saved and retrieved based on operator name. + When this is not sufficient, operators can override checkpoint_datagroup_key() to pass a custom key. + Nothing besides __init__ should be called explicitely by the user as a ComputationalGraphOperator should always be embedded into a hysop.problem.Problem, or at least, a child class of hysop.core.graph.computational_graph.ComputationalGraph. @@ -669,6 +678,70 @@ class ComputationalGraphOperator(ComputationalGraphNode): return ops + def checkpoint_required(self): + """ + Should return True if this operator may export/import custom checkpoint data. + Can be overriden to enable operator checkpointing. + """ + return False + + def checkpoint_datagroup_key(self): + """ + By default the checkpoint datagroup key is based on operator name. + This can be overriden to generate custom keys. + Note that all keys are post-processing by using CheckpointHandler._format_zarr_key. + """ + return self.name + + def save_checkpoint(self, datagroup, mpi_params, io_params, compressor): + """ + Save custom operator data to a checkpoint. + + Datagroup is a zarr.hierarchy.Datagroup object, see hysop.core.checkpoints.CheckpointHandler for example usage. + Parameters mpi_params and io_params are MPIParams and IOParams coming from the CheckpointHandler. + You can create numpy-like arrays with datagroup.create_dataset and subgroups with datagroup.create_group. + Compressor is the compressor that should be used when creating arrays with datagroup.create_dataset. + + Each group or array can contain a json-serialisable dictionary of metadata. + Metadata can be set as the following: + group.attrs[key] = value + or + array.attrs[key] = value + where key is a string that does not contain '\' or '/', see hysop.core.checkpoints.CheckpointHandler._format_zarr_key. + + Only io_leader should write metadata, io_leader can be determined as (mpi_params.rank == io_params.io_leader) + Multiple processes array writes should be synchronized unless they write to different blocks of data. + See https://zarr.readthedocs.io/en/stable/tutorial.html#parallel-computing-and-synchronization for more information. + """ + if self.checkpoint_required(): + msg='Operator {} does require checkpointing but {}.save_checkpoint() has not been overriden.' + raise NotImplementedError(msg.format(self.name, self.__class__.__name__)) + else: + msg='{}.load_checkpoint() called but operator {} does not seem to require a checkpoint...' + raise RuntimeError(msg.format(self.__class__.__name__, self.name)) + + def load_checkpoint(self, datagroup, mpi_params, io_params, relax_constraints): + """ + Reload custom operator data from a checkpoint. + + Datagroup is a zarr.hierarchy.Datagroup object, see hysop.core.checkpoints.CheckpointHandler for example usage. + Parameters mpi_params and io_params are MPIParams and IOParams coming from the CheckpointHandler. + If relax_constraints is set, you can ignore data discreapencies such as datatype, else should an error should be raised. + + Data arrays or subgroups can be accessed with the dict-like datagroup[key] syntax. + Group or array metadata can be retrieved by using the group.attrs[key] or array.attrs[key] syntax where key is a + string that does not contain '\' or '/', see hysop.core.checkpoints.CheckpointHandler._format_zarr_key. + + As this operation read-only, there is no need to synchronize processes. + Also note that metadata type is not always the same when deserialized (for example tuples become lists). + """ + if self.checkpoint_required(): + msg='Operator {} does require checkpointing but {}.load_checkpoint() has not been overriden.' + raise NotImplementedError(msg.format(self.name, self.__class__.__name__)) + else: + msg='{}.load_checkpoint() called but operator {} does not seem to require a checkpoint...' + raise RuntimeError(msg.format(self.__class__.__name__, self.name)) + def _check_backend(self): """ Checks backend support and topologies. diff --git a/hysop_examples/example_utils.py b/hysop_examples/example_utils.py index 36349d1e1a853c4df6004f5aea27e824f704099e..9f63f320d04c4654142bdf4bef4281ca055c1319 100644 --- a/hysop_examples/example_utils.py +++ b/hysop_examples/example_utils.py @@ -1568,6 +1568,7 @@ class HysopArgParser(argparse.ArgumentParser): def _setup_parameters(self, args): from hysop import IO, IOParams from hysop.core.checkpoints import CheckpointHandler + from hysop.tools.debug_dumper import DebugDumper args.io_params = IOParams(filename=None, filepath=args.dump_dir, frequency=args.dump_freq, dump_times=args.dump_times, @@ -1625,7 +1626,14 @@ class HysopArgParser(argparse.ArgumentParser): # debug dumps if (args.debug_dump_dir is None): args.debug_dump_dir = args.dump_dir - + if args.debug_dump_target: + debug_dumper = DebugDumper( + path=args.debug_dump_dir, + name=args.debug_dump_target, + force_overwrite=True, enable_on_op_apply=True) + else: + debug_dumper = None + args.debug_dumper = debug_dumper def _setup_implementation(self, args): from hysop.constants import Implementation diff --git a/hysop_examples/examples/analytic/analytic.py b/hysop_examples/examples/analytic/analytic.py index 43d175cf9e56eb6e7880ad754e3d3592d4e214ae..be9bddad40836793a8e8c3f04f04c6443ede93c1 100755 --- a/hysop_examples/examples/analytic/analytic.py +++ b/hysop_examples/examples/analytic/analytic.py @@ -111,19 +111,9 @@ def compute(args): times_of_interest=args.times_of_interest, t=t) - # Attach a field debug dumper if requested - from hysop.tools.debug_dumper import DebugDumper - if args.debug_dump_target: - debug_dumper = DebugDumper( - path=args.debug_dump_dir, - name=args.debug_dump_target, - force_overwrite=True, enable_on_op_apply=True) - else: - debug_dumper = None - # Finally solve the problem problem.solve(simu, dry_run=args.dry_run, - debug_dumper=debug_dumper, + debug_dumper=args.debug_dumper, checkpoint_handler=args.checkpoint_handler) # Finalize diff --git a/hysop_examples/examples/bubble/periodic_bubble.py b/hysop_examples/examples/bubble/periodic_bubble.py index 21f4dd8ee653d3b7b5292a141ff936402a0aefe0..1b25b879d72ddc0c6a48f2c964ff16c025edef0c 100644 --- a/hysop_examples/examples/bubble/periodic_bubble.py +++ b/hysop_examples/examples/bubble/periodic_bubble.py @@ -285,16 +285,6 @@ def compute(args): adapt_dt.equivalent_CFL, filename='parameters.txt', precision=8) - # Attach a field debug dumper if requested - from hysop.tools.debug_dumper import DebugDumper - if args.debug_dump_target: - debug_dumper = DebugDumper( - path=args.debug_dump_dir, - name=args.debug_dump_target, - force_overwrite=True, enable_on_op_apply=True) - else: - debug_dumper = None - # Initialize vorticity, velocity, viscosity and density on all topologies Bc, Br = args.Bc, args.Br dx = np.max(np.divide(box.length, np.asarray(args.npts)-1)) @@ -306,7 +296,7 @@ def compute(args): # Finally solve the problem problem.solve(simu, dry_run=args.dry_run, - debug_dumper=debug_dumper, + debug_dumper=args.debug_dumper, checkpoint_handler=args.checkpoint_handler) # Finalize diff --git a/hysop_examples/examples/bubble/periodic_bubble_levelset.py b/hysop_examples/examples/bubble/periodic_bubble_levelset.py index 967c0b119eadce4bb75988dd1fe1ab3e2d733462..d3ba8e80fda7fec5edd53930232ca6a90f20f174 100644 --- a/hysop_examples/examples/bubble/periodic_bubble_levelset.py +++ b/hysop_examples/examples/bubble/periodic_bubble_levelset.py @@ -284,16 +284,6 @@ def compute(args): adapt_dt.equivalent_CFL, filename='parameters.txt', precision=8) - # Attach a field debug dumper if requested - from hysop.tools.debug_dumper import DebugDumper - if args.debug_dump_target: - debug_dumper = DebugDumper( - path=args.debug_dump_dir, - name=args.debug_dump_target, - force_overwrite=True, enable_on_op_apply=True) - else: - debug_dumper = None - # Initialize vorticity, velocity, viscosity and density on all topologies Bc, Br = args.Bc, args.Br problem.initialize_field(field=velo, formula=init_velocity) @@ -304,7 +294,7 @@ def compute(args): # Finally solve the problem problem.solve(simu, dry_run=args.dry_run, - debug_dumper=debug_dumper, + debug_dumper=args.debug_dumper, checkpoint_handler=args.checkpoint_handler) # Finalize diff --git a/hysop_examples/examples/bubble/periodic_bubble_levelset_penalization.py b/hysop_examples/examples/bubble/periodic_bubble_levelset_penalization.py index 6023b607c8cae6183cba6302b4cf7bd560315a0a..126bf71ca0da7114e8b3827d085f5a581767a62a 100644 --- a/hysop_examples/examples/bubble/periodic_bubble_levelset_penalization.py +++ b/hysop_examples/examples/bubble/periodic_bubble_levelset_penalization.py @@ -325,16 +325,6 @@ def compute(args): adapt_dt.equivalent_CFL, filename='parameters.txt', precision=8) - # Attach a field debug dumper if requested - from hysop.tools.debug_dumper import DebugDumper - if args.debug_dump_target: - debug_dumper = DebugDumper( - path=args.debug_dump_dir, - name=args.debug_dump_target, - force_overwrite=True, enable_on_op_apply=True) - else: - debug_dumper = None - # Initialize vorticity, velocity, viscosity and density on all topologies Bc, Br = args.Bc, args.Br problem.initialize_field(field=velo, formula=init_velocity) @@ -346,7 +336,7 @@ def compute(args): # Finally solve the problem problem.solve(simu, dry_run=args.dry_run, - debug_dumper=debug_dumper, + debug_dumper=args.debug_dumper, checkpoint_handler=args.checkpoint_handler) # Finalize diff --git a/hysop_examples/examples/bubble/periodic_jet_levelset.py b/hysop_examples/examples/bubble/periodic_jet_levelset.py index bbf7223d0d10284ad4d71f99286a1d12091ef0aa..3bc7b83db0d2920f27c66d8ee74d7b775a2e2ff9 100644 --- a/hysop_examples/examples/bubble/periodic_jet_levelset.py +++ b/hysop_examples/examples/bubble/periodic_jet_levelset.py @@ -273,16 +273,6 @@ def compute(args): adapt_dt.equivalent_CFL, filename='parameters.txt', precision=8) - # Attach a field debug dumper if requested - from hysop.tools.debug_dumper import DebugDumper - if args.debug_dump_target: - debug_dumper = DebugDumper( - path=args.debug_dump_dir, - name=args.debug_dump_target, - force_overwrite=True, enable_on_op_apply=True) - else: - debug_dumper = None - # Initialize vorticity, velocity, viscosity and density on all topologies problem.initialize_field(field=velo, formula=init_velocity) problem.initialize_field(field=vorti, formula=init_vorticity) @@ -291,7 +281,7 @@ def compute(args): # Finally solve the problem problem.solve(simu, dry_run=args.dry_run, - debug_dumper=debug_dumper, + debug_dumper=args.debug_dumper, checkpoint_handler=args.checkpoint_handler) # Finalize diff --git a/hysop_examples/examples/cylinder/oscillating_cylinder.py b/hysop_examples/examples/cylinder/oscillating_cylinder.py index 287159233c0ecae1f96a7845745e66b2234742bc..de8a2f97ac095e79991e24163c96abdd80620448 100644 --- a/hysop_examples/examples/cylinder/oscillating_cylinder.py +++ b/hysop_examples/examples/cylinder/oscillating_cylinder.py @@ -247,16 +247,6 @@ def compute(args): adapt_dt.equivalent_CFL, filename='parameters.txt', precision=8) - # Attach a field debug dumper if requested - from hysop.tools.debug_dumper import DebugDumper - if args.debug_dump_target: - debug_dumper = DebugDumper( - path=args.debug_dump_dir, - name=args.debug_dump_target, - force_overwrite=True, enable_on_op_apply=True) - else: - debug_dumper = None - # Initialize vorticity, velocity, viscosity and density on all topologies problem.initialize_field(field=velo, formula=init_velocity) problem.initialize_field(field=vorti, formula=init_vorticity) @@ -264,7 +254,7 @@ def compute(args): # Finally solve the problem problem.solve(simu, dry_run=args.dry_run, - debug_dumper=debug_dumper, + debug_dumper=args.debug_dumper, checkpoint_handler=args.checkpoint_handler) # Finalize diff --git a/hysop_examples/examples/flow_around_sphere/flow_around_sphere.py b/hysop_examples/examples/flow_around_sphere/flow_around_sphere.py index ce5c6ef71e0900a10badd2da2c5a0bad0059938e..858e4bbf71e186cd381554276b68ccc966240156 100644 --- a/hysop_examples/examples/flow_around_sphere/flow_around_sphere.py +++ b/hysop_examples/examples/flow_around_sphere/flow_around_sphere.py @@ -315,23 +315,13 @@ def compute(args): min_max_U.Finf, min_max_W.Finf, adapt_dt.equivalent_CFL, filename='parameters.txt', precision=8) - # Attach a field debug dumper if requested - from hysop.tools.debug_dumper import DebugDumper - if args.debug_dump_target: - debug_dumper = DebugDumper( - path=args.debug_dump_dir, - name=args.debug_dump_target, - force_overwrite=True, enable_on_op_apply=True) - else: - debug_dumper = None - problem.initialize_field(vorti, formula=computeVort) problem.initialize_field(velo, formula=computeVel) problem.initialize_field(sphere, formula=computeSphere) # Finally solve the problem problem.solve(simu, dry_run=args.dry_run, - debug_dumper=debug_dumper, + debug_dumper=args.debug_dumper, checkpoint_handler=args.checkpoint_handler) diff --git a/hysop_examples/examples/multiresolution/scalar_advection.py b/hysop_examples/examples/multiresolution/scalar_advection.py index 58a9daf25f034635d9ee71d528ee02a6248020ee..71ed3d9471b23edf9f44adb69b5cde4decd83165 100644 --- a/hysop_examples/examples/multiresolution/scalar_advection.py +++ b/hysop_examples/examples/multiresolution/scalar_advection.py @@ -181,19 +181,9 @@ def compute(args): times_of_interest=args.times_of_interest, dt=dt, dt0=dt0) - # Attach a field debug dumper if requested - from hysop.tools.debug_dumper import DebugDumper - if args.debug_dump_target: - debug_dumper = DebugDumper( - path=args.debug_dump_dir, - name=args.debug_dump_target, - force_overwrite=True, enable_on_op_apply=True) - else: - debug_dumper = None - # Finally solve the problem problem.solve(simu, dry_run=args.dry_run, - debug_dumper=debug_dumper, + debug_dumper=args.debug_dumper, checkpoint_handler=args.checkpoint_handler) # Finalize diff --git a/hysop_examples/examples/particles_above_salt/particles_above_salt_bc.py b/hysop_examples/examples/particles_above_salt/particles_above_salt_bc.py index 2c74ae5e825aad5dc7d5d4a523b506a89650c9cd..1054d6ace33451d7c77daa327a117142fe5ff0f8 100644 --- a/hysop_examples/examples/particles_above_salt/particles_above_salt_bc.py +++ b/hysop_examples/examples/particles_above_salt/particles_above_salt_bc.py @@ -308,16 +308,6 @@ def compute(args): min_max_U.Finf, min_max_W.Finf, adapt_dt.equivalent_CFL, filename='parameters.txt', precision=8) - # Attach a field debug dumper if requested - from hysop.tools.debug_dumper import DebugDumper - if args.debug_dump_target: - debug_dumper = DebugDumper( - path=args.debug_dump_dir, - name=args.debug_dump_target, - force_overwrite=True, enable_on_op_apply=True) - else: - debug_dumper = None - # Initialize vorticity, velocity, S and C on all topologies problem.initialize_field(field=velo, formula=init_velocity) problem.initialize_field(field=vorti, formula=init_vorticity) @@ -326,7 +316,7 @@ def compute(args): # Finally solve the problem problem.solve(simu, dry_run=args.dry_run, - debug_dumper=debug_dumper, + debug_dumper=args.debug_dumper, checkpoint_handler=args.checkpoint_handler) # Finalize diff --git a/hysop_examples/examples/particles_above_salt/particles_above_salt_bc_3d.py b/hysop_examples/examples/particles_above_salt/particles_above_salt_bc_3d.py index 08adb0dc2b9c6fac0123c2285dbc654173a2de28..f7c1b6c54328948bc6b02751f7daf75df3a88c84 100644 --- a/hysop_examples/examples/particles_above_salt/particles_above_salt_bc_3d.py +++ b/hysop_examples/examples/particles_above_salt/particles_above_salt_bc_3d.py @@ -324,16 +324,6 @@ def compute(args): min_max_U.Finf, min_max_W.Finf, adapt_dt.equivalent_CFL, filename='parameters.txt', precision=8) - # Attach a field debug dumper if requested - from hysop.tools.debug_dumper import DebugDumper - if args.debug_dump_target: - debug_dumper = DebugDumper( - path=args.debug_dump_dir, - name=args.debug_dump_target, - force_overwrite=True, enable_on_op_apply=True) - else: - debug_dumper = None - # Initialize vorticity, velocity, S and C on all topologies problem.initialize_field(field=velo, formula=init_velocity) problem.initialize_field(field=vorti, formula=init_vorticity) @@ -342,7 +332,7 @@ def compute(args): # Finally solve the problem problem.solve(simu, dry_run=args.dry_run, - debug_dumper=debug_dumper, + debug_dumper=args.debug_dumper, checkpoint_handler=args.checkpoint_handler) diff --git a/hysop_examples/examples/particles_above_salt/particles_above_salt_periodic.py b/hysop_examples/examples/particles_above_salt/particles_above_salt_periodic.py index 10de6dde5c36ca6e7537d2967cdf502cdbac65e1..0bf75e0b7732fca2f5745290e0ef6f9bf6c7a824 100644 --- a/hysop_examples/examples/particles_above_salt/particles_above_salt_periodic.py +++ b/hysop_examples/examples/particles_above_salt/particles_above_salt_periodic.py @@ -318,16 +318,6 @@ def compute(args): min_max_U.Finf, min_max_W.Finf, adapt_dt.equivalent_CFL, filename='parameters.txt', precision=8) - # Attach a field debug dumper if requested - from hysop.tools.debug_dumper import DebugDumper - if args.debug_dump_target: - debug_dumper = DebugDumper( - path=args.debug_dump_dir, - name=args.debug_dump_target, - force_overwrite=True, enable_on_op_apply=True) - else: - debug_dumper = None - # Initialize vorticity, velocity, S and C on all topologies problem.initialize_field(field=velo, formula=init_velocity) problem.initialize_field(field=vorti, formula=init_vorticity) @@ -337,7 +327,7 @@ def compute(args): # Finally solve the problem problem.solve(simu, dry_run=args.dry_run, - debug_dumper=debug_dumper, + debug_dumper=args.debug_dumper, checkpoint_handler=args.checkpoint_handler) diff --git a/hysop_examples/examples/particles_above_salt/particles_above_salt_symmetrized.py b/hysop_examples/examples/particles_above_salt/particles_above_salt_symmetrized.py index c77fb54bc24df5388641d87883cb7e343c31ebb3..9ab6eae39a47751d2eaddb99e50d01a2b4e0f8ba 100644 --- a/hysop_examples/examples/particles_above_salt/particles_above_salt_symmetrized.py +++ b/hysop_examples/examples/particles_above_salt/particles_above_salt_symmetrized.py @@ -306,16 +306,6 @@ def compute(args): min_max_U.Finf, min_max_W.Finf, adapt_dt.equivalent_CFL, filename='parameters.txt', precision=8) - # Attach a field debug dumper if requested - from hysop.tools.debug_dumper import DebugDumper - if args.debug_dump_target: - debug_dumper = DebugDumper( - path=args.debug_dump_dir, - name=args.debug_dump_target, - force_overwrite=True, enable_on_op_apply=True) - else: - debug_dumper = None - # Initialize vorticity, velocity, S and C on all topologies problem.initialize_field(field=velo, formula=init_velocity) problem.initialize_field(field=vorti, formula=init_vorticity) @@ -324,7 +314,7 @@ def compute(args): # Finally solve the problem problem.solve(simu, dry_run=args.dry_run, - debug_dumper=debug_dumper, + debug_dumper=args.debug_dumper, checkpoint_handler=args.checkpoint_handler) diff --git a/hysop_examples/examples/scalar_advection/levelset.py b/hysop_examples/examples/scalar_advection/levelset.py index 0b153896ca1b925ca3afa60c24444a6c7c610e64..8bf74e4698ff4a0e8ebde821da6894657ad38242 100644 --- a/hysop_examples/examples/scalar_advection/levelset.py +++ b/hysop_examples/examples/scalar_advection/levelset.py @@ -207,22 +207,12 @@ def compute(args): if args.display_graph: problem.display(args.visu_rank) - # Attach a field debug dumper if requested - from hysop.tools.debug_dumper import DebugDumper - if args.debug_dump_target: - debug_dumper = DebugDumper( - path=args.debug_dump_dir, - name=args.debug_dump_target, - force_overwrite=True, enable_on_op_apply=True) - else: - debug_dumper = None - # Initialize scalar problem.initialize_field(scalar, formula=init_scalar) # Finally solve the problem problem.solve(simu, dry_run=args.dry_run, - debug_dumper=debug_dumper, + debug_dumper=args.debug_dumper, checkpoint_handler=args.checkpoint_handler) problem.finalize() diff --git a/hysop_examples/examples/scalar_advection/scalar_advection.py b/hysop_examples/examples/scalar_advection/scalar_advection.py index 17c7275a01827b1c9f61ddd350a3b77eadd6bb81..a75992ab2941e9ea67f3c0e89bd71954a1afd544 100644 --- a/hysop_examples/examples/scalar_advection/scalar_advection.py +++ b/hysop_examples/examples/scalar_advection/scalar_advection.py @@ -135,19 +135,9 @@ def compute(args): times_of_interest=args.times_of_interest, dt=dt, dt0=dt0) - # Attach a field debug dumper if requested - from hysop.tools.debug_dumper import DebugDumper - if args.debug_dump_target: - debug_dumper = DebugDumper( - path=args.debug_dump_dir, - name=args.debug_dump_target, - force_overwrite=True, enable_on_op_apply=True) - else: - debug_dumper = None - # Finally solve the problem problem.solve(simu, dry_run=args.dry_run, - debug_dumper=debug_dumper, + debug_dumper=args.debug_dumper, checkpoint_handler=args.checkpoint_handler) diff --git a/hysop_examples/examples/scalar_diffusion/scalar_diffusion.py b/hysop_examples/examples/scalar_diffusion/scalar_diffusion.py index dcf1f88bb7c616c4c2b77ca13bc554cdae03811e..1abf3be08d7aa62b381b50a8ba66004c58385c97 100755 --- a/hysop_examples/examples/scalar_diffusion/scalar_diffusion.py +++ b/hysop_examples/examples/scalar_diffusion/scalar_diffusion.py @@ -101,16 +101,6 @@ def compute(args): if args.display_graph: problem.display(args.visu_rank) - # Attach a field debug dumper when requested - if args.debug_dump_target: - from hysop.tools.debug_dumper import DebugDumper - debug_dumper = DebugDumper( - path=args.debug_dump_dir, - name=args.debug_dump_target, - force_overwrite=True, enable_on_op_apply=True) - else: - debug_dumper = None - # Initialize discrete scalar field problem.initialize_field(scalar, formula=init_scalar) @@ -123,7 +113,7 @@ def compute(args): # Finally solve the problem problem.solve(simu, dry_run=args.dry_run, - debug_dumper=debug_dumper, + debug_dumper=args.debug_dumper, checkpoint_handler=args.checkpoint_handler) # Finalize diff --git a/hysop_examples/examples/sediment_deposit/sediment_deposit.py b/hysop_examples/examples/sediment_deposit/sediment_deposit.py index 9b2107b43f7599a62f38f0f1ce34dbd54857e644..84c05dbbbfca0d1f715e54cd6494e3088733b17d 100644 --- a/hysop_examples/examples/sediment_deposit/sediment_deposit.py +++ b/hysop_examples/examples/sediment_deposit/sediment_deposit.py @@ -320,16 +320,6 @@ def compute(args): min_max_U.Finf, min_max_W.Finf, adapt_dt.equivalent_CFL, filename='parameters.txt', precision=8) - # Attach a field debug dumper if requested - from hysop.tools.debug_dumper import DebugDumper - if args.debug_dump_target: - debug_dumper = DebugDumper( - path=args.debug_dump_dir, - name=args.debug_dump_target, - force_overwrite=True, enable_on_op_apply=True) - else: - debug_dumper = None - # Initialize vorticity, velocity, S on all topologies problem.initialize_field(field=velo, formula=init_velocity) problem.initialize_field(field=vorti, formula=init_vorticity) @@ -338,7 +328,7 @@ def compute(args): # Finally solve the problem problem.solve(simu, dry_run=args.dry_run, - debug_dumper=debug_dumper, + debug_dumper=args.debug_dumper, checkpoint_handler=args.checkpoint_handler) diff --git a/hysop_examples/examples/sediment_deposit/sediment_deposit_levelset.py b/hysop_examples/examples/sediment_deposit/sediment_deposit_levelset.py index 476852fa0fb8792ae3d15b8b1d4e2897c8d17970..4d2f5bf568c1700efb0c9b32732b767d21c4bdca 100644 --- a/hysop_examples/examples/sediment_deposit/sediment_deposit_levelset.py +++ b/hysop_examples/examples/sediment_deposit/sediment_deposit_levelset.py @@ -381,16 +381,6 @@ def compute(args): min_max_U.Finf, min_max_W.Finf, adapt_dt.equivalent_CFL, filename='parameters.txt', precision=8) - # Attach a field debug dumper if requested - from hysop.tools.debug_dumper import DebugDumper - if args.debug_dump_target: - debug_dumper = DebugDumper( - path=args.debug_dump_dir, - name=args.debug_dump_target, - force_overwrite=True, enable_on_op_apply=True) - else: - debug_dumper = None - # Initialize vorticity, velocity, S on all topologies problem.initialize_field(field=velo, formula=init_velocity) problem.initialize_field(field=vorti, formula=init_vorticity) @@ -399,7 +389,7 @@ def compute(args): # Finally solve the problem problem.solve(simu, dry_run=args.dry_run, - debug_dumper=debug_dumper, + debug_dumper=args.debug_dumper, checkpoint_handler=args.checkpoint_handler) diff --git a/hysop_examples/examples/shear_layer/shear_layer.py b/hysop_examples/examples/shear_layer/shear_layer.py index e7e162154bed95e6f8b42b39c6e1cc039e14fabf..05bbe3f7c68bce6009cd3fa69975618107e557cf 100644 --- a/hysop_examples/examples/shear_layer/shear_layer.py +++ b/hysop_examples/examples/shear_layer/shear_layer.py @@ -182,23 +182,13 @@ def compute(args): t=t, dt=dt) simu.write_parameters(t, dt, filename='parameters.txt', precision=4) - # Attach a field debug dumper if requested - from hysop.tools.debug_dumper import DebugDumper - if args.debug_dump_target: - debug_dumper = DebugDumper( - path=args.debug_dump_dir, - name=args.debug_dump_target, - force_overwrite=True, enable_on_op_apply=True) - else: - debug_dumper = None - # Initialize only the vorticity problem.initialize_field(velo, formula=init_velocity) problem.initialize_field(vorti, formula=init_vorticity) # Finally solve the problem problem.solve(simu, dry_run=args.dry_run, - debug_dumper=debug_dumper, + debug_dumper=args.debug_dumper, checkpoint_handler=args.checkpoint_handler, plot_freq=args.plot_freq) diff --git a/hysop_examples/examples/taylor_green/taylor_green.py b/hysop_examples/examples/taylor_green/taylor_green.py index 942bfccac1753f70b1a6e0ac80dff5505e04641a..cc51ec1ec95e91866d8803c22fa1900b32344d7b 100644 --- a/hysop_examples/examples/taylor_green/taylor_green.py +++ b/hysop_examples/examples/taylor_green/taylor_green.py @@ -293,22 +293,12 @@ def compute(args): min_max_U.Finf, min_max_W.Finf, min_max_gradU.Finf, adapt_dt.equivalent_CFL) simu.write_parameters(*params, filename='parameters.txt', precision=8) - # Attach a field debug dumper if requested - from hysop.tools.debug_dumper import DebugDumper - if args.debug_dump_target: - debug_dumper = DebugDumper( - path=args.debug_dump_dir, - name=args.debug_dump_target, - force_overwrite=True, enable_on_op_apply=True) - else: - debug_dumper = None - # Initialize only the vorticity problem.initialize_field(vorti, formula=init_vorticity) # Finally solve the problem problem.solve(simu, dry_run=args.dry_run, - debug_dumper=debug_dumper, + debug_dumper=args.debug_dumper, checkpoint_handler=args.checkpoint_handler) # Finalize diff --git a/hysop_examples/examples/taylor_green/taylor_green_cpuFortran.py b/hysop_examples/examples/taylor_green/taylor_green_cpuFortran.py index fdb613695677d8da96c92c7e28d58fa93971b46b..2fe7bb438c235b45244d9d3d05e0f676c4a70e19 100644 --- a/hysop_examples/examples/taylor_green/taylor_green_cpuFortran.py +++ b/hysop_examples/examples/taylor_green/taylor_green_cpuFortran.py @@ -211,22 +211,12 @@ def compute(args): min_max_U.Finf, min_max_W.Finf, adapt_dt.equivalent_CFL, filename='parameters.txt', precision=8) - # Attach a field debug dumper if requested - from hysop.tools.debug_dumper import DebugDumper - if args.debug_dump_target: - debug_dumper = DebugDumper( - path=args.debug_dump_dir, - name=args.debug_dump_target, - force_overwrite=True, enable_on_op_apply=True) - else: - debug_dumper = None - # Initialize only the vorticity problem.initialize_field(vorti, formula=init_vorticity) # Finally solve the problem problem.solve(simu, dry_run=args.dry_run, - debug_dumper=debug_dumper, + debug_dumper=args.debug_dumper, checkpoint_handler=args.checkpoint_handler) # Finalize