This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Append output to existing vtk file

+3 votes

I have a writeoutput.py function, where I would like to write my data to vtk files. As I pass a string that identifies the file to write to, I want fenics to open that file and, if it exists, append the current output to it.

So, is there an option in

vfile = dolfin.File(filestring+'__vel.pvd')

that I can pass to the File command, like
vfile = dolfin.File(filestring+'__vel.pvd', 'append') ??

Or how can I do this generally?

related to an answer for: How overwrite file in next timestep.
asked Jan 22, 2014 by Jan FEniCS User (8,290 points)
edited Jan 22, 2014 by Jan

1 Answer

+4 votes

I wouldn't recommend doing this in general with XML-based formats, like VTK. XML is not suited to adding data without holding the entire XML data tree in memory. I would suggest that you look at XDMF.

PVD files are pretty light, so we could support adding to it reasonably efficiently. The File interface is common to a number of output formats, and hence can only have limited functionality. You can create a more specialised file object, e.g. a XDMFFile, which can have a richer interface. Richer functionally could go into the VTKFile interface, but take a first look if XDMFFIle does what you want.

answered Jan 22, 2014 by Garth N. Wells FEniCS Expert (35,930 points)

Thanks for the hint. I need it for visualization in paraview. So I don't see why XDMF should not be suitable.

...