VTXWriter cannot output time history

I am using Fenicsx 0.8, and try to use VTXWriter to write output files. However, it can only write correct output for one function but constant output file for the other function. I tried to use XDMFFile, both functions can be outputted correctly.

sample code:

V= fem.functionspace(mesh = domain, element=("Lagrange",1, (3, ) ) )
u = fem.Function(V)

with XDMFFile(MPI.COMM_WORLD, 'test_u.xdmf', "w") as xdmf:
    xdmf.write_mesh(domain)


s_space= fem.functionspace(mesh=domain, element=("DG", 0, (3, 3)))

s_sol = fem.Function(s_space)
s_sol.name = "S"

vtx_u = io.VTXWriter(MPI.COMM_WORLD, 'vtx_test_u.bp', u)
vtx_s = io.VTXWriter(MPI.COMM_WORLD, 'vtx_test_s.bp', s_sol)

for n in range(1, 10):

   # do things  
  # u is solved using Newton solver

   num_its, converged = solver.solve(u)

# Then get s using projection,
    s_testFun = ufl.TestFunction(s_space)
    s_trialFun = ufl.TrialFunction(s_space)
    a_s = ufl.inner(s_trialFun , s_testFun ) * dx
    L_s = ufl.inner(PK1, s_testFun ) * dx

    s_problem= LinearProblem(a_s, L_s)
    s_sol_this = s_problem.solve()


   # VTXwriter gives the constant s over time, same as the first step
   # but u output is correct
    s_sol.x.array[:] = s_sol_this.x.array
    vtx_u.write(n)
    vtx_s.write(n)

   # xdmf gives correct u and s
    xdmf.write_function(u, t=n)
    xdmf.write_function(s_sol, t=n)

   # xdmf.write_function(s_sol_this, t=n) also work

Thanks.

Please note that this has already been discussed at:

and is an open issue in ADIOS2/VTXWriter

1 Like

Thanks for the prompt response. I could not find that topic before you mentioned it here. Sorry for that. I will use XDMFFile instead until the VTXWriter issue is solved.