From 2da4528add3be09ad6b8874e9fe5133bdc36cbf7 Mon Sep 17 00:00:00 2001 From: Chris Greenshields Date: Mon, 29 Jul 2024 14:44:41 +0100 Subject: [PATCH] foamSequenceVTKFiles: generates a .vtk.series file to maintain time in a sequence of VTK files. Instead of loading a group of VTK which uses their index as time, the respective .vtk.series file can be loaded which relates each file to the correct time. --- bin/foamSequenceVTKFiles | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/bin/foamSequenceVTKFiles b/bin/foamSequenceVTKFiles index 00d86ebb98..e89afd5477 100755 --- a/bin/foamSequenceVTKFiles +++ b/bin/foamSequenceVTKFiles @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | Website: https://openfoam.org -# \\ / A nd | Copyright (C) 2015-2022 OpenFOAM Foundation +# \\ / A nd | Copyright (C) 2015-2024 OpenFOAM Foundation # \\/ M anipulation | #------------------------------------------------------------------------------ # License @@ -90,6 +90,22 @@ multipleSeries () { echo "$_dirs" } +seriesFileHead () { + cat< "$series_file" + for f in $file_list do ! [ "$d" = SINGLE ] && \ ! echo "$f" | grep -q "$d" && \ continue - [ "$d" = SINGLE ] && unset s - link=$(printf "${n}${s}.%04d.vtk" $i) ln -s "../$f" "$out/$link" + + # Write series file + [ "$i" -eq 0 ] || printf ",\n" >> "$series_file" + time="$(dirname "$f" | awk -F/ '{print $NF}')" + printf "%17s\"%s\", \"time\": %s }" \ + '{"name": ' \ + "$link" \ + "$time" >> "$series_file" + i=$(( i + 1 )) # Relies on ordered list of files done + seriesFileFoot >> "$series_file" + s=$(( s + 1 )) done done