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.
This commit is contained in:
@ -3,7 +3,7 @@
|
|||||||
# ========= |
|
# ========= |
|
||||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
# \\ / O peration | Website: https://openfoam.org
|
# \\ / O peration | Website: https://openfoam.org
|
||||||
# \\ / A nd | Copyright (C) 2015-2022 OpenFOAM Foundation
|
# \\ / A nd | Copyright (C) 2015-2024 OpenFOAM Foundation
|
||||||
# \\/ M anipulation |
|
# \\/ M anipulation |
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# License
|
# License
|
||||||
@ -90,6 +90,22 @@ multipleSeries () {
|
|||||||
echo "$_dirs"
|
echo "$_dirs"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
seriesFileHead () {
|
||||||
|
cat<<EOF
|
||||||
|
{
|
||||||
|
"file-series-version": "1.0",
|
||||||
|
"files": [
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
seriesFileFoot () {
|
||||||
|
cat<<EOF
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
dir=postProcessing
|
dir=postProcessing
|
||||||
out=sequencedVTK
|
out=sequencedVTK
|
||||||
|
|
||||||
@ -158,19 +174,33 @@ do
|
|||||||
# Image index
|
# Image index
|
||||||
i=0
|
i=0
|
||||||
|
|
||||||
|
[ "$d" = SINGLE ] && unset s
|
||||||
|
|
||||||
|
series_file="$out/$n$s.vtk.series"
|
||||||
|
seriesFileHead > "$series_file"
|
||||||
|
|
||||||
for f in $file_list
|
for f in $file_list
|
||||||
do
|
do
|
||||||
! [ "$d" = SINGLE ] && \
|
! [ "$d" = SINGLE ] && \
|
||||||
! echo "$f" | grep -q "$d" && \
|
! echo "$f" | grep -q "$d" && \
|
||||||
continue
|
continue
|
||||||
|
|
||||||
[ "$d" = SINGLE ] && unset s
|
|
||||||
|
|
||||||
link=$(printf "${n}${s}.%04d.vtk" $i)
|
link=$(printf "${n}${s}.%04d.vtk" $i)
|
||||||
ln -s "../$f" "$out/$link"
|
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
|
i=$(( i + 1 )) # Relies on ordered list of files
|
||||||
done
|
done
|
||||||
|
|
||||||
|
seriesFileFoot >> "$series_file"
|
||||||
|
|
||||||
s=$(( s + 1 ))
|
s=$(( s + 1 ))
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user