From 187d5e97f403aa28075e8410c7f897dfa4c8283d Mon Sep 17 00:00:00 2001
From: Thomas Gibson <gibsonthomas1120@hotmail.com>
Date: Sat, 15 May 2021 20:25:29 -0500
Subject: [PATCH] Add switch for writing output

---
 examples/maxwell/cavities.py | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/examples/maxwell/cavities.py b/examples/maxwell/cavities.py
index 03f65362..2808a505 100644
--- a/examples/maxwell/cavities.py
+++ b/examples/maxwell/cavities.py
@@ -114,11 +114,13 @@ def main(dims, write_output=False, order=4):
     e, h = maxwell_operator.split_eh(fields)
 
     if write_output:
-        vis.write_vtk_file("fld-cavities-%04d.vtu" % step,
-                [
-                    ("e", e),
-                    ("h", h),
-                    ])
+        vis.write_vtk_file(
+            "fld-cavities-%04d.vtu" % step,
+            [
+                ("e", e),
+                ("h", h),
+            ]
+        )
 
     for event in dt_stepper.run(t_end=final_t):
         if isinstance(event, dt_stepper.StateComputed):
@@ -130,12 +132,15 @@ def main(dims, write_output=False, order=4):
                     norm(u=h[0]), norm(u=h[1]),
                     time()-t_last_step)
             if step % 10 == 0:
-                e, h = maxwell_operator.split_eh(event.state_component)
-                vis.write_vtk_file("fld-cavities-%04d.vtu" % step,
+                if write_output:
+                    e, h = maxwell_operator.split_eh(event.state_component)
+                    vis.write_vtk_file(
+                        "fld-cavities-%04d.vtu" % step,
                         [
                             ("e", e),
                             ("h", h),
-                            ])
+                        ]
+                    )
             t_last_step = time()
 
 
-- 
GitLab