openfoam/tutorials/incompressible/simpleFoam/turbulentFlatPlate/Allrun
Kutalmis Bercin 408e6b55e9 TUT: simplify setups.orig cases
DOC: Curle: fix typo in header file (fixes #2498)

TUT: airfoil2D: apply standard freestream conditions for nuTilda and nut
2022-06-08 13:53:01 +01:00

208 lines
5.3 KiB
Bash
Executable File

#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
#------------------------------------------------------------------------------
# settings
# operand setups
setups="
kOmegaSST
kEpsilon
"
# flag to enable computations
run=true
# flag to enable computations in parallel mode
parallel=true
# flag to enable to use a common mesh
common_mesh=true
# flag to enable to use a common dynamic code
common_dynamic_code=true
# operand setups for the wall-normal height of the first-cell centre
declare -A grading_vs_yp
#level 5 gradings
grading_vs_yp[0.05]=50000
grading_vs_yp[1]=2200
grading_vs_yp[2]=950
grading_vs_yp[5]=300
grading_vs_yp[10]=130
grading_vs_yp[30]=30
grading_vs_yp[50]=15
grading_vs_yp[100]=5
# level 3 gradings
#grading_vs_yp[1]=9300
#grading_vs_yp[2]=4300
#grading_vs_yp[5]=1500
#grading_vs_yp[10]=650
#grading_vs_yp[30]=175
#grading_vs_yp[50]=90
#grading_vs_yp[100]=35
#------------------------------------------------------------------------------
#######################################
# Create the given setup
# Arguments:
# $1 = Path to create the setup
# Outputs:
# Writes info to stdout
#######################################
dry_run_setup() {
[ $# -eq 0 ] && { echo "Usage error: $0"; exit 1; }
setup="$1"
yp="$2"
dirSetup="setups/$setup/$yp"
dirSetupOrig="setups.orig/$setup"
dirOrig="$dirSetupOrig/0.orig"
dirConstant="$dirSetupOrig/constant"
dirSystem="$dirSetupOrig/system"
printf "\n# Create the setup: %s %s\n" "$setup" yPlus-"$yp"
if [ ! -d "$dirSetup" ]
then
mkdir -p "$dirSetup"
cp -aRfL "setups.orig/common/." "$dirSetup"
cp -afL "$dirSetupOrig"/All* "$dirSetup" 2>/dev/null || :
[ -d "$dirOrig" ] && cp -aRfL "$dirOrig/." "$dirSetup/0.orig"
[ -d "$dirConstant" ] && cp -aRfL "$dirConstant/." "$dirSetup/constant"
[ -d "$dirSystem" ] && cp -aRfL "$dirSystem/." "$dirSetup/system"
else
printf "\n # Directory %s already exists\n" "$dirSetup"
printf " # Skipping the creation of a new setup\n"
fi
}
#######################################
# Run the given setup
# Arguments:
# $1 = Path to the setup to run
# Outputs:
# Writes info to stdout
#######################################
run_setup() {
[ $# -eq 0 ] && { echo "Usage error: $0"; exit 1; }
setup="$1"
yp="$2"
dirSetup="setups/$setup/$yp"
dirResult="results/$setup/$yp"
dry_run_setup "$setup" "$yp"
[ -d results ] || mkdir -p results
[ -d results/"$setup" ] || mkdir -p results/"$setup"
printf "\n# Run the setup: %s %s\n\n" "$setup" yPlus-"$yp"
if [ ! -d "$dirResult" ]
then
cp -Rf "$dirSetup" "$dirResult"
if [ "$common_mesh" = true ]
then
if [ -d results/mesh ]
then
printf "## Copy the common mesh to the setup: %s\n\n" "$setup"
cp -Rf results/mesh/polyMesh "$dirResult"/constant/.
fi
fi
if [ "$common_dynamic_code" = true ]
then
if [ -d results/dynamicCode ]
then
printf "## Copy the common dynamic code to the setup: %s\n\n" "$setup"
cp -Rf results/dynamicCode "$dirResult"/.
fi
fi
if [ "$parallel" = true ]
then
( cd "$dirResult" && ./Allrun-parallel )
else
( cd "$dirResult" && ./Allrun )
fi
if [ "$common_mesh" = true ]
then
if [ ! -d results/mesh ]
then
printf "\n## Store the mesh of %s as the common mesh\n\n" "$setup"
mkdir -p results/mesh
cp -Rf "$dirResult"/constant/polyMesh results/mesh/.
fi
fi
if [ "$common_dynamic_code" = true ]
then
if [ ! -d results/dynamicCode ] && [ -d "$dirResult"/dynamicCode ]
then
printf "\n## Store the dynamic code of %s as the common dynamic code\n\n" "$setup"
cp -Rf "$dirResult"/dynamicCode results/.
fi
fi
else
printf " # Directory %s already exists\n" "$dirResult"
printf " # Skipping the computation of the given setup\n"
fi
}
#------------------------------------------------------------------------------
for i in "${!grading_vs_yp[@]}"
do
yp=$i
grading=${grading_vs_yp[$yp]}
sed "s/GRADING/$grading/g" \
setups.orig/common/system/blockMeshDict.template > \
setups.orig/common/system/blockMeshDict
for setup in $setups
do
dirSetupOrig="setups.orig/$setup"
if [ ! -d "$dirSetupOrig" ]
then
echo "Setup directory: $dirSetupOrig" \
"could not be found - skipping execution" 1>&2
continue
fi
if [ "$run" = true ]
then
run_setup "$setup" "$yp"
else
dry_run_setup "$setup" "$yp"
fi
done
rm -Rf results/mesh
done
if notTest "$@" && [ "$run" = true ]
then
./plot
fi
#------------------------------------------------------------------------------