Interface to VTK files. VTK supports arbitrary order Lagrange finite elements for the geometry description. XDMF is the preferred format for geometry order <= 2.
| 114 | |
| 115 | |
| 116 | class VTKFile(_cpp.io.VTKFile): |
| 117 | """Interface to VTK files. |
| 118 | |
| 119 | VTK supports arbitrary order Lagrange finite elements for the |
| 120 | geometry description. XDMF is the preferred format for geometry |
| 121 | order <= 2. |
| 122 | """ |
| 123 | |
| 124 | def __enter__(self): |
| 125 | """Enter context manager.""" |
| 126 | return self |
| 127 | |
| 128 | def __exit__(self, exception_type, exception_value, traceback): |
| 129 | """Exit context manager and close file.""" |
| 130 | self.close() |
| 131 | |
| 132 | def write_mesh(self, mesh: Mesh, t: float = 0.0) -> None: |
| 133 | """Write mesh to file for a given time.""" |
| 134 | self.write(mesh._cpp_object, t) |
| 135 | |
| 136 | def write_function(self, u: list[Function] | Function, t: float = 0.0) -> None: |
| 137 | """Write a functions to file with a given time.""" |
| 138 | cpp_objects = [u._cpp_object] if isinstance(u, Function) else [_u._cpp_object for _u in u] |
| 139 | super().write(cpp_objects, t) |
| 140 | |
| 141 | |
| 142 | class XDMFFile(_cpp.io.XDMFFile): |
no outgoing calls