Commit f714c9c5 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

ENH: add cloneParallelCase function into bin/tools/RunFunctions

parent 25c74188
......@@ -219,28 +219,97 @@ compileApplication()
#
cloneCase()
{
if [ -e "$2" ]
local src=$1
local dst=$2
shift 2
if [ -e "$dst" ]
then
echo "Case already cloned: remove case directory $2 to clone"
elif [ -d "$1" ]
echo "Case already cloned: remove case directory $dst prior to cloning"
return 1
elif [ ! -d "$src" ]
then
echo "Cloning $2 case from $1"
mkdir $2
# These must exist, so do not hide error messages
for f in system constant
do
\cp -r $1/$f $2
done
echo "Error: no directory to clone: $src"
return 1
fi
echo "Cloning $dst case from $src"
mkdir $dst
# These must exist, so do not hide error messages
for f in constant system
do
\cp -r $src/$f $dst
done
# Either (or both) may exist, so error messages may be spurious
for f in 0 0.orig
# Either (or both) may exist, so error messages may be spurious
for f in 0 0.orig
do
\cp -r $src/$f $dst 2>/dev/null
done
return 0
}
#
# cloneParallelCase srcDir dstDir [...times]
#
# If any times are specified, they will be used for the cloning.
# Otherwise the entire processor* directories are cloned
cloneParallelCase()
{
local src=$1
local dst=$2
shift 2
if [ -e "$dst" ]
then
echo "Case already cloned: remove case directory $dst prior to cloning"
return 1
fi
[ -d "$src" ] || {
echo "Error: no directory to clone: $src"
return 1
}
echo "Cloning $dst parallel case from $src"
mkdir $dst
# These must exist, so do not hide error messages
for f in constant system
do
\cp -r $src/$f $dst
done
[ -d $src/processor0 ] || {
echo "Does not appear to be a parallel case"
return 1
}
if [ "$#" -eq 0 ]
then
# Copy all processor directories
echo " clone processor* directories"
\cp -r $src/processor* $dst
else
# Only copy some time directories
echo " clone processor directories with $# times: $@"
for proc in $(cd $src && \ls -d processor*)
do
\cp -r $1/$f $2 2>/dev/null
srcProc=$src/$proc
dstProc=$dst/$proc
mkdir $dstProc
cp -r $srcProc/constant $dstProc/
for time
do
[ -d $srcProc/$time ] && cp -r $srcProc/$time $dstProc/
done
done
else
echo "Error: cannot clone from non-existent directory"
echo " $1"
fi
return 0
}
# Overwrite 0/ with the contents of 0.orig/ if it exists.
......
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions
cloneParallelCase()
{
if [ -d $2 ]
then
echo "Case already cloned: remove case directory $2 to clone"
else
echo "Cloning $2 case from $1 in parallel mode"
mkdir $2
cpfiles="processor* system constant"
for f in $cpfiles
do
cp -r $1/$f $2
done
fi
}
# Do the Spalart-Allmaras steady-state case
(cd motorBike && foamRunTutorials)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment