From 55776069975061c488a6294a5e81a7a92b04db45 Mon Sep 17 00:00:00 2001 From: Kutalmis Bercin Date: Fri, 1 Nov 2019 16:08:24 +0000 Subject: [PATCH] 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 --- .../transient/{createPlots => plot} | 0 .../incompressible/simpleFoam/bump2D/0/nut | 2 +- .../incompressible/simpleFoam/bump2D/Allclean | 2 +- .../incompressible/simpleFoam/bump2D/Allrun | 39 +++++- ...operties => turbulenceProperties.template} | 5 +- .../simpleFoam/bump2D/createPlots | 106 --------------- .../incompressible/simpleFoam/bump2D/plot | 121 ++++++++++++++++++ 7 files changed, 162 insertions(+), 113 deletions(-) rename tutorials/incompressible/pimpleFoam/LES/periodicHill/transient/{createPlots => plot} (100%) rename tutorials/incompressible/simpleFoam/bump2D/constant/{turbulenceProperties => turbulenceProperties.template} (92%) delete mode 100755 tutorials/incompressible/simpleFoam/bump2D/createPlots create mode 100755 tutorials/incompressible/simpleFoam/bump2D/plot diff --git a/tutorials/incompressible/pimpleFoam/LES/periodicHill/transient/createPlots b/tutorials/incompressible/pimpleFoam/LES/periodicHill/transient/plot similarity index 100% rename from tutorials/incompressible/pimpleFoam/LES/periodicHill/transient/createPlots rename to tutorials/incompressible/pimpleFoam/LES/periodicHill/transient/plot diff --git a/tutorials/incompressible/simpleFoam/bump2D/0/nut b/tutorials/incompressible/simpleFoam/bump2D/0/nut index b4932f4e39..d21f7dee12 100644 --- a/tutorials/incompressible/simpleFoam/bump2D/0/nut +++ b/tutorials/incompressible/simpleFoam/bump2D/0/nut @@ -44,7 +44,7 @@ boundaryField bump { - type fixedValue; + type nutLowReWallFunction; value uniform 0; } diff --git a/tutorials/incompressible/simpleFoam/bump2D/Allclean b/tutorials/incompressible/simpleFoam/bump2D/Allclean index d505d16807..9960709f40 100755 --- a/tutorials/incompressible/simpleFoam/bump2D/Allclean +++ b/tutorials/incompressible/simpleFoam/bump2D/Allclean @@ -3,6 +3,6 @@ cd ${0%/*} || exit 1 # Run from this directory . $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase -\rm -f *.png +\rm -f *.png #------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/simpleFoam/bump2D/Allrun b/tutorials/incompressible/simpleFoam/bump2D/Allrun index 61f1172ce8..7013a485b1 100755 --- a/tutorials/incompressible/simpleFoam/bump2D/Allrun +++ b/tutorials/incompressible/simpleFoam/bump2D/Allrun @@ -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 #------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/simpleFoam/bump2D/constant/turbulenceProperties b/tutorials/incompressible/simpleFoam/bump2D/constant/turbulenceProperties.template similarity index 92% rename from tutorials/incompressible/simpleFoam/bump2D/constant/turbulenceProperties rename to tutorials/incompressible/simpleFoam/bump2D/constant/turbulenceProperties.template index 1aba2bb1fd..0ac8b36c26 100644 --- a/tutorials/incompressible/simpleFoam/bump2D/constant/turbulenceProperties +++ b/tutorials/incompressible/simpleFoam/bump2D/constant/turbulenceProperties.template @@ -19,11 +19,8 @@ simulationType RAS; RAS { -// RASModel kOmegaSST; - RASModel SpalartAllmaras; - + RASModel TURB_MODE; turbulence on; - printCoeffs on; } diff --git a/tutorials/incompressible/simpleFoam/bump2D/createPlots b/tutorials/incompressible/simpleFoam/bump2D/createPlots deleted file mode 100755 index 31c08adc24..0000000000 --- a/tutorials/incompressible/simpleFoam/bump2D/createPlots +++ /dev/null @@ -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</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 - -# ------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/simpleFoam/bump2D/plot b/tutorials/incompressible/simpleFoam/bump2D/plot new file mode 100755 index 0000000000..a30f46d332 --- /dev/null +++ b/tutorials/incompressible/simpleFoam/bump2D/plot @@ -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</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 + +# ------------------------------------------------------------------------------