Skip to content

Commit 73d8038

Browse files
authored
disable I/O by default in Jupyter (#259)
also, the first and last plotfile were not respecting io.do_io
1 parent 8e6acd6 commit 73d8038

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

examples/examples.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@
8787
"driver.tmax = 1.0\n",
8888
"driver.verbose = 0\n",
8989
"io.basename = smooth_\n",
90-
"io.do_io = 1\n",
90+
"io.do_io = 0\n",
9191
"io.dt_out = 0.2\n",
92+
"io.force_final_output = 0\n",
9293
"io.n_out = 10000\n",
9394
"mesh.grid_type = Cartesian2d\n",
9495
"mesh.nx = 32\n",

pyro/_defaults

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ basename = pyro_ ; basename for output files
1616
dt_out = 0.1 ; simulation time between writing output files
1717
n_out = 10000 ; number of timesteps between writing output files
1818
do_io = 1 ; do we output at all?
19+
force_final_output = 0 ; regardless of do_io, do we output when the simulation ends?
1920

2021
[vis]
2122

pyro/pyro_sim.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,12 @@ def initialize_problem(self, problem_name, *, inputs_file=None, inputs_dict=None
149149

150150
self.rp.load_params(inputs_file, no_new=1)
151151

152-
# manually override the dovis and verbose defaults
152+
# manually override the I/O, dovis, and verbose defaults
153153
# for Jupyter, we want runtime vis disabled by default
154154
if not self.from_commandline:
155155
self.rp.set_param("vis.dovis", 0)
156156
self.rp.set_param("driver.verbose", 0)
157+
self.rp.set_param("io.do_io", 0)
157158

158159
if inputs_dict is not None:
159160
for k, v in inputs_dict.items():
@@ -198,7 +199,10 @@ def run_sim(self):
198199

199200
# output the 0th data
200201
basename = self.rp.get_param("io.basename")
201-
self.sim.write(f"{basename}{self.sim.n:04d}")
202+
do_io = self.rp.get_param("io.do_io")
203+
204+
if do_io:
205+
self.sim.write(f"{basename}{self.sim.n:04d}")
202206

203207
if self.dovis:
204208
plt.figure(num=1, figsize=(8, 6), dpi=100, facecolor='w')
@@ -208,10 +212,13 @@ def run_sim(self):
208212
self.single_step()
209213

210214
# final output
211-
if self.verbose > 0:
212-
msg.warning("outputting...")
213-
basename = self.rp.get_param("io.basename")
214-
self.sim.write(f"{basename}{self.sim.n:04d}")
215+
force_final_output = self.rp.get_param("io.force_final_output")
216+
217+
if do_io or force_final_output:
218+
if self.verbose > 0:
219+
msg.warning("outputting...")
220+
basename = self.rp.get_param("io.basename")
221+
self.sim.write(f"{basename}{self.sim.n:04d}")
215222

216223
tm_main.end()
217224
# -------------------------------------------------------------------------

pyro/test.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,12 @@ def run_test(t, reset_fails, store_all_benchmarks, rtol, nproc):
5757
reset_bench_on_fail=reset_fails,
5858
make_bench=store_all_benchmarks)
5959
p.initialize_problem(t.problem, inputs_file=t.inputs, inputs_dict=t.options)
60-
start_n = p.sim.n
6160
err = p.run_sim(rtol)
6261
finally:
6362
os.chdir(orig_cwd)
6463
if err == 0:
6564
# the test passed; clean up the output files for developer use
6665
basename = p.rp.get_param("io.basename")
67-
(test_dir / f"{basename}{start_n:04d}.h5").unlink()
6866
(test_dir / f"{basename}{p.sim.n:04d}.h5").unlink()
6967
(test_dir / "inputs.auto").unlink()
7068
test_dir.rmdir()
@@ -86,7 +84,7 @@ def do_tests(out_file,
8684
reset_fails=False, store_all_benchmarks=False,
8785
single=None, solver=None, rtol=1e-12, nproc=1):
8886

89-
opts = {"driver.verbose": 0, "vis.dovis": 0, "io.do_io": 0}
87+
opts = {"driver.verbose": 0, "vis.dovis": 0, "io.do_io": 0, "io.force_final_output": 1}
9088

9189
results = {}
9290

0 commit comments

Comments
 (0)