diff --git a/tutorials/verificationAndValidation/turbulentInflow/0.orig/U b/tutorials/verificationAndValidation/turbulentInflow/0.orig/U index f7079db8c0..fe54da5e4b 100644 --- a/tutorials/verificationAndValidation/turbulentInflow/0.orig/U +++ b/tutorials/verificationAndValidation/turbulentInflow/0.orig/U @@ -31,11 +31,11 @@ boundaryField type fixedValue; value uniform (0 0 0); } - sides_half0 + left { type cyclic; } - sides_half1 + right { type cyclic; } diff --git a/tutorials/verificationAndValidation/turbulentInflow/0.orig/nut b/tutorials/verificationAndValidation/turbulentInflow/0.orig/nut index 2496e7ae86..82a1e2456b 100644 --- a/tutorials/verificationAndValidation/turbulentInflow/0.orig/nut +++ b/tutorials/verificationAndValidation/turbulentInflow/0.orig/nut @@ -29,11 +29,11 @@ boundaryField { type zeroGradient; } - sides_half0 + left { type cyclic; } - sides_half1 + right { type cyclic; } diff --git a/tutorials/verificationAndValidation/turbulentInflow/0.orig/p b/tutorials/verificationAndValidation/turbulentInflow/0.orig/p index 73a85d2823..f2c9b2c25d 100644 --- a/tutorials/verificationAndValidation/turbulentInflow/0.orig/p +++ b/tutorials/verificationAndValidation/turbulentInflow/0.orig/p @@ -29,11 +29,11 @@ boundaryField { type zeroGradient; } - sides_half0 + left { type cyclic; } - sides_half1 + right { type cyclic; } diff --git a/tutorials/verificationAndValidation/turbulentInflow/Allclean b/tutorials/verificationAndValidation/turbulentInflow/Allclean index 0a6c7b2a83..2538225cb4 100755 --- a/tutorials/verificationAndValidation/turbulentInflow/Allclean +++ b/tutorials/verificationAndValidation/turbulentInflow/Allclean @@ -4,7 +4,6 @@ cd ${0%/*} || exit 1 # Run from this directory #------------------------------------------------------------------------------ cleanCase0 -rm -rf constant/boundaryData/inlet -rm -rf results +\rm -rf system/controlDict constant/boundaryData/inlet results #------------------------------------------------------------------------------ diff --git a/tutorials/verificationAndValidation/turbulentInflow/Allrun b/tutorials/verificationAndValidation/turbulentInflow/Allrun index 8a23f43d5f..ad7ceae124 100755 --- a/tutorials/verificationAndValidation/turbulentInflow/Allrun +++ b/tutorials/verificationAndValidation/turbulentInflow/Allrun @@ -4,31 +4,92 @@ cd ${0%/*} || exit 1 # Run from this directory . ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions # Tutorial clean functions #------------------------------------------------------------------------------ -# Test with different synthetic inflow models -modelTypes="reducedDigitalFilter digitalFilter DFSEM" +endTime=10 +\cp system/controlDict.template system/controlDict +if notTest $@ +then + endTime=85 +fi +\sed -i "s|END_TIME|$endTime|g" system/controlDict -runApplication blockMesh -restore0Dir -# Compute (serial) and collect data -for modelType in $modelTypes -do - echo - echo "Running with model: $modelType" - (cd 0 && ln -snf "inlet.$modelType" inlet) - (cd constant/boundaryData && ln -snf "inlet.$modelType" inlet) - - runApplication -s "$modelType" pimpleFoam - ./createGraphs - - # Collect data in 'results' directory - results="results/$modelType" - echo "Placing summary in $results" - mkdir -p "$results" - mv -f log.* *.png postProcessing "$results" 2>/dev/null +# Collect data into the 'results' directory, +# and clean the case for the next run +# +# $1 = model +# ---- +collectData(){ + model=$1 + \echo " Moving results into 'results/$model'" + results="results/$model" + \mkdir -p "$results" + timeDir=$(foamListTimes -latestTime) + \mv -f log* *.png postProcessing "$timeDir" "$results" 2>/dev/null cleanTimeDirectories - rm -rf processor* -done + \rm -rf processor* > /dev/null 2>&1 +} + + +# Compute the case in 'serial' mode, +# and collect the data +# +# $* = models +# ---- +serialRun(){ + models=$* + for model in $models + do + \echo " Running with the synthetic turbulence model: $model" + (\cd 0 && \ln -snf "inlet.$model" inlet) + (\cd constant/boundaryData && \ln -snf "inlet.$model" inlet) + + runApplication -s "$model" $(getApplication) + ./plot + collectData $model + done +} + + +# Compute the case in 'parallel' mode, +# and collect the data +# +# $* = models +# ---- +parallelRun(){ + models=$* + for model in $models + do + \echo " Running with the synthetic turbulence model: $model" + (\cd 0 && \ln -snf "inlet.$model" inlet) + (\cd constant/boundaryData && \ln -snf "inlet.$model" inlet) + + runApplication -s "$model" decomposePar + runParallel -s "$model" $(getApplication) + ./plot + + collectData $model + done +} + + +#------------------------------------------------------------------------------ + +# Synthetic inflow models +models=" +reducedDigitalFilter +digitalFilter +DFSEM +" + +# Prepare the numerical setup +runApplication blockMesh +restore0Dir +\rm -rf "results" + +# Run with the synthetic turbulence models +serialRun $models +#parallelRun $models + #------------------------------------------------------------------------------ diff --git a/tutorials/verificationAndValidation/turbulentInflow/Allrun-parallel b/tutorials/verificationAndValidation/turbulentInflow/Allrun-parallel deleted file mode 100755 index c3584e519d..0000000000 --- a/tutorials/verificationAndValidation/turbulentInflow/Allrun-parallel +++ /dev/null @@ -1,35 +0,0 @@ -#!/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 -#------------------------------------------------------------------------------ - -# Test with different synthetic inflow models -modelTypes="reducedDigitalFilter digitalFilter DFSEM" - -runApplication blockMesh -restore0Dir - -# Compute (parallel) and collect data -for modelType in $modelTypes -do - echo - echo "Running with model: $modelType" - (cd 0 && ln -snf "inlet.$modelType" inlet) - (cd constant/boundaryData && ln -snf "inlet.$modelType" inlet) - - runApplication -s "$modelType" decomposePar - runParallel -s "$modelType" pimpleFoam - ./createGraphs - - # Collect data in 'results' directory - results="results/$modelType" - echo "Placing summary in $results" - mkdir -p "$results" - mv -f log.* *.png postProcessing "$results" 2>/dev/null - - cleanTimeDirectories - rm -rf processor* -done - -#------------------------------------------------------------------------------ diff --git a/tutorials/verificationAndValidation/turbulentInflow/README b/tutorials/verificationAndValidation/turbulentInflow/README index e7d02e3af7..d17226d0b4 100644 --- a/tutorials/verificationAndValidation/turbulentInflow/README +++ b/tutorials/verificationAndValidation/turbulentInflow/README @@ -10,25 +10,25 @@ examined through a single-cell-domain smooth-wall plane channel flow setup: The input statistics are obtained from: - Moser, Kim & Mansour - "DNS of Turbulent Channel Flow up to Re_tau=590", - Physics of Fluids (1999) vol 11, 943-945. - doi.org/10.1063/1.869966 + Moser, R. D., Kim, J., & Mansour, N. N. (1999). + Direct numerical simulation of turbulent channel flow up to Reτ=590. + Physics of fluids, 11(4), 943-945. + DOI:10.1063/1.869966 -from which the input first-/second-order turbulence statistics data for the -smooth-wall plane channel flow at Re=395 were used. +from which the input first-/second-order turbulence statistics data for the +smooth-wall plane channel flow at ReTau=395 were used. The data is available online from (Retrieved: 21-06-2019): - http://turbulence.ices.utexas.edu/MKM_1999.html + https://turbulence.oden.utexas.edu/data/MKM/chan395/ -Serial executing: +Serial executing (comment out 'parallelRun'): ./Allrun -Parallel (decompositionMethod=scotch) executing: +Parallel (decompositionMethod=scotch) executing (comment out 'serialRun'): -./Allrunparallel +./Allrun -Both scripts run the test case, and collect the OpenFOAM samples, and plots into -the 'results' directory. +The script will run the test case, and collect the plots and samples into +the 'results' directory. diff --git a/tutorials/verificationAndValidation/turbulentInflow/constant/transportProperties b/tutorials/verificationAndValidation/turbulentInflow/constant/transportProperties index f97c34ebfc..f7675d512a 100644 --- a/tutorials/verificationAndValidation/turbulentInflow/constant/transportProperties +++ b/tutorials/verificationAndValidation/turbulentInflow/constant/transportProperties @@ -17,15 +17,12 @@ FoamFile transportModel Newtonian; -// Re_tau = u_tau L / nu -// Re_tau = 395 -// L = half channel height = 1 -// Ubulk/u_tau = 17.55 -// U_bulk = 17.55 -> u_tau = 1 -// -> nu = 1*1/395 = 2.532e-3 - -nu nu [ 0 2 -1 0 0 0 0 ] 2.532e-3; +// ReTau = uTau delta / nuFluid +// ReTau = 395 [-] +// delta = half channel height = 1 [m] +// -> nuFluid = 1*1/395 = 2.532e-3 [m2/s] +nu 2.532e-3; // ************************************************************************* // diff --git a/tutorials/verificationAndValidation/turbulentInflow/constant/turbulenceProperties b/tutorials/verificationAndValidation/turbulentInflow/constant/turbulenceProperties index ded27993b6..33b9f662ec 100644 --- a/tutorials/verificationAndValidation/turbulentInflow/constant/turbulenceProperties +++ b/tutorials/verificationAndValidation/turbulentInflow/constant/turbulenceProperties @@ -19,19 +19,14 @@ simulationType LES; LES { - turbulence on; - LESModel Smagorinsky; SmagorinskyCoeffs { - Ce 1.05; - Ck 0.0266; // Updated to give Cs = 0.065 + Ce 1.048; + Ck 0.02654; // Updated to give Cs = 0.065 } - printCoeffs on; - delta vanDriest; - vanDriestCoeffs { delta cubeRootVol; @@ -42,6 +37,9 @@ LES Aplus 26; Cdelta 0.158; } + + printCoeffs on; + turbulence on; } diff --git a/tutorials/verificationAndValidation/turbulentInflow/createGraphs b/tutorials/verificationAndValidation/turbulentInflow/createGraphs deleted file mode 100755 index 7ef92f3cb5..0000000000 --- a/tutorials/verificationAndValidation/turbulentInflow/createGraphs +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Require gnuplot -command -v gnuplot >/dev/null || { - echo "gnuplot not found - skipping graph creation" 1>&2 - exit 1 -} - - -# The latestTime in postProcessing/inletSampling -timeDir=$(foamListTimes -case postProcessing/inletSampling -latestTime 2>/dev/null) - -[ -n "$timeDir" ] || { - echo "No postProcessing/inletSampling found - skipping graph creation" 1>&2 - exit 2 -} - -timeDir="postProcessing/inletSampling/$timeDir" - -echo "Creating graphs" - -gnuplot<" - -set offset .05, .05 -set style data linespoints - -set grid -set linetype 1 lc rgb 'black' lw 2 -set linetype 2 lc rgb 'red' lw 2 -set linetype 3 lc rgb 'blue' lw 2 -set linetype 4 lc rgb 'green' lw 2 -set linetype 5 lc rgb 'black' pi -8 pt 4 ps 1.5 -set linetype 6 lc rgb 'red' pi -8 pt 4 ps 1.5 -set linetype 7 lc rgb 'blue' pi -8 pt 4 ps 1.5 -set linetype 8 lc rgb 'green' pi -8 pt 4 ps 1.5 - - -set title "Stress in cell" -input = "$timeDir/inletCell_UPrime2Mean.xy" -set output 'stress-cell.png' -plot \ - input u 1:2 w lines t "" lt 1, \ - input u 1:5 w lines t "" lt 2, \ - input u 1:7 w lines t "" lt 3, \ - input u 1:3 w lines t "" lt 4 - - -set title "Stress on patch" -input = "$timeDir/inletPatch_UPrime2Mean.xy" -set output 'stress-patch.png' -plot \ - input u 1:2 w lines t "" lt 1, \ - input u 1:5 w lines t "" lt 2, \ - input u 1:7 w lines t "" lt 3, \ - input u 1:3 w lines t "" lt 4 - -GNUPLOT - -#------------------------------------------------------------------------------ diff --git a/tutorials/verificationAndValidation/turbulentInflow/plot b/tutorials/verificationAndValidation/turbulentInflow/plot new file mode 100755 index 0000000000..066dfeae7b --- /dev/null +++ b/tutorials/verificationAndValidation/turbulentInflow/plot @@ -0,0 +1,73 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory +#------------------------------------------------------------------------------ + +plotStresses() { + timeDir=$1 + \echo " Plotting the normal and Reynolds stresses" + + gnuplot<" + set offset .05, .05 + + set style data linespoints + set linetype 1 lc rgb 'black' lw 2 + set linetype 2 lc rgb 'red' lw 2 + set linetype 3 lc rgb 'blue' lw 2 + set linetype 4 lc rgb 'green' lw 2 + set linetype 5 lc rgb 'black' pi -8 pt 4 ps 1.5 + set linetype 6 lc rgb 'red' pi -8 pt 4 ps 1.5 + set linetype 7 lc rgb 'blue' pi -8 pt 4 ps 1.5 + set linetype 8 lc rgb 'green' pi -8 pt 4 ps 1.5 + + set title "Normal and Reynolds stresses on cell" + input="$timeDir/inletCell_UPrime2Mean.xy" + set output 'stress-cell.png' + plot \ + input u 1:2 w lines t "" lt 1, \ + input u 1:5 w lines t "" lt 2, \ + input u 1:7 w lines t "" lt 3, \ + input u 1:3 w lines t "" lt 4 + + set title "Normal and Reynolds stresses on patch" + input = "$timeDir/inletPatch_UPrime2Mean.xy" + set output 'stress-patch.png' + plot \ + input u 1:2 w lines t "" lt 1, \ + input u 1:5 w lines t "" lt 2, \ + input u 1:7 w lines t "" lt 3, \ + input u 1:3 w lines t "" lt 4 + +PLT_STRESSES +} + + +#------------------------------------------------------------------------------ + +# Require gnuplot +command -v gnuplot >/dev/null || { + \echo "gnuplot not found - skipping graph creation" 1>&2 + \exit 1 +} + + +# The latestTime in postProcessing/inletSampling +timeDir=$(foamListTimes -case postProcessing/inletSampling -latestTime 2>/dev/null) + +[ -n "$timeDir" ] || { + \echo "No postProcessing/inletSampling found - skipping graph creation" 1>&2 + \exit 2 +} + +timeDir="postProcessing/inletSampling/$timeDir" + +plotStresses "$timeDir" + + +#------------------------------------------------------------------------------ diff --git a/tutorials/verificationAndValidation/turbulentInflow/system/blockMeshDict b/tutorials/verificationAndValidation/turbulentInflow/system/blockMeshDict index bd41cd7ade..dc4e6b1e67 100644 --- a/tutorials/verificationAndValidation/turbulentInflow/system/blockMeshDict +++ b/tutorials/verificationAndValidation/turbulentInflow/system/blockMeshDict @@ -60,16 +60,16 @@ boundary type wall; faces ((4 3 9 10)); } - sides_half0 + left { type cyclic; - neighbourPatch sides_half1; + neighbourPatch right; faces ((1 2 5 0)(2 3 4 5)); } - sides_half1 + right { type cyclic; - neighbourPatch sides_half0; + neighbourPatch left; faces ((6 11 8 7)(11 10 9 8)); } inlet diff --git a/tutorials/verificationAndValidation/turbulentInflow/system/controlDict b/tutorials/verificationAndValidation/turbulentInflow/system/controlDict.template similarity index 90% rename from tutorials/verificationAndValidation/turbulentInflow/system/controlDict rename to tutorials/verificationAndValidation/turbulentInflow/system/controlDict.template index 398af336cf..dd21ffb068 100644 --- a/tutorials/verificationAndValidation/turbulentInflow/system/controlDict +++ b/tutorials/verificationAndValidation/turbulentInflow/system/controlDict.template @@ -23,7 +23,7 @@ startTime 0; stopAt endTime; -endTime 85; +endTime END_TIME; deltaT 4e-3; @@ -31,7 +31,7 @@ writeControl timeStep; writeInterval 1250; -purgeWrite 0; +purgeWrite 3; writeFormat ascii; @@ -47,11 +47,12 @@ runTimeModifiable false; adjustTimeStep false; -// Allow 10% run-up before calculating mean +// Allow 10% of time for initialisation before sampling timeStart #eval #{ 0.1 * ${/endTime} #}; functions { + #include "fieldAverage" #include "sampling" } diff --git a/tutorials/verificationAndValidation/turbulentInflow/system/decomposeParDict b/tutorials/verificationAndValidation/turbulentInflow/system/decomposeParDict index acac6ac758..0120736b01 100644 --- a/tutorials/verificationAndValidation/turbulentInflow/system/decomposeParDict +++ b/tutorials/verificationAndValidation/turbulentInflow/system/decomposeParDict @@ -15,7 +15,7 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -numberOfSubdomains 6; +numberOfSubdomains 3; method scotch; diff --git a/tutorials/verificationAndValidation/turbulentInflow/system/fieldAverage b/tutorials/verificationAndValidation/turbulentInflow/system/fieldAverage new file mode 100644 index 0000000000..b794f43dbf --- /dev/null +++ b/tutorials/verificationAndValidation/turbulentInflow/system/fieldAverage @@ -0,0 +1,36 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fieldAverage; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +fieldAverage1 +{ + type fieldAverage; + libs (fieldFunctionObjects); + writeControl writeTime; + timeStart $/timeStart; + + fields + ( + U + { + mean on; + prime2Mean on; + base time; + } + ); +} + +// ************************************************************************* // diff --git a/tutorials/verificationAndValidation/turbulentInflow/system/sampling b/tutorials/verificationAndValidation/turbulentInflow/system/sampling index 1f75e54e79..02a2e19627 100644 --- a/tutorials/verificationAndValidation/turbulentInflow/system/sampling +++ b/tutorials/verificationAndValidation/turbulentInflow/system/sampling @@ -15,25 +15,6 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -fieldAverage1 -{ - type fieldAverage; - libs (fieldFunctionObjects); - writeControl writeTime; - timeStart $/timeStart; - - fields - ( - U - { - mean on; - prime2Mean on; - base time; - } - ); -} - - inletSampling { type sets; @@ -56,7 +37,7 @@ inletSampling } inletCell { - type face; + type midPoint; axis y; start (0.062832 0 1.57); end (0.062832 2 1.57);