Skip to content

Commit a132a92

Browse files
committed
TL: corrected Rectilinear.toVTR for paraview groups
1 parent 1874244 commit a132a92

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

pySDC/helpers/fieldsIO.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ def nDoF(self):
457457
"""Number of degrees of freedom for one variable"""
458458
return np.prod(self.gridSizes)
459459

460-
def toVTR(self, baseName, varNames, suffix="{:06d}_t={:1.2f}s"):
460+
def toVTR(self, baseName, varNames, idxFormat="{:06d}"):
461461
"""
462462
Convert all 3D fields stored in binary format (FieldsIO) into a list
463463
of VTR files, that can be read later with Paraview or equivalent to
@@ -469,10 +469,9 @@ def toVTR(self, baseName, varNames, suffix="{:06d}_t={:1.2f}s"):
469469
Base name of the VTR file.
470470
varNames : list[str]
471471
Variable names of the fields.
472-
suffix : str, optional
473-
Formating string for the suffix of the VTR file, containing the
474-
index in first position, and the time in second position.
475-
The default is "{:06d}_t={:1.2f}s".
472+
idxFormat : str, optional
473+
Formatting string for the index of the VTR file.
474+
The default is "{:06d}".
476475
477476
Example
478477
-------
@@ -486,10 +485,10 @@ def toVTR(self, baseName, varNames, suffix="{:06d}_t={:1.2f}s"):
486485
assert self.dim == 3, "can only be used with 3D fields"
487486
from pySDC.helpers.vtkIO import writeToVTR
488487

489-
template = f"{baseName}_{suffix}"
488+
template = f"{baseName}_{idxFormat}"
490489
for i in range(self.nFields):
491-
t, u = self.readField(i)
492-
writeToVTR(template.format(i, t), u, self.header["coords"], varNames)
490+
_, u = self.readField(i)
491+
writeToVTR(template.format(i), u, self.header["coords"], varNames)
493492

494493
# -------------------------------------------------------------------------
495494
# MPI-parallel implementation

pySDC/tests/test_helpers/test_fieldsIO.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,10 @@ def testToVTR(nVar, nX, nY, nZ, nSteps):
184184
vtrFiles = glob.glob("testToVTR*.vtr")
185185
assert len(vtrFiles) == file.nFields
186186

187-
vtrFiles.sort(key=lambda name: int(name.split("_")[1]))
187+
vtrFiles.sort(key=lambda name: int(name.split("_")[-1][:-4]))
188188
for i, vFile in enumerate(vtrFiles):
189189
uVTR, coords, _ = readFromVTR(vFile)
190-
tVTR = float(vFile.split("_t=")[-1].split("s.vtr")[0])
191-
tFile, uFile = file.readField(i)
192-
assert np.allclose(tFile, tVTR), "mismatch between field times"
190+
_, uFile = file.readField(i)
193191
assert np.allclose(uFile, uVTR), "mismatch between data"
194192
for i, (xVTR, xFile) in enumerate(zip(coords, file.header["coords"])):
195193
assert np.allclose(xVTR, xFile), f"coordinate mismatch in dir. {i}"

0 commit comments

Comments
 (0)