pymor.tools.io.vtk

Module Contents

Functions

_read_collection

_read_single

_get_collection_data

_get_vtk_type

Parse given file until a VTKFile element is found.

read_vtkfile

Try to read a given file into a Sequence of meshio.Mesh instances

write_vtk_collection

Output grid-associated data in vtk format

pymor.tools.io.vtk._read_collection(xml, metadata_key)[source]
pymor.tools.io.vtk._read_single(filename)[source]
pymor.tools.io.vtk._get_collection_data(filename)[source]
pymor.tools.io.vtk._get_vtk_type(path)[source]

Parse given file until a VTKFile element is found.

We use the incremental event emitting parser here since we can expect to encounter appended binary data in the xml which lxml cannot parse.

Parameters

path

vtk file to peek into

Returns

None if no VTKFile element found, else the type attribute of the VTKFile element

pymor.tools.io.vtk.read_vtkfile(filename, metadata_key='timestep')[source]

Try to read a given file into a Sequence of meshio.Mesh instances

Parameters

metadata_key

Which metadata to extract and return alongside the meshio.Mesh instances.

Returns

A list of (metadata_value, meshio.Mesh) tuples. The length of the list is either 1 for

a singular vtk/vtu/vtp input file (None is returned as metadata), or however many members are in the collection file (pvd).

pymor.tools.io.vtk.write_vtk_collection(filename_base, meshes, metadata=None)[source]

Output grid-associated data in vtk format

filename_base

common component for output files in collection

meshes

Sequence of meshio.Mesh objects

metadata

dict of {key1: sequence1, key2: sequence2} where sequence must be of len(meshes) or len == 1 currently supported keys are “timestep”, “name”, “group” and “part” used to describe datapoints in Vtk collection file defaults to { ‘timestep’: list(range(len(meshes))) }

Returns

full filename of saved file