Saving and retrieving fields to/from xdmf files
Hi,
I'd like to try out the new support for xdmf files, but unfortunately there don't seem to be any examples or demos available. All I could find was a an email which suggested to do this:
file = File("foo.xdmf")
file << u
(Here I presume that u is a dolfin.Function.) I tried to play around with this but am having a couple of questions:
1) What is the correct way to associate timestamps with the data (for example for later inspection in Paraview) - in particular when I'd like to save multiple fields simultaneously?
After digging a bit into the C++ classes and their docstrings, I tried this (in Python):
file = File("foo.xdmf")
file << (u, 0.0)
file << (v, 0.0)
file << (u, 1.0)
file << (v, 2.0)
I'd expect this to save both fields u, v at time t=0, whereas at time t=1 only the field u should be saved, and similarly at t=2 only v should be saved. When I open the resulting file in Paraview, it seems to recognise that there are four fields present in the .xdmf file (these are displayed in the 'Properties' pane, both in the 'Blocks' and 'Hierarchy' tabs). However, the 'Display' pane doesn't give me any option to visualise either of the fields. Only when I advance to t=1.0 or t=2.0 (at each of which time steps there is just a single field present) can I visualise that data.
Of course it's possible that I'm just unable to use Paraview correctly, but my hunch is that I'm doing something wrong in saving the data. Any suggestions?
2) How can I read the data back in from a .xdmf file?
More precisely, assume I previously saved multiple fields at different time steps as above. How do I, say, retrieve a field with name 'v' which was stored at time t=2.0 so that I can store it in a df.Function object?
Generally, would it be possible to make some examples (or even just short code snippets) available for the new functionality that was introduced in dolfin 1.1? There seems to be a lot of really cool stuff, but it's of very limited use if it's unclear how to use it in one's own code. :) A case in point is the re-ordering of dofs, where I'm still confused as to what the correct way is to reliably set the values of a df.Function, other than using vertex_to_dof_map() (which is unreleased as yet, I believe?).
Many thanks!
Max
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Garth Wells
- Solved:
- Last query:
- Last reply: