diff --git a/pySDC/helpers/fieldsIO.py b/pySDC/helpers/fieldsIO.py index 2a515f8121e609c7cc373b842390d94c12508000..3b124dd109aae19a109f88cbccddcafaa04d5d16 100644 --- a/pySDC/helpers/fieldsIO.py +++ b/pySDC/helpers/fieldsIO.py @@ -457,7 +457,7 @@ class Rectilinear(Scalar): """Number of degrees of freedom for one variable""" return np.prod(self.gridSizes) - def toVTR(self, baseName, varNames, suffix="{:06d}_t={:1.2f}s"): + def toVTR(self, baseName, varNames, idxFormat="{:06d}"): """ Convert all 3D fields stored in binary format (FieldsIO) into a list of VTR files, that can be read later with Paraview or equivalent to @@ -469,10 +469,9 @@ class Rectilinear(Scalar): Base name of the VTR file. varNames : list[str] Variable names of the fields. - suffix : str, optional - Formating string for the suffix of the VTR file, containing the - index in first position, and the time in second position. - The default is "{:06d}_t={:1.2f}s". + idxFormat : str, optional + Formatting string for the index of the VTR file. + The default is "{:06d}". Example ------- @@ -486,10 +485,10 @@ class Rectilinear(Scalar): assert self.dim == 3, "can only be used with 3D fields" from pySDC.helpers.vtkIO import writeToVTR - template = f"{baseName}_{suffix}" + template = f"{baseName}_{idxFormat}" for i in range(self.nFields): - t, u = self.readField(i) - writeToVTR(template.format(i, t), u, self.header["coords"], varNames) + _, u = self.readField(i) + writeToVTR(template.format(i), u, self.header["coords"], varNames) # ------------------------------------------------------------------------- # MPI-parallel implementation diff --git a/pySDC/tests/test_helpers/test_fieldsIO.py b/pySDC/tests/test_helpers/test_fieldsIO.py index d13fefd3eb6a97ba44211ac12d76e7f599623d2b..1e75505d0faab3f8c062a251466fe1a2b378c4b4 100644 --- a/pySDC/tests/test_helpers/test_fieldsIO.py +++ b/pySDC/tests/test_helpers/test_fieldsIO.py @@ -184,12 +184,10 @@ def testToVTR(nVar, nX, nY, nZ, nSteps): vtrFiles = glob.glob("testToVTR*.vtr") assert len(vtrFiles) == file.nFields - vtrFiles.sort(key=lambda name: int(name.split("_")[1])) + vtrFiles.sort(key=lambda name: int(name.split("_")[-1][:-4])) for i, vFile in enumerate(vtrFiles): uVTR, coords, _ = readFromVTR(vFile) - tVTR = float(vFile.split("_t=")[-1].split("s.vtr")[0]) - tFile, uFile = file.readField(i) - assert np.allclose(tFile, tVTR), "mismatch between field times" + _, uFile = file.readField(i) assert np.allclose(uFile, uVTR), "mismatch between data" for i, (xVTR, xFile) in enumerate(zip(coords, file.header["coords"])): assert np.allclose(xVTR, xFile), f"coordinate mismatch in dir. {i}"