TUT: reorganise the scripts and dicts in turbulentInflow

This commit is contained in:
Kutalmis Bercin
2019-11-14 10:09:36 +00:00
committed by Andrew Heather
parent 87250cb770
commit 80681eeb2b
16 changed files with 231 additions and 187 deletions

View File

@ -31,11 +31,11 @@ boundaryField
type fixedValue; type fixedValue;
value uniform (0 0 0); value uniform (0 0 0);
} }
sides_half0 left
{ {
type cyclic; type cyclic;
} }
sides_half1 right
{ {
type cyclic; type cyclic;
} }

View File

@ -29,11 +29,11 @@ boundaryField
{ {
type zeroGradient; type zeroGradient;
} }
sides_half0 left
{ {
type cyclic; type cyclic;
} }
sides_half1 right
{ {
type cyclic; type cyclic;
} }

View File

@ -29,11 +29,11 @@ boundaryField
{ {
type zeroGradient; type zeroGradient;
} }
sides_half0 left
{ {
type cyclic; type cyclic;
} }
sides_half1 right
{ {
type cyclic; type cyclic;
} }

View File

@ -4,7 +4,6 @@ cd ${0%/*} || exit 1 # Run from this directory
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
cleanCase0 cleanCase0
rm -rf constant/boundaryData/inlet \rm -rf system/controlDict constant/boundaryData/inlet results
rm -rf results
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -4,31 +4,92 @@ cd ${0%/*} || exit 1 # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions # Tutorial clean functions . ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions # Tutorial clean functions
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Test with different synthetic inflow models endTime=10
modelTypes="reducedDigitalFilter digitalFilter DFSEM" \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 # Collect data into the 'results' directory,
for modelType in $modelTypes # and clean the case for the next run
do #
echo # $1 = model
echo "Running with model: $modelType" # ----
(cd 0 && ln -snf "inlet.$modelType" inlet) collectData(){
(cd constant/boundaryData && ln -snf "inlet.$modelType" inlet) model=$1
\echo " Moving results into 'results/$model'"
runApplication -s "$modelType" pimpleFoam results="results/$model"
./createGraphs \mkdir -p "$results"
timeDir=$(foamListTimes -latestTime)
# Collect data in 'results' directory \mv -f log* *.png postProcessing "$timeDir" "$results" 2>/dev/null
results="results/$modelType"
echo "Placing summary in $results"
mkdir -p "$results"
mv -f log.* *.png postProcessing "$results" 2>/dev/null
cleanTimeDirectories cleanTimeDirectories
rm -rf processor* \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 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
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -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
#------------------------------------------------------------------------------

View File

@ -10,25 +10,25 @@ examined through a single-cell-domain smooth-wall plane channel flow setup:
The input statistics are obtained from: The input statistics are obtained from:
Moser, Kim & Mansour Moser, R. D., Kim, J., & Mansour, N. N. (1999).
"DNS of Turbulent Channel Flow up to Re_tau=590", Direct numerical simulation of turbulent channel flow up to Reτ=590.
Physics of Fluids (1999) vol 11, 943-945. Physics of fluids, 11(4), 943-945.
doi.org/10.1063/1.869966 DOI:10.1063/1.869966
from which the input first-/second-order turbulence statistics data for the from which the input first-/second-order turbulence statistics data for the
smooth-wall plane channel flow at Re=395 were used. smooth-wall plane channel flow at ReTau=395 were used.
The data is available online from (Retrieved: 21-06-2019): 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 ./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 script will run the test case, and collect the plots and samples into
the 'results' directory. the 'results' directory.

View File

@ -17,15 +17,12 @@ FoamFile
transportModel Newtonian; transportModel Newtonian;
// Re_tau = u_tau L / nu // ReTau = uTau delta / nuFluid
// Re_tau = 395 // ReTau = 395 [-]
// L = half channel height = 1 // delta = half channel height = 1 [m]
// Ubulk/u_tau = 17.55 // -> nuFluid = 1*1/395 = 2.532e-3 [m2/s]
// 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;
nu 2.532e-3;
// ************************************************************************* // // ************************************************************************* //

View File

@ -19,19 +19,14 @@ simulationType LES;
LES LES
{ {
turbulence on;
LESModel Smagorinsky; LESModel Smagorinsky;
SmagorinskyCoeffs SmagorinskyCoeffs
{ {
Ce 1.05; Ce 1.048;
Ck 0.0266; // Updated to give Cs = 0.065 Ck 0.02654; // Updated to give Cs = 0.065
} }
printCoeffs on;
delta vanDriest; delta vanDriest;
vanDriestCoeffs vanDriestCoeffs
{ {
delta cubeRootVol; delta cubeRootVol;
@ -42,6 +37,9 @@ LES
Aplus 26; Aplus 26;
Cdelta 0.158; Cdelta 0.158;
} }
printCoeffs on;
turbulence on;
} }

View File

@ -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<<GNUPLOT
set terminal png size 1000,800 enhanced font "Helvetica,24"
set xrange [0:1]
set yrange [-1:8]
set xlabel "Channel height"
set ylabel "<u_i u_i>"
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 "<uu>" lt 1, \
input u 1:5 w lines t "<vv>" lt 2, \
input u 1:7 w lines t "<ww>" lt 3, \
input u 1:3 w lines t "<uv>" 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 "<uu>" lt 1, \
input u 1:5 w lines t "<vv>" lt 2, \
input u 1:7 w lines t "<ww>" lt 3, \
input u 1:3 w lines t "<uv>" lt 4
GNUPLOT
#------------------------------------------------------------------------------

View File

@ -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<<PLT_STRESSES
set terminal pngcairo font "helvetica,20" size 1000, 800
set xrange [0:1]
set yrange [-1:8]
set grid
set key top right
set xlabel "Channel height from the bottomWall [m]"
set ylabel "<u_i^' u_i^'>"
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 "<u^' u^'>" lt 1, \
input u 1:5 w lines t "<v^' v^'>" lt 2, \
input u 1:7 w lines t "<w^' w^'>" lt 3, \
input u 1:3 w lines t "<u^' v^'>" 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 "<u^' u^'>" lt 1, \
input u 1:5 w lines t "<v^' v^'>" lt 2, \
input u 1:7 w lines t "<w^' w^'>" lt 3, \
input u 1:3 w lines t "<u^' v^'>" 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"
#------------------------------------------------------------------------------

View File

@ -60,16 +60,16 @@ boundary
type wall; type wall;
faces ((4 3 9 10)); faces ((4 3 9 10));
} }
sides_half0 left
{ {
type cyclic; type cyclic;
neighbourPatch sides_half1; neighbourPatch right;
faces ((1 2 5 0)(2 3 4 5)); faces ((1 2 5 0)(2 3 4 5));
} }
sides_half1 right
{ {
type cyclic; type cyclic;
neighbourPatch sides_half0; neighbourPatch left;
faces ((6 11 8 7)(11 10 9 8)); faces ((6 11 8 7)(11 10 9 8));
} }
inlet inlet

View File

@ -23,7 +23,7 @@ startTime 0;
stopAt endTime; stopAt endTime;
endTime 85; endTime END_TIME;
deltaT 4e-3; deltaT 4e-3;
@ -31,7 +31,7 @@ writeControl timeStep;
writeInterval 1250; writeInterval 1250;
purgeWrite 0; purgeWrite 3;
writeFormat ascii; writeFormat ascii;
@ -47,11 +47,12 @@ runTimeModifiable false;
adjustTimeStep false; adjustTimeStep false;
// Allow 10% run-up before calculating mean // Allow 10% of time for initialisation before sampling
timeStart #eval #{ 0.1 * ${/endTime} #}; timeStart #eval #{ 0.1 * ${/endTime} #};
functions functions
{ {
#include "fieldAverage"
#include "sampling" #include "sampling"
} }

View File

@ -15,7 +15,7 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
numberOfSubdomains 6; numberOfSubdomains 3;
method scotch; method scotch;

View File

@ -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;
}
);
}
// ************************************************************************* //

View File

@ -15,25 +15,6 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
fieldAverage1
{
type fieldAverage;
libs (fieldFunctionObjects);
writeControl writeTime;
timeStart $/timeStart;
fields
(
U
{
mean on;
prime2Mean on;
base time;
}
);
}
inletSampling inletSampling
{ {
type sets; type sets;
@ -56,7 +37,7 @@ inletSampling
} }
inletCell inletCell
{ {
type face; type midPoint;
axis y; axis y;
start (0.062832 0 1.57); start (0.062832 0 1.57);
end (0.062832 2 1.57); end (0.062832 2 1.57);