-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add helper scripts for creating and deleting large numbers of tecplot…
… files (#225) * Add helper scripts for creating and deleting tecplot files * Clean up `f5convert_all` * Condense to 1 script for conversion and 1 for cleaning, add option to use f5tovtk * Add some content to the docs * Convert tabs to spaces * Adding f5convert/f5clean to conda build * Increasing max ci runtime --------- Co-authored-by: Tim Brooks <41971846+timryanb@users.noreply.github.com>
- Loading branch information
Showing
5 changed files
with
185 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
|
||
helpstring=" | ||
This command will look for all .f5 files in the current directory and delete any files with the same name but a | ||
.plt, .szplt or .vtk extension, this is useful for clearing space on your filesystem by removing tecplot/paraview files | ||
that can be regenerated from the f5 files when needed. It is also safer than simply running 'rm *.plt *.szplt *.vtk' as | ||
it will only delete the files that can be regenerated from the f5 files. | ||
To clean up all files in the current directory: | ||
> `basename $0` | ||
To also run recursively in all subdirectories that contain .f5 files: | ||
> `basename $0` -s | ||
" | ||
|
||
if [ "$1" == "-h" ]; then | ||
echo "$helpstring" | ||
exit 0 | ||
fi | ||
|
||
subdirs=false | ||
while [[ "$#" -gt 0 ]]; do case $1 in | ||
-s|--subdirs) subdirs=true;; | ||
*) echo "Unknown parameter passed: $1"; exit 1;; | ||
esac; shift; done | ||
|
||
f5clean_all() { | ||
for f in *.f5; do | ||
for extension in plt szplt vtk; do | ||
fileName="${f%.*}.$extension" | ||
[ -e $fileName ] && echo "deleting $fileName" && rm -f ./$fileName | ||
done | ||
done | ||
} | ||
|
||
|
||
if [ $subdirs = true ] ; then | ||
RootDir=$(pwd) | ||
find . -iname '*.f5' -printf '%h\n' | sort -u | while read i; do | ||
cd "$i" && pwd && f5clean_all ; cd "$RootDir" | ||
done | ||
else | ||
f5clean_all | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
#!/bin/bash | ||
|
||
helpstring=" | ||
This command runs f5totec or f5tovtk in parallel on all .f5 files in the current directory | ||
Usage: | ||
To convert .f5 files in the current directory using all available procs: | ||
> `basename $0` | ||
By default, `basename $0` will ignore any .f5 files for which there is a corresponding .plt file newer than the .f5 file | ||
To convert all .f5 files overwriting existing files: | ||
> `basename $0` -r | ||
To run on N procs: | ||
> `basename $0` -n N | ||
To supress the echoing of which files will and won't be converted (does not supress f5totec's own output): | ||
> `basename $0` -q | ||
To also run recursively in all subdirectories that contain .f5 files: | ||
> `basename $0` -s | ||
To use f5tovtk instead of f5totec: | ||
> `basename $0` --vtk | ||
This script uses GNU parallel which can be installed on debian using: | ||
> sudo apt-get install parallel | ||
" | ||
|
||
if [ "$1" == "-h" ]; then | ||
echo "$helpstring" | ||
exit 0 | ||
fi | ||
|
||
if ! command -v parallel &> /dev/null | ||
then | ||
echo "parallel could not be found, please install it to use f5convert_all" | ||
exit | ||
fi | ||
|
||
# Parse input options | ||
reconvert=false | ||
quiet=false | ||
vtk=false | ||
subdirs=false | ||
extra_args="" | ||
nprocs=+0 | ||
while [[ "$#" -gt 0 ]]; do case $1 in | ||
-n|--nprocs) nprocs=$2; shift;; | ||
-q|--quiet) quiet=true; shift;; | ||
-r|--reconvert) reconvert=true; shift;; | ||
-s|--subdirs) subdirs=true; shift;; | ||
--vtk) vtk=true;; | ||
*) echo "Unknown parameter passed: $1"; exit 1;; | ||
esac; shift; done | ||
|
||
f5convert_all() { | ||
|
||
reconvert=$1 | ||
quiet=$2 | ||
vtk=$3 | ||
nprocs=$4 | ||
|
||
for value in $reconvert $quiet $vtk $nprocs; do | ||
echo $value | ||
done | ||
|
||
if [ $vtk = true ] ; then | ||
convertCommand=f5tovtk | ||
else | ||
convertCommand=f5totec | ||
fi | ||
|
||
# Loop through all the f5 files in the current directory and figure out which ones to convert | ||
filesToConvert=() | ||
for f in *.f5; | ||
do | ||
if [ $reconvert = true ] || ([ "$vtk" = false ] && [ ! -f "${f%.*}.plt" ] && [ ! -f "${f%.*}.szplt" ]) || ([ "$vtk" = true ] && [ ! -f "${f%.*}.vtk" ]) ; then | ||
# If there is not .plt/.szplt/.vtk file corresponding to the current .f5 or is user specified -r then convert the file | ||
filesToConvert[${#filesToConvert[@]}]=$f | ||
echo "$f" 'will be converted' | ||
elif [ -f "${f%.*}.plt" ] && [ "$vtk" = false ] ; then | ||
if [ "${f%.*}.plt" -ot "$f" ] ; then | ||
# If there is a .plt file but it's older than the corresponding .f5 file then convert the .f5 file | ||
echo "$f" 'will be converted as it is newer than' "${f%.*}.plt" | ||
filesToConvert[${#filesToConvert[@]}]=$f | ||
else | ||
echo "$f" 'will not be converted as' "${f%.*}.plt" 'already exists, to force overwriting use the -r flag' | ||
fi | ||
elif [ -f "${f%.*}.szplt" ] && [ "$vtk" = false ] ; then | ||
if [ "${f%.*}.szplt" -ot "$f" ] ; then | ||
# If there is a .szplt file but it's older than the corresponding .f5 file then convert the .f5 file | ||
echo "$f" 'will be converted as it is newer than' "${f%.*}.szplt" | ||
filesToConvert[${#filesToConvert[@]}]=$f | ||
else | ||
echo "$f" 'will not be converted as' "${f%.*}.szplt" 'already exists, to force overwriting use the -r flag' | ||
fi | ||
elif [ -f "${f%.*}.vtk" ] && [ "$vtk" = true ] ; then | ||
if [ "${f%.*}.vtk" -ot "$f" ] ; then | ||
# If there is a .vtk file but it's older than the corresponding .f5 file then convert the .f5 file | ||
echo "$f" 'will be converted as it is newer than' "${f%.*}.vtk" | ||
filesToConvert[${#filesToConvert[@]}]=$f | ||
else | ||
echo "$f" 'will not be converted as' "${f%.*}.vtk" 'already exists, to force overwriting use the -r flag' | ||
fi | ||
fi | ||
done | ||
|
||
# Do the conversion | ||
for f in "${filesToConvert[@]}"; | ||
do | ||
echo "$f" | ||
done | parallel --will-cite -j$nprocs $convertCommand {} | ||
} | ||
|
||
if [ $subdirs = true ] ; then | ||
RootDir=$(pwd) | ||
find . -iname '*.f5' -printf '%h\n' | sort -u | while read i; do | ||
cd "$i" && pwd && f5convert_all $reconvert $quiet $vtk $nprocs ; cd "$RootDir" | ||
done | ||
else | ||
f5convert_all $reconvert $quiet $vtk $nprocs | ||
fi |
This file was deleted.
Oops, something went wrong.