mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add cloneParallelCase function into bin/tools/RunFunctions
This commit is contained in:
@ -219,28 +219,97 @@ compileApplication()
|
|||||||
#
|
#
|
||||||
cloneCase()
|
cloneCase()
|
||||||
{
|
{
|
||||||
if [ -e "$2" ]
|
local src=$1
|
||||||
|
local dst=$2
|
||||||
|
shift 2
|
||||||
|
|
||||||
|
if [ -e "$dst" ]
|
||||||
then
|
then
|
||||||
echo "Case already cloned: remove case directory $2 to clone"
|
echo "Case already cloned: remove case directory $dst prior to cloning"
|
||||||
elif [ -d "$1" ]
|
return 1
|
||||||
|
elif [ ! -d "$src" ]
|
||||||
then
|
then
|
||||||
echo "Cloning $2 case from $1"
|
echo "Error: no directory to clone: $src"
|
||||||
mkdir $2
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Cloning $dst case from $src"
|
||||||
|
mkdir $dst
|
||||||
# These must exist, so do not hide error messages
|
# These must exist, so do not hide error messages
|
||||||
for f in system constant
|
for f in constant system
|
||||||
do
|
do
|
||||||
\cp -r $1/$f $2
|
\cp -r $src/$f $dst
|
||||||
done
|
done
|
||||||
|
|
||||||
# Either (or both) may exist, so error messages may be spurious
|
# Either (or both) may exist, so error messages may be spurious
|
||||||
for f in 0 0.orig
|
for f in 0 0.orig
|
||||||
do
|
do
|
||||||
\cp -r $1/$f $2 2>/dev/null
|
\cp -r $src/$f $dst 2>/dev/null
|
||||||
done
|
done
|
||||||
else
|
return 0
|
||||||
echo "Error: cannot clone from non-existent directory"
|
}
|
||||||
echo " $1"
|
|
||||||
|
#
|
||||||
|
# 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
|
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
|
||||||
|
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
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Overwrite 0/ with the contents of 0.orig/ if it exists.
|
# Overwrite 0/ with the contents of 0.orig/ if it exists.
|
||||||
|
|||||||
@ -1,27 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
cd ${0%/*} || exit 1 # Run from this directory
|
cd ${0%/*} || exit 1 # Run from this directory
|
||||||
|
|
||||||
# Source tutorial run functions
|
|
||||||
. $WM_PROJECT_DIR/bin/tools/RunFunctions
|
. $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
|
# Do the Spalart-Allmaras steady-state case
|
||||||
(cd motorBike && foamRunTutorials)
|
(cd motorBike && foamRunTutorials)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user