Commit bffd44af authored by Simeon Doetsch's avatar Simeon Doetsch

VTK: added support for multiple file mode

parent dd95e08b
......@@ -68,9 +68,9 @@ Simulation(sim_dir='', format=None, coordinates=None)
plutoplot searchs for the gridfile and simulation data first in `sim_dir`,
then in `sim_dir/data`, and then looks up the data directory in `pluto.ini`.
Default: Current working directory
- `format`: file format of the simulation data, currently supports `double` and `float`
- `format`: file format of the simulation data, currently supports `dbl`, `flt`, `vtk`
in both `single_file` and `multiple_files` mode.
Default: `double` and `float` are tried in that order
Default: `dbl`, `flt`, `vtk`, are tried in that order
- `coordinates`: coordinate system of the simulation grid.
Supports `cartesian`, `spherical`, `polar`, `cylindrical`.
Only necessary for projecting the grind into a cartesian system (e.g. for plotting).
......
......@@ -83,8 +83,13 @@ class SimulationMetadata:
self.read_vars(join(data_dir, '{}.out'.format(format)), format)
# read VTK offsets in file
if format == 'vtk' and self.file_mode == 'single':
self.vtk_offsets = vtk_offsets(join(data_dir, 'data.0000.vtk'))
if format == 'vtk':
if self.file_mode == 'single':
self.vtk_offsets = vtk_offsets(join(data_dir, 'data.0000.vtk'))
else:
self.vtk_offsets = {}
for var in self.vars:
self.vtk_offsets.update(vtk_offsets(join(data_dir, '{}.0000.vtk'.format(var))))
def read_vars(self, path, format) -> None:
"""Read simulation step data and written variables"""
......
......@@ -62,12 +62,15 @@ class PlutoData(object):
filename = "data.{n:04d}.{format}".format(n=self.n, format=self.format)
# byte offset of variable in dbl file
offset = self.charsize * self.size * self.vars.index(var)
elif self.file_mode == 'multiple':
else:
filename = "{var}.{:04d}.{format}".format(var=var, n=self.n, format=self.format)
offset = 0
elif self.format == 'vtk':
filename = "data.{n:04d}.vtk".format(n=self.n)
offset = self.simulation.metadata.vtk_offsets[var]
if self.file_mode == 'single':
filename = "data.{n:04d}.vtk".format(n=self.n)
else:
filename = "{var}.{n:04d}.vtk".format(var=var, n=self.n)
shape = tuple(reversed(self.data_shape))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment