diff --git a/examples/examples.ipynb b/examples/examples.ipynb index b5ee26648..27caada76 100644 --- a/examples/examples.ipynb +++ b/examples/examples.ipynb @@ -87,8 +87,9 @@ "driver.tmax = 1.0\n", "driver.verbose = 0\n", "io.basename = smooth_\n", - "io.do_io = 1\n", + "io.do_io = 0\n", "io.dt_out = 0.2\n", + "io.force_final_output = 0\n", "io.n_out = 10000\n", "mesh.grid_type = Cartesian2d\n", "mesh.nx = 32\n", diff --git a/pyro/_defaults b/pyro/_defaults index ff2427904..2f32cc45e 100644 --- a/pyro/_defaults +++ b/pyro/_defaults @@ -16,6 +16,7 @@ basename = pyro_ ; basename for output files dt_out = 0.1 ; simulation time between writing output files n_out = 10000 ; number of timesteps between writing output files do_io = 1 ; do we output at all? +force_final_output = 0 ; regardless of do_io, do we output when the simulation ends? [vis] diff --git a/pyro/pyro_sim.py b/pyro/pyro_sim.py index a31086f92..fd554019f 100755 --- a/pyro/pyro_sim.py +++ b/pyro/pyro_sim.py @@ -114,11 +114,12 @@ def initialize_problem(self, problem_name, *, inputs_file=None, inputs_dict=None self.rp.load_params(inputs_file, no_new=1) - # manually override the dovis and verbose defaults + # manually override the I/O, dovis, and verbose defaults # for Jupyter, we want runtime vis disabled by default if not self.from_commandline: self.rp.set_param("vis.dovis", 0) self.rp.set_param("driver.verbose", 0) + self.rp.set_param("io.do_io", 0) if inputs_dict is not None: for k, v in inputs_dict.items(): @@ -162,7 +163,10 @@ def run_sim(self): # output the 0th data basename = self.rp.get_param("io.basename") - self.sim.write(f"{basename}{self.sim.n:04d}") + do_io = self.rp.get_param("io.do_io") + + if do_io: + self.sim.write(f"{basename}{self.sim.n:04d}") if self.dovis: plt.figure(num=1, figsize=(8, 6), dpi=100, facecolor='w') @@ -172,10 +176,13 @@ def run_sim(self): self.single_step() # final output - if self.verbose > 0: - msg.warning("outputting...") - basename = self.rp.get_param("io.basename") - self.sim.write(f"{basename}{self.sim.n:04d}") + force_final_output = self.rp.get_param("io.force_final_output") + + if do_io or force_final_output: + if self.verbose > 0: + msg.warning("outputting...") + basename = self.rp.get_param("io.basename") + self.sim.write(f"{basename}{self.sim.n:04d}") tm_main.end() # ------------------------------------------------------------------------- diff --git a/pyro/test.py b/pyro/test.py index d2868c56d..2f5b953bb 100755 --- a/pyro/test.py +++ b/pyro/test.py @@ -57,14 +57,12 @@ def run_test(t, reset_fails, store_all_benchmarks, rtol, nproc): reset_bench_on_fail=reset_fails, make_bench=store_all_benchmarks) p.initialize_problem(t.problem, inputs_file=t.inputs, inputs_dict=t.options) - start_n = p.sim.n err = p.run_sim(rtol) finally: os.chdir(orig_cwd) if err == 0: # the test passed; clean up the output files for developer use basename = p.rp.get_param("io.basename") - (test_dir / f"{basename}{start_n:04d}.h5").unlink() (test_dir / f"{basename}{p.sim.n:04d}.h5").unlink() (test_dir / "inputs.auto").unlink() test_dir.rmdir() @@ -86,7 +84,7 @@ def do_tests(out_file, reset_fails=False, store_all_benchmarks=False, single=None, solver=None, rtol=1e-12, nproc=1): - opts = {"driver.verbose": 0, "vis.dovis": 0, "io.do_io": 0} + opts = {"driver.verbose": 0, "vis.dovis": 0, "io.do_io": 0, "io.force_final_output": 1} results = {}