← Back to team overview

dolfin team mailing list archive

Re: [Question #103296]: saving output to xml format

 

Question #103296 on DOLFIN changed:
https://answers.launchpad.net/dolfin/+question/103296

    Status: Open => Answered

Anders Logg proposed the following answer:
On Fri, Mar 05, 2010 at 09:49:29AM -0000, Chris Richardson wrote:
> New question #103296 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/103296
>
> I want to save output from python to checkpoint my code for reading in later.
> I thought XML was the right way to do this, but I have problems with saving XML.
> Firstly, the demo in tensor-weighted-poisson does not work for me -
>
> -snip-
> # Store to file
> mesh_file = File("mesh.xml.gz")
> c00_file = File("c00.xml.gz")
> c01_file = File("c01.xml.gz")
> c11_file = File("c11.xml.gz")
>
> mesh_file << mesh
> c00_file << c00
> c01_file << c01
> c11_file << c11
> -snip-
>
>   File "../demo/pde/tensor-weighted-poisson/python/generate_data.py", line 38, in <module>
>     mesh_file << mesh
> RuntimeError: *** Error: Unable to write XML data, gzipped XML (.xml.gz) not supported for output.

We can read input in gzipped XML, but not output (should be fairly
easy to add) so you need to use unzipped XML for output.

> Is there some configuration I am missing???
>
> Secondly, if I try to use uncompressed XML:
>
> T1 = Function(Q)
> tfile_xml = File("r1-t.xml")
> tfile_xml << T1
>
> RuntimeError: *** Error: Unable to write objects of type Function to Unknown file type files.

You can't store Functions to file, not any more. We could before but
it was removed since it relied on DOLFIN having a large precompiled
library of elements. Instead, you need to read/write vectors:

  file << T1.vector()
  file >> T1.vector()

You can also try the TimeSeries class which reads/writes in binary
format which should be much more efficient.

It currently only handles Vectors but will handle Meshes in the future.

--
Anders

-- 
You received this question notification because you are a member of
DOLFIN Team, which is an answer contact for DOLFIN.