Skip to content
Snippets Groups Projects
Commit 501ad5a6 authored by Andrew Heather's avatar Andrew Heather
Browse files

ENH: Tutorial script update

parent 38e40ffb
Branches
Tags
No related merge requests found
......@@ -6,28 +6,24 @@ cd ${0%/*} || exit 1 # run from this directory
eulerianCase=../eulerianInjection
checkPrecursorCase() {
if [ ! -f ${1}/system/controlDict ]
then
echo "Error: unable to find precursor Eulerian case $eulerianCase"
exit 1
fi
}
copyLagrangianData() {
copyLagrangianData()
{
dir=$1
latestTime=$(\cd $dir && foamListTimes -latestTime)
if [ ! "$latestTime" ]
if [ -z $latestTime ]
then
# Try a processor directory
latestTime=$(\cd $dir && foamListTimes -latestTime -processor)
if [ "$latestTime" ]
if [ -d $dir/processor0 ]
then
dir="${dir}/processor0"
# Try a processor directory
latestTime=$(\cd $dir && foamListTimes -latestTime -processor)
if [ -n $latestTime ]
then
dir="${dir}/processor0"
fi
fi
fi
if [ ! "$latestTime" ]
if [ -z $latestTime ]
then
echo "Error: unable to find Lagrangian data in case $eulerianCase"
exit 1
......@@ -35,13 +31,16 @@ copyLagrangianData() {
dir=$dir/${latestTime}/lagrangian
echo "Copying lagrangian data from $dir to 0 directory"
\cp -r $dir 0
if [ -d $dir ]
then
echo "Copying lagrangian data from $dir to 0 directory"
\cp -r $dir 0
else
echo "Error: unable to find Lagrangian data in case $dir"
fi
}
checkPrecursorCase ${eulerianCase}
restore0Dir;
copyLagrangianData ${eulerianCase}
......
......@@ -6,28 +6,24 @@ cd ${0%/*} || exit 1 # run from this directory
eulerianCase=../eulerianInjection
checkPrecursorCase() {
if [ ! -f ${1}/system/controlDict ]
then
echo "Error: unable to find precursor Eulerian case $eulerianCase"
exit 1
fi
}
copyLagrangianData() {
copyLagrangianData()
{
dir=$1
latestTime=$(\cd $dir && foamListTimes -latestTime)
if [ ! "$latestTime" ]
if [ -z $latestTime ]
then
# Try a processor directory
latestTime=$(\cd $dir && foamListTimes -latestTime -processor)
if [ "$latestTime" ]
if [ -d $dir/processor0 ]
then
dir="${dir}/processor0"
# Try a processor directory
latestTime=$(\cd $dir && foamListTimes -latestTime -processor)
if [ -n $latestTime ]
then
dir="${dir}/processor0"
fi
fi
fi
if [ ! "$latestTime" ]
if [ -z $latestTime ]
then
echo "Error: unable to find Lagrangian data in case $eulerianCase"
exit 1
......@@ -35,13 +31,16 @@ copyLagrangianData() {
dir=$dir/${latestTime}/lagrangian
echo "Copying lagrangian data from $dir to 0 directory"
\cp -r $dir 0
if [ -d $dir ]
then
echo "Copying lagrangian data from $dir to 0 directory"
\cp -r $dir 0
else
echo "Error: unable to find Lagrangian data in case $dir"
fi
}
checkPrecursorCase ${eulerianCase}
restore0Dir;
copyLagrangianData ${eulerianCase}
......
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