How to append to VTX file

Oops… it was something silly…

Here’s the correct use:

from dolfinx.io import VTXWriter
import dolfinx
from mpi4py import MPI

mesh = dolfinx.mesh.create_unit_cube(MPI.COMM_WORLD, 10, 10, 10)
V = dolfinx.fem.FunctionSpace(mesh, ("Lagrange", 1))
u = dolfinx.fem.Function(V)

u.interpolate(lambda x: x[0] ** 2 + x[1] ** 2 + x[2] ** 2)

writer = VTXWriter(mesh.comm, "my_export.bp", [u], "BP4")

writer.write(1.0)

u.interpolate(lambda x: 3 + x[0] - x[0])

writer.write(2.0)
1 Like