MCPcopy Create free account
hub / github.com/FEniCS/dolfinx / VTXWriter

Class VTXWriter

python/dolfinx/io/utils.py:34–113  ·  view source on GitHub ↗

Writer for VTX files, using ADIOS2 to create the files. VTX supports arbitrary order Lagrange finite elements for the geometry description and arbitrary order (discontinuous) Lagrange finite elements for Functions. The files can be viewed using Paraview.

Source from the content-addressed store, hash-verified

32 __all__ = [*__all__, "VTXWriter", "VTXMeshPolicy"]
33
34 class VTXWriter:
35 """Writer for VTX files, using ADIOS2 to create the files.
36
37 VTX supports arbitrary order Lagrange finite elements for the
38 geometry description and arbitrary order (discontinuous)
39 Lagrange finite elements for Functions.
40
41 The files can be viewed using Paraview.
42 """
43
44 _cpp_object: _cpp.io.VTXWriter_float32 | _cpp.io.VTXWriter_float64
45
46 def __init__(
47 self,
48 comm: _MPI.Comm,
49 filename: str | Path,
50 output: Mesh | Function | list[Function] | tuple[Function],
51 engine: str = "BPFile",
52 mesh_policy: VTXMeshPolicy = VTXMeshPolicy.update,
53 ):
54 """Initialize a writer for outputting data in the VTX format.
55
56 Args:
57 comm: The MPI communicator
58 filename: The output filename
59 output: The data to output. Either a mesh, a single
60 (discontinuous) Lagrange Function or list of
61 (discontinuous) Lagrange Functions.
62 engine: ADIOS2 engine to use for output. See
63 ADIOS2 documentation for options.
64 mesh_policy: Controls if the mesh is written to file at
65 the first time step only when a ``Function`` is
66 written to file, or is re-written (updated) at each
67 time step. Has an effect only for ``Function``
68 output.
69
70 Note:
71 All Functions for output must share the same mesh and
72 have the same element type.
73 """
74 # Get geometry type
75 if isinstance(output, Mesh):
76 dtype = output.geometry.x.dtype
77 elif isinstance(output, Function):
78 dtype = output.function_space.mesh.geometry.x.dtype
79 else:
80 dtype = output[0].function_space.mesh.geometry.x.dtype
81
82 if np.issubdtype(dtype, np.float32):
83 _vtxwriter = _cpp.io.VTXWriter_float32
84 elif np.issubdtype(dtype, np.float64):
85 _vtxwriter = _cpp.io.VTXWriter_float64
86 else:
87 raise RuntimeError(f"VTXWriter does not support dtype={dtype}.")
88
89 if isinstance(output, Mesh):
90 self._cpp_object = _vtxwriter(comm, filename, output._cpp_object, engine) # type: ignore[union-attr]
91 else:

Callers 15

test_second_order_vtxMethod · 0.90
test_vtx_meshMethod · 0.90
test_vtx_names_failMethod · 0.90
test_vtx_functionsMethod · 0.90
test_empty_rank_meshMethod · 0.90
test_vtx_reuse_meshMethod · 0.90
test_dg_0_dataMethod · 0.90
demo_axis.pyFile · 0.90

Calls

no outgoing calls

Tested by 10

test_second_order_vtxMethod · 0.72
test_vtx_meshMethod · 0.72
test_vtx_names_failMethod · 0.72
test_vtx_functionsMethod · 0.72
test_empty_rank_meshMethod · 0.72
test_vtx_reuse_meshMethod · 0.72
test_dg_0_dataMethod · 0.72