Commit a78c0879 authored by Martin Bauer's avatar Martin Bauer
Browse files

Datahandling VTK fix

parent 8ecc7676
......@@ -6,8 +6,10 @@ from pystencils.utils import DotDict
import waLBerla as wlb
import warnings
class ParallelDataHandling(DataHandling):
GPU_DATA_PREFIX = "gpu_"
VTK_COUNTER = 0
def __init__(self, blocks, defaultGhostLayers=1, defaultLayout='SoA', dim=3):
"""
......@@ -294,7 +296,8 @@ class ParallelDataHandling(DataHandling):
ghostLayers = 0
if ghostLayers is True:
ghostLayers = min(self.ghostLayersOfField(n) for n in dataNames)
fileName = "%s_%02d" % (fileName, ParallelDataHandling.VTK_COUNTER)
ParallelDataHandling.VTK_COUNTER += 1
output = wlb.vtk.makeOutput(self.blocks, fileName, ghostLayers=ghostLayers)
for n in dataNames:
output.addCellDataWriter(wlb.field.createVTKWriter(self.blocks, n))
......
......@@ -304,17 +304,21 @@ class SerialDataHandling(DataHandling):
for name in dataNames:
field = self._getFieldWithGivenNumberOfGhostLayers(name, ghostLayers)
if self.dim == 2:
field = field[:, :, np.newaxis]
cellData[name] = field[:, :, np.newaxis]
if len(field.shape) == 3:
field = np.ascontiguousarray(field)
cellData[name] = np.ascontiguousarray(field)
elif len(field.shape) == 4:
field = [np.ascontiguousarray(field[..., i]) for i in range(field.shape[-1])]
if len(field) == 2:
field.append(np.zeros_like(field[0]))
field = tuple(field)
fSize = field.shape[-1]
if fSize == self.dim:
field = [np.ascontiguousarray(field[..., i]) for i in range(fSize)]
if len(field) == 2:
field.append(np.zeros_like(field[0]))
cellData[name] = tuple(field)
else:
for i in range(fSize):
cellData["%s[%d]" % (name, i)] = np.ascontiguousarray(field[...,i])
else:
assert False
cellData[name] = field
imageToVTK(fullFileName, cellData=cellData)
return writer
......
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