Skip to content
Snippets Groups Projects
Commit 65432bfb authored by Franck Pérignon's avatar Franck Pérignon
Browse files

update printer for parallel output

parent a9aff277
No related branches found
No related tags found
No related merge requests found
......@@ -30,12 +30,12 @@ class Printer(Monitoring):
Monitoring.__init__(self, fields, frequency, name="Printer")
## output file name prefix
if prefix is None:
self.prefix = './out_' + str(main_rank)
self.prefix = './out_'
else:
self.prefix = prefix + str(main_rank)
self.prefix = prefix
## Extension for filename
if ext is None:
self.ext = '.vtk'
self.ext = ''
else:
self.ext = ext
self.input = fields
......@@ -67,8 +67,10 @@ class Printer(Monitoring):
def _build_vtk_dict(self):
"""Build a dictionary from fields to VTK image."""
res = {}
for f in self.variables:
for df in f.discreteFields.values():
#ind = df.topology.mesh.iCompute
if f.isVector:
for d in xrange(len(df.data)):
if len(df.data[d].shape) == 2:
......@@ -113,12 +115,22 @@ class Printer(Monitoring):
except AttributeError:
pass
# Set output file name
filename = self.prefix + '_it_' + str(ite) + self.ext
filename = self.prefix + 'iter_' + str(ite)
filename += '_' + str(main_rank) + self.ext
print "Print to file " + filename
## VTK output \todo: Need fix in 2D, getting an IOError.
try:
orig = self.variables[0].discreteFields.values()[0].topology.mesh.global_start
evtk.imageToVTK(filename, origin=(orig[0], orig[1], orig[2]), pointData=self._build_vtk_dict())
#orig = self.variables[0].discreteFields.values()[0].topology.mesh.global_start
topo = self.variables[0].discreteFields.keys()[0]
orig = tuple([topo.mesh.origin[i]
for i in xrange(topo.mesh.dim)])
coords = topo.mesh.coords
ind = topo.mesh.local_start
orig = tuple([topo.mesh.coords[i].flatten()[ind[i]]
for i in xrange(topo.mesh.dim)])
spacing = tuple(topo.mesh.space_step)
evtk.imageToVTK(filename, origin=orig, spacing=spacing,
pointData=self._build_vtk_dict()))
except IOError:
if self.variables[0].domain.dimension == 2:
## Standard output
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment