Commit 79f9c3bb authored by Andrew Heather's avatar Andrew Heather
Browse files

TUT: Added new bump2D case

parent 485523ea
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1806 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (69.44 0 0);
boundaryField
{
inlet
{
type fixedValue;
value $internalField;
}
outlet
{
type inletOutlet;
inletValue uniform (0 0 0);
value $internalField;
}
top
{
type symmetryPlane;
}
"(symUp|symDown)"
{
type symmetryPlane;
}
bump
{
type noSlip;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1806 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object nuTilda;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -1 0 0 0 0];
internalField uniform 6.93e-5; // 3*nu_inf
boundaryField
{
inlet
{
type fixedValue;
value $internalField;
}
outlet
{
type inletOutlet;
inletValue $internalField;
value $internalField;
}
top
{
type symmetryPlane;
}
"(symUp|symDown)"
{
type symmetryPlane;
}
bump
{
type fixedValue;
value uniform 0;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1806 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object nut;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -1 0 0 0 0];
internalField uniform 4.86e-6;
boundaryField
{
inlet
{
type calculated;
value $internalField;
}
outlet
{
type calculated;
value $internalField;
}
top
{
type symmetryPlane;
}
"(symUp|symDown)"
{
type symmetryPlane;
}
bump
{
type fixedValue;
value uniform 0;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1806 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object omega;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [ 0 0 -1 0 0 0 0 ];
internalField uniform 5220.8;
boundaryField
{
inlet
{
type fixedValue;
value $internalField;
}
outlet
{
type inletOutlet;
inletValue $internalField;
value $internalField;
}
top
{
type symmetryPlane;
}
"(symUp|symDown)"
{
type symmetryPlane;
}
bump
{
type omegaWallFunction;
value $internalField;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1806 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 0;
boundaryField
{
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue;
value $internalField;
}
top
{
type symmetryPlane;
}
"(symUp|symDown)"
{
type symmetryPlane;
}
bump
{
type zeroGradient;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions
runApplication blockMesh
runApplication $(getApplication)
#------------------------------------------------------------------------------
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1806 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
transportModel Newtonian;
nu 2.31e-5;
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1806 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object turbulenceProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
simulationType RAS;
RAS
{
// RASModel kOmegaSST;
RASModel SpalartAllmaras;
turbulence on;
printCoeffs on;
}
// ************************************************************************* //
#!/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
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1806 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
scale 1;
vertices
(
( -25.0 0 1 ) // 0
( 0 0 1 ) // 1
( 0.3 0 1 ) // 2
( 1.2 0 1 ) // 3
( 1.5 0 1 ) // 4
( 26.5 0 1 ) // 5
( 26.5 5 1 ) // 6
( 1.5 5 1 ) // 7
( 1.2 5 1 ) // 8
( 0.3 5 1 ) // 9
( 0 5 1 ) // 10
( -25.0 5 1 ) // 11
( -25.0 0 -1 ) // 12
( 0 0 -1 ) // 13
( 0.3 0 -1 ) // 14
( 1.2 0 -1 ) // 15
( 1.5 0 -1 ) // 16
( 26.5 0 -1 ) // 17
( 26.5 5 -1 ) // 18
( 1.5 5 -1 ) // 19
( 1.2 5 -1 ) // 20
( 0.3 5 -1 ) // 21
( 0 5 -1 ) // 22
( -25.0 5 -1 ) // 23
);
blocks
(
// Medium level for tutorial
hex ( 0 1 13 12 11 10 22 23) (30 1 81) simpleGrading (0.002 1 20000)
hex ( 1 2 14 13 10 9 21 22) (25 1 81) simpleGrading (2 1 20000)
hex ( 2 3 15 14 9 8 20 21) (60 1 81) simpleGrading (1 1 20000)
hex ( 3 4 16 15 8 7 19 20) (25 1 81) simpleGrading (0.5 1 20000)
hex ( 4 5 17 16 7 6 18 19) (30 1 81) simpleGrading (500 1 20000)
// Fine
//hex ( 0 1 13 12 11 10 22 23) (240 1 648) simpleGrading (0.002 1 20000)
//hex ( 1 2 14 13 10 9 21 22) (200 1 648) simpleGrading (2 1 20000)
//hex ( 2 3 15 14 9 8 20 21) (480 1 648) simpleGrading (1 1 20000)
//hex ( 3 4 16 15 8 7 19 20) (200 1 648) simpleGrading (0.5 1 20000)
//hex ( 4 5 17 16 7 6 18 19) (240 1 648) simpleGrading (500 1 20000)
);
edges #codeStream
{
codeInclude
#{
#include "pointField.H"
#include "mathematicalConstants.H"
#};
code
#{
const scalar xMin = 0.3;
const scalar xMax = 1.2;
const label nPoints = 100;
const scalar dx = (xMax - xMin)/scalar(nPoints - 1);
os << "(" << nl << "spline 2 3" << nl;
pointField profile(nPoints);
const scalar pi = constant::mathematical::pi;
for (label i = 0; i < nPoints; ++i)
{
scalar x = xMin + i*dx;
profile[i].x() = x;
profile[i].y() = 0.05*pow4(sin(pi*x/0.9 - (pi/3)));
profile[i].z() = 1;
}
os << profile << nl;
os << "spline 14 15" << nl;
profile.replace(2, -1);
os << profile << nl;
os << ");" << nl;
#};
};
boundary
(
inlet
{
type patch;
faces
(
(0 11 23 12)
);
}
outlet
{
type patch;
faces
(
(17 18 6 5)
);
}
top
{
type symmetryPlane;
faces
(
(11 10 22 23)
(10 9 21 22)
( 9 8 20 21)
( 8 7 19 20)
( 7 6 18 19)
);
}
symUp
{
type symmetryPlane;
faces
(
( 0 12 13 1)
);
}
bump
{
type wall;
faces
(
( 1 13 14 2)
( 2 14 15 3)
( 3 15 16 4)
);
}
symDown
{
type symmetryPlane;