ENH: generalise bump2D Allrun and plot scripts

STYLE: renamed periodicHill createPlots -> plot for consistency

TUT: use nutLowReWallFunction for bump2D

- required for the new nutWallFuncs hierarchy
This commit is contained in:
Kutalmis Bercin
2019-11-01 16:08:24 +00:00
committed by Andrew Heather
parent d13df0e4da
commit 5577606997
7 changed files with 162 additions and 113 deletions

View File

@ -44,7 +44,7 @@ boundaryField
bump
{
type fixedValue;
type nutLowReWallFunction;
value uniform 0;
}

View File

@ -1,9 +1,46 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions
. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions
runApplication blockMesh
runApplication $(getApplication)
# Turbulence closure models
models="
kOmegaSST
SpalartAllmaras
"
for model in $models
do
echo "Processing model: $model"
\cp constant/turbulenceProperties.template constant/turbulenceProperties
runApplication -s "$model" foamDictionary -entry RAS.RASModel \
-set "$model" constant/turbulenceProperties
runApplication $(getApplication)
timeDir=$(foamListTimes -latestTime)
# Create datasets for benchmark comparisons
echo "# ccx tau_xx tau_yy tau_zz cp" > profiles.dat
foamDictionary -entry boundaryField.bump.value -value $timeDir/Cx | \
sed -n '/(/,/)/p' | sed -e 's/[()]//g;/^\s*$/d' > Cx.$$
foamDictionary -entry boundaryField.bump.value -value $timeDir/wallShearStress | \
sed -n '/(/,/)/p' | sed -e 's/[()]//g;/^\s*$/d' > tau.$$
foamDictionary -entry boundaryField.bump.value -value $timeDir/Cp | \
sed -n '/(/,/)/p' | sed -e 's/[()]//g;/^\s*$/d' > cp.$$
\paste -d ' ' Cx.$$ tau.$$ cp.$$ >> profiles.dat
\rm -f Cx.$$ tau.$$ cp.$$
# Store model results
modelDir="$model"
\rm -rf "$modelDir"
\mkdir "$modelDir"
\mv log* profiles.dat "$timeDir" postProcessing "$modelDir"
cleanTimeDirectories
done
#------------------------------------------------------------------------------

View File

@ -19,11 +19,8 @@ simulationType RAS;
RAS
{
// RASModel kOmegaSST;
RASModel SpalartAllmaras;
RASModel TURB_MODE;
turbulence on;
printCoeffs on;
}

View File

@ -1,106 +0,0 @@
#!/bin/sh
# Note: CFL3D data available from:
# https://turbmodels.larc.nasa.gov/bump_sa.html
cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions
#set -x
plotTau() {
graphNameTau="hill2D_tau.png"
echo "Creating wallshear stress graph to $graphNameTau"
gnuplot<<PLT_TAU
set terminal pngcairo font "helvetica,20" size 1000, 1000
set xrange [0:1.5]
set yrange [0:0.008]
set grid
set key bottom right
set xlabel "x"
set ylabel "c_f"
set output "$graphNameTau"
Uref = 69.44
set lmargin 10
set rmargin 1.5
set bmargin 3.2
# plot \
# "profiles.dat" u 1:(sqrt(\$2*\$2+\$3*\$3+\$4*\$4)/(0.5*Uref*Uref)) \
# t "simpleFoam" w l lw 2 lc rgb "black", \
# "cf_bump_cfl3d_sa.dat" every 10 u 1:2 \
# t "CFL3D" w p ps 3 pt 6 lw 2 lc rgb "red"
plot \
"profiles.dat" u 1:(sqrt(\$2*\$2+\$3*\$3+\$4*\$4)/(0.5*Uref*Uref)) \
t "simpleFoam" w l lw 2 lc rgb "black"
PLT_TAU
}
plotCp() {
graphNameCp="hill2D_cp.png"
echo "Creating pressure coefficient graph to $graphNameCp"
gnuplot<<PLT_CP
set terminal pngcairo font "helvetica,20" size 1000, 1000
set xrange [0:1.5]
set yrange [0.4:-0.8]
set grid
set key bottom right
set xlabel "x"
set ylabel "c_p"
set output "$graphNameCp"
Uref = 69.44
set lmargin 10
set rmargin 1.5
set bmargin 3.2
# plot \
# "profiles.dat" u 1:5 \
# t "simpleFoam" w l lw 2 lc rgb "black", \
# "cp_bump_cfl3d_sa.dat" every 10 u 1:2 \
# t "CFL3D" w p ps 3 pt 6 lw 2 lc rgb "red"
plot \
"profiles.dat" u 1:5 \
t "simpleFoam" w l lw 2 lc rgb "black"
PLT_CP
}
if notTest $@
then
# Create validation plots
# Test if gnuplot exists on the system
command -v gnuplot >/dev/null 2>&1 || {
echo "gnuplot not found - skipping graph creation" 1>&2
exit 1
}
# Test if awk exists on the system
command -v awk >/dev/null 2>&1 || {
echo "awk not found - skipping graph creation" 1>&2
exit 1
}
timeDir=$(foamListTimes -latestTime)
echo "# ccx tau_xx tau_yy tau_zz cp" > profiles.dat
foamDictionary -entry boundaryField.bump.value -value $timeDir/Cx | \
sed -n '/(/,/)/p' | sed -e 's/[()]//g;/^\s*$/d' > Cx.$$
foamDictionary -entry boundaryField.bump.value -value $timeDir/wallShearStress | \
sed -n '/(/,/)/p' | sed -e 's/[()]//g;/^\s*$/d' > tau.$$
foamDictionary -entry boundaryField.bump.value -value $timeDir/Cp | \
sed -n '/(/,/)/p' | sed -e 's/[()]//g;/^\s*$/d' > cp.$$
paste -d ' ' Cx.$$ tau.$$ cp.$$ >> profiles.dat
plotTau
plotCp
\rm -f Cx.$$ tau.$$ cp.$$ profiles.dat
fi
# ------------------------------------------------------------------------------

View File

@ -0,0 +1,121 @@
#!/bin/sh
# Note: CFL3D data available from:
# https://turbmodels.larc.nasa.gov/bump_sa.html
# The CFL3D-SpalartAllmaras datasets of Cf and Cp:
# Cf = https://turbmodels.larc.nasa.gov/Bump/SA/cf_bump.dat
# Cp = https://turbmodels.larc.nasa.gov/Bump/SA/cp_bump.dat
cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions
plotCf() {
declare -a resultSet=("${!1}")
declare -a modelSet=("${!2}")
graphNameCf="hill2D_cf.png"
echo "Creating skin friction coefficient graph to $graphNameCf"
gnuplot<<PLT_CF
set terminal pngcairo font "helvetica,20" size 1000, 1000
set xrange [0:1.5]
set yrange [0:0.008]
set grid
set key bottom right
set xlabel "x"
set ylabel "C_f" rotate by 0
set output "$graphNameCf"
results="${resultSet[*]}"
models="${modelSet[*]}"
Uref = 69.44
set lmargin 10
set rmargin 1.5
set bmargin 3.2
# plot \
# "cf_bump_cfl3d_sa.dat" every 10 u 1:2 t "CFL3D" \
# w p ps 3 pt 6 lw 2 lc rgb "red", \
# for [i=1:words(results)] word(results, i) \
# u 1:(sqrt(\$2*\$2+\$3*\$3+\$4*\$4)/(0.5*Uref*Uref)) \
# t word(models, i) with lines
plot \
for [i=1:words(results)] word(results, i) \
u 1:(sqrt(\$2*\$2+\$3*\$3+\$4*\$4)/(0.5*Uref*Uref)) \
t word(models, i) with lines
PLT_CF
}
plotCp() {
declare -a resultSet=("${!1}")
declare -a modelSet=("${!2}")
graphNameCp="hill2D_cp.png"
echo "Creating pressure coefficient graph to $graphNameCp"
gnuplot<<PLT_CP
set terminal pngcairo font "helvetica,20" size 1000, 1000
set xrange [0:1.5]
set yrange [0.4:-0.8]
set grid
set key bottom right
set xlabel "x"
set ylabel "C_p" rotate by 0
set output "$graphNameCp"
results="${resultSet[@]}"
models="${modelSet[@]}"
Uref = 69.44
set lmargin 10
set rmargin 1.5
set bmargin 3.2
# plot \
# "cp_bump_cfl3d_sa.dat" every 10 u 1:2 t "CFL3D" \
# w p ps 3 pt 6 lw 2 lc rgb "red", \
# for [i=1:words(results)] word(results, i) \
# u (\$1):(\$5) t word(models, i) with lines
plot \
for [i=1:words(results)] word(results, i) \
u (\$1):(\$5) t word(models, i) with lines
PLT_CP
}
if notTest $@
then
# Create validation plots
# Test if gnuplot exists on the system
command -v gnuplot >/dev/null 2>&1 || {
echo "gnuplot not found - skipping graph creation" 1>&2
exit 1
}
# Test if awk exists on the system
command -v awk >/dev/null 2>&1 || {
echo "awk not found - skipping graph creation" 1>&2
exit 1
}
# Turbulence closure models
models=('kOmegaSST' 'kEpsilon')
modelResults=()
n=0
for model in "${models[@]}"
do
modelResults[$n]="${model}/profiles.dat"
n=$(($n+1))
done
plotCp modelResults[@] models[@]
plotCf modelResults[@] models[@]
fi
# ------------------------------------------------------------------------------