saving output to xml format
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-
-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/
mesh_file << mesh
RuntimeError: *** Error: Unable to write XML data, gzipped XML (.xml.gz) not supported 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.
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Anders Logg
- Solved:
- 2010-03-05
- Last query:
- 2010-03-05
- Last reply:
- 2010-03-05
|
#1 |
On Fri, Mar 05, 2010 at 09:49:29AM -0000, Chris Richardson wrote:
> New question #103296 on DOLFIN:
> https:/
>
> 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-
>
> -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/
> 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
Chris Richardson (chris-bpi) said : | #2 |
Many thanks,
Chris
Chris Richardson (chris-bpi) said : | #3 |
Thanks Anders Logg, that solved my question.