File: demo_no_vtk_adios2.patch

package info (click to toggle)
fenics-dolfinx 1%3A0.9.0-8
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 5,304 kB
  • sloc: cpp: 33,643; python: 22,329; makefile: 234; sh: 173; xml: 55
file content (54 lines) | stat: -rw-r--r-- 1,915 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
--- a/python/demo/demo_scattering_boundary_conditions.py
+++ b/python/demo/demo_scattering_boundary_conditions.py
@@ -638,8 +638,11 @@
 Esh_dg = fem.Function(V_dg)
 Esh_dg.interpolate(Esh)
 
-with io.VTXWriter(domain.comm, "Esh.bp", Esh_dg) as vtx:
-    vtx.write(0.0)
+if hasattr(io,"VTXWriter"):
+    with io.VTXWriter(domain.comm, "Esh.bp", Esh_dg) as vtx:
+        vtx.write(0.0)
+else:
+    print("Cannot write Esh.bp: VTXWriter (adios2) is not available")
 # -
 
 # We visualize the solution using PyVista. For more information about
@@ -677,8 +680,11 @@
 E.x.array[:] = Eb.x.array[:] + Esh.x.array[:]
 E_dg = fem.Function(V_dg)
 E_dg.interpolate(E)
-with io.VTXWriter(domain.comm, "E.bp", E_dg) as vtx:
-    vtx.write(0.0)
+if hasattr(io,"VTXWriter"):
+    with io.VTXWriter(domain.comm, "E.bp", E_dg) as vtx:
+        vtx.write(0.0)
+else:
+    print("Cannot write E.bp: VTXWriter (adios2) is not available")
 # -
 
 # We validate our numerical solution by computing the absorption,
--- a/python/demo/demo_half_loaded_waveguide.py
+++ b/python/demo/demo_half_loaded_waveguide.py
@@ -482,11 +482,17 @@
         Et_dg.interpolate(eth)
 
         # Save solutions
-        with io.VTXWriter(msh.comm, f"sols/Et_{i}.bp", Et_dg) as f:
-            f.write(0.0)
+        if hasattr(io,"VTXWriter"):
+            with io.VTXWriter(msh.comm, f"sols/Et_{i}.bp", Et_dg) as f:
+                f.write(0.0)
+        else:
+            print(f"Cannot write sols/Et_{i}.bp: VTXWriter (adios2) is not available")
 
-        with io.VTXWriter(msh.comm, f"sols/Ez_{i}.bp", ezh) as f:
-            f.write(0.0)
+        if hasattr(io,"VTXWriter"):
+            with io.VTXWriter(msh.comm, f"sols/Ez_{i}.bp", ezh) as f:
+                f.write(0.0)
+        else:
+            print(f"Cannot write sols/Ez_{i}.bp: VTXWriter (adios2) is not available")
 
         # Visualize solutions with Pyvista
         if have_pyvista: