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

allow xmf output every time step

parent 76e3c0be
No related branches found
No related tags found
No related merge requests found
......@@ -25,7 +25,7 @@ class Printer(Monitoring):
Print field(s) values on a given topo, in HDF5 or VTK format.
"""
def __init__(self, variables, topo, prefix=None,
frequency=1, formattype=None, task_id=None):
frequency=1, formattype=None, task_id=None, xmfalways=False):
"""
Create a results printer for given fields, prefix
prefix (relative path) and an output frequency.
......@@ -35,6 +35,8 @@ class Printer(Monitoring):
@param prefix output file name. Default is None ==> no output.
Full or relative path.
@param formattype : output file format, default=vtk.
@param xmfalways : true if xmf output must be done every time
an hdf5 file is created
"""
Monitoring.__init__(self, variables, topo, task_id=task_id)
assert frequency > 0
......@@ -86,6 +88,8 @@ class Printer(Monitoring):
self._get_filename = lambda i: self.prefix + \
"_{0:05d}".format(i) + '.h5'
self.step = self._step_HDF5
if xmfalways:
self.step = self._step_HDF5_XMF
elif self.formattype == DATA:
self._get_filename = lambda i: self.prefix + \
"_{0}_{1:05d}.dat".format(self.topo.rank, i)
......@@ -117,7 +121,7 @@ class Printer(Monitoring):
self.step(simulation)
self._count += 1
def finalize(self):
def createXMFFile(self):
if self.formattype == HDF5 and self.topo.rank == self.io_rank:
# Write the xmf file driving all h5 files.
# Writing only one file
......@@ -139,6 +143,9 @@ class Printer(Monitoring):
f.write(" </Domain>\n")
f.write("</Xdmf>\n")
f.close()
def finalize(self):
self.createXMFFile()
Monitoring.finalize(self)
def _build_vtk_dict(self):
......@@ -217,6 +224,10 @@ class Printer(Monitoring):
f.close()
def _step_HDF5_XMF(self, simu):
self._step_HDF5(simu)
self.createXMFFile()
def _step_DATA(self, simu):
f = open(self._get_filename(self._count), 'w')
shape = self.topo.mesh.resolution
......
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