Beruflich Dokumente
Kultur Dokumente
discussions, stats, and author profiles for this publication at: https://www.researchgate.net/publication/263281166
CITATIONS READS
0 704
2 authors:
Some of the authors of this publication are also working on these related projects:
NACOR: European project on New Innovative Aircraft Configurations and Related Issues View project
All content following this page was uploaded by Heinrich Luedeke on 30 June 2016.
IB 124-2014/2
Z. Belligoli, H. Lüdeke
Herausgeber:
Deutsches Zentrum für Luft- und Raumfahrt e.V.
Institut für Aerodynamik und Strömungstechnik
Lilienthalplatz 7, Germany, 38108 Braunschweig
ISSN 1614-7790
Institutsdirektor: Verfasser:
Prof. Dr.-Ing. habil. C.-C. Rossow BSc Z. Belligoli
Dr.-Ing. H. Lüdeke
1 Introduction 1
2 Theoretical Background 2
2.1 Decaying Isotropic Turbulence . . . . . . . . . . . . . . . . . . . . . . . . 2
2.2 Taylor-Green Vortex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.3 Enstrophy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3 OpenFOAM 7
3.1 Overview of OpenFOAM . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2 What is boxTurb ? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.2.1 blockMesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.2.2 boxTurb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.2.3 dnsFoam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.2.4 enstrophy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2.5 Default Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.2.6 MapFields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4 Results 14
4.1 Decay of isotropic Turbulence (DIT) . . . . . . . . . . . . . . . . . . . . . 14
4.1.1 boxTurb16 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.1.2 boxTurb32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.2 boxTurb64 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.2.1 Different Initial Conditions . . . . . . . . . . . . . . . . . . . . . . 20
4.3 TGFoam 2D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.3.1 taylorGreenVortex.C . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.4 TG Foam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.5 TG Foam2D3D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.5.1 taylorgreenvortex 3D.C . . . . . . . . . . . . . . . . . . . . . 32
i
1 Introduction
1
2 Theoretical Background
In this part some general background will be given for the different test cases that are
going to be investigated.
• Mean rotations and mean buoyancy are not important and can be neglected.
Rotation and buoyancy in the mean flow-field tend to suppress vertical motion and
create an anisotrpy between the vertical and horizontal directions.
A flow is said to be homogeneous if :
This is equivalent to assume that the statistics of the turbulent flow are not a function
of space. An isotrpic flow is by definiton authomatically homogeneous.
The theory of 3D isotropic homogeneous turbulence is based on the examination of the
turbulent kinetic energy (TKE) budget (potential energy is constant for flow without
buoyancy fluctuations).
dEk
= −ǫ (2.1)
dt
2
u2i ∂ui
where E =< 2
> and ǫ =< ν ∂xj
>.
Equation 2.1 has the meaning that the rate of change of TKE is balanced by viscous
dissipation.
For a flow which is homogeneous in space, a spectral description is appropriate, al-
lowing to examine properties as a function of wavelength.
2
2. Theoretical Background 3
For isotrpic velocity fields the energy spectrum does not depend on directions and can
be written by:
where φi,i (k) is the velocity spectrum defined as the Fourier transform of the two-
P ˆ
point velocity correlation Ri,j (r) = hui (x)uj (x + r)i = x Ri,j (k)e
ik·r
and Rˆi,j (k) =
huˆi (k)uˆj (k)i are the Fourier coefficients of Ri,j (r) .
∗ ∗
The energy budget equation for stationary turbulence in spectral space can be written
as :
∂
E(k) = T (k) − 2νk 2 E(k) (2.3)
∂t
where T (k) is the kinetic energy transfer due to nonlinear interactions. Since the inte-
gral of the transport term T (k) over the whole k-space vanishes, the result is :
∂ ∞ ∞
Z Z
E(k)dk = −2ν k 2 E(k)dk (2.4)
∂t 0 0
R∞
which is the equivalent in spectral space of eq. 2.1. Hence ǫ = 0 2νk 2 E(k)dk : the rate
of dissipation of energy is equal to the rate of injection of energy.
Stationary isotropic turbulence is often studied numerically by adding a forcing term
to the momentum equation. This is usually done for the purpose of achieving higher
Reynolds numbers and longer statistics than is possible for decaying isotropic turbu-
lence. It is generally accepted that forcing the momentum equation at low wave num-
bers does not influence the small scale statistics of the flow provided that there is wide
separation betweem the largest and smallest scales. Such kind of turbulent behaviour
is referred as Forced Isotropic Turbulence (FIT).
The forcing term solves the function of a source of Turbulent Kinetic Energy (TKE).
However, sources of TKE are typically not homogeneous. It is then assumed that, for a
large Reynolds number, isotropy and homogeneity still holds at small scales and away
from the boundaries. Under this assumption, it is possible to represent turbulence
production as follows :
∂
E(k) = T (k) + F (k) − 2νk 2 E(k) (2.5)
∂t
If turbulence is stationary and the forcing F (k) is concentrated in a narrow spectral
band centered around a wave number ki , then :
124-2014/2
2. Theoretical Background 4
In the limit of ν → 0, the energy dissipation becomes negligible at large scales. Thus an
intermediate range of scales is expected between the forcing scale and the scale where
viscous dissipation becomes important :
The range of ν chosen for the simulation is suche that the kinematic viscosity is small
enough (Re large enough) to allow for a turbulent flow-field to be generated and large
enough (Re small enough) to resolve the geometries down to the Kolmogorov scales.
Kolmogorov’s theory from 1941 for the energy spectrum makes use of the result that
ǫ, the energy injection rate and dissipation rate also control the flux of energy. Energy
flux is independent of wavenumber k, and equal to ǫ for k > ki . Kolmogorov’s theory
assumes the injection wavenumber is much smaller than the dissipation wavenumber
(ki << kd ), meaning that the forcing term is active only at small wavenumbers.. In
the intermediate range of scales ki < k < kd neither the forcing nor the viscosity are
explicitly important, but instead the energy flux ǫ and the local wavenumber k are the
only controlling parameters. after a dimesional analysis, the energy density can be
expressed as :
124-2014/2
2. Theoretical Background 5
Aa + Bb + Cc = 0 (2.11)
Due to its simplicity in both initial and boundary conditions (usually no boundary con-
ditions are required since simulations are performed on a periodic domain in all direc-
tions), the Taylor-Green Vortex has been studied extensively in literature and serves as
a well-established reference and benchmark test problem for direct numerical simula-
tion (DNS) solvers and large eddy simulation (LES) subgrid scale models.
The treatment of the Taylor-Green test case is numerically very similar to the forced
isotropic turbulence, the only differece is an absence of the forcing term that keeps
turbulence alive; a consequence of this is the continuous decrease in the energy of the
eddies due to dissipation. The kinetic energy in the eddies will therefore decrease
down to zero for t → ∞.
It is a useful test case to check for diffusion and dissipation properties of the code.
Although the initial flowfield can be written as above, a Taylor-Green vortex can also be
obtained from the following intial conditions, representing a phase-shift with respect
to eq. 2.10
x y z
u = V0 sin( )cos( )cos( )
L L L
x y z (2.12)
v = −V0 cos( )sin( )cos( )
L L L
w=0
where V0 is the initial, reference velocity and L is a reference length. Within the scaling
of the incompressible code-version, both equal unity which is used for initialisation.
The initial value for the pressure is:
ρ0 V02 2x 2y 2z
p = p0 + cos + cos cos +2 (2.13)
16 L L L
Simulations for both the 2D and 3D Taylor-Green vortex will be performed.
For the 2D case, an analytical solution in the domain 0 < x, y < 2π is available:
u = −cos(x)sin(y)e−2t
v = sin(x)cos(y)e−2t (2.14)
1
p = (cos(2x) + cos(2y))e−4t
4
However, this solution can’t be expanded to the 3D case. This is because, in 3D, the
vortices start to interact with each other and give life to that chaotic behaviour which
is typical for turbulence. On the other hand, in the 2D case, the initial vortices don’t
interact as time goes by, they just decay.
124-2014/2
2. Theoretical Background 6
2.3 Enstrophy
An important quantity for turbulent flows is the enstrophy ε, defined for an incom-
pressible flowfield by:
1 ρ
Z
ε= ω
~ ·ω
~ dΩ
ρ0 Ω Ω 2
dEk
ǫ=−
dt
where Ek is the kinetic energy of the flow. However, the Ek will not be directly com-
puted and ǫ will be computed with the formula :
2 µ
ǫ= ε=2 ε
Re ρ0 · U · L
This is valid for incompressible flows only but approximately valid for compressible
flows at low Mach number. Since for the current test case the value of U and L are set
to unity, the equation can be simplified to :
ǫ = 2ν ε
where ν is the kinematic viscosity ρµ0 . The value of the local enstrophy in a single grid
cell is computed with the formula:
1 ~ ~ |2
εloc = |∇ ×U
2
where U~ is the velocity field. The simulations will provide the value of enstrophy in
each cell, an average of the quantity is calculated by summing up the local enstrophy
divided by the number of cells. Finally, a single, averaged value of the enstrophy will
be available at each time step and allow a plot of these quantities time evolution.
124-2014/2
3 OpenFOAM
• Segregated, iterative solution: For the system of equations governing the problem
of interest, separate matrix equations are created for each equation and are solved
within an iterative sequence.
• Finite volume method: Matrix equations are constructed using the finite volume
method applied to arbitrary shaped cells.
• Colocated variables: The solution variable for each matrix equation is defined at
cell centres.
The PISO algorithm will be implemented to iteratively solve the equations which are
discretized implicitely in time and thus need to be coupled by an algorithm like PISO.
The algorithm works following three steps :
7
3. OpenFOAM 8
• Prediction Step : the pressure field at tn−1 is used to solve the momentum equa-
tion resulting in an intermediate velocity field.
• 2nd Corrector Step : The 1st Corrector Step is repeated, yielding a final pressure
and velocity field.
./Allrun
• blockMesh : which creates a cartesian mesh according to the content of the file
constant/polyMesh/blockMeshDict
• boxTurb : which creates a random initial 3D flow field consistent with the origi-
nal definition of isotropic turbulence.
124-2014/2
3. OpenFOAM 9
3.2.1 blockMesh
blockMesh creates a cartesian grid according to the content of the file
constant/polyMesh/blockMeshDict. This last file controls all the parameters
that are involved in the generation of the mesh. The principle behind blockMesh
is to decompose the domain geometry into a set of one or more three dimensional,
hexahedral blocks. Edges of the blocks can be straight lines, arcs or splines. How-
ever, a simple, cubic domain was used for all the simulations. The mesh is ostensibly
specified as a number of cells in each direction of the block.
After the header, a number of keywords that help specify the mesh are given. Here
follows a description of the most important ones:
To fully understand their use the reader should refer to the OpenFOAM manual aval-
ble online.
The only parameter that is going to be modified during the simulations is the number
of cells forming the grid. This can be done by changing the parameters identified by
the block keyword. The first entry (hex ) is the shape modifier of the box and the
second entry gives the number of cells in each of the three direction for that block. So,
for example, if the second entry is (20 13 17), it means that there are 20 cells in the
x1 direction, 13 cells in the x2 direction and 17 cells in the x3 direction. These numbers
will be changed in order to obtain a finer and finer grid.
3.2.2 boxTurb
boxTurb is a preprocessing utility found in OpenFOAM sub-directory
applications/utilities/preProcessing/boxTurb and it generates an
124-2014/2
3. OpenFOAM 10
initial turbulent velocity field, U , consistent with the mesh produced by blockMesh.
As it is, it can be implemented in the simulation of decaying isotropic turbulence,
whereas it has to be modified in order to simulate the Taylor-Green vortex. Most
of the interesting code is found in turbGen.C which is found in the sub-direcotry
src/randomProcesses/turbulence/. The complete understanding of the
working priciples of boxTurb is not in the prime scopes of this report though.
3.2.3 dnsFoam
In the introduction on decaying isotropic turbulence and the Taylor-Green vor-
tex it was noted that energy is constantly converted into heat through the dif-
fusion term. The flow will thus eventually return to rest unless something
is done to keep the turbulence alive. To generate a forced isotropic turbu-
lence, in dnsFoam energy is constantly introduced in the form of a small ran-
dom body force generated through the script dnsFoam.C which is located in
$FOAM APP/applications/solvers/DNS/dnsFoam. The C++ syntax for the force
generation reads :
where mag is an operator which computes the magnitude of its object. The
cross product ˆ is used to make the generated field incompressible. K.nn() re-
turns the dimensions of the wavenumber mesh. The object forceGen in the
above code is declared and initialized in readTurbulenceProperties.H. In
the function newfield in Uoprocess.C, which is found in the sub-directory
$FOAM SRC/randomProcesses/processes, the following code is found:
forAll (UOfield, i)
{
is ((sqrK = magSqr(K[i])) < sqrKupper && sqrK > sqrKlower)
{
count ++;
UOfield[i]=
(1.0 - Alpha*DeltaT)*UOfield[i]
+ Scale*Sigma*WienerProcess();
}
}
where sqrK is the square root of the wavenumber. The energy is randomly added only
to those wavenumbers with magnitude between sqrKlower and sqrKupper. These
corresponds to the square root of the values UOKupper and UOKlower given in the
file constant/turbulenceProperties. Sigma is a measure of how much energy
is added in total to the field and Alpha has to do with the life time of each contribution
to the force field as the contributions accumulated in time. This parameters are all con-
figurable in the file constant/turbulenceProperties. Finally, Scale is a scaling
124-2014/2
3. OpenFOAM 11
fvVectorMatrix UEqn
(
fvm::ddt(U)
+ fvm::div(phi,U)
-fvm::laplacian(nu, U)
==
force
);
solve(UEqn==-fvc::grad(p));
in the above piece of code, the UEqn is initialised as a finite volume matrix. Then the
momentum equation is wirtten. The command fvm discretises its object by a finite
volume method, the command ddt computes the derivative of its object with respect
to time, div computes the divergence of its object, laplacian computes the laplacian
of its object and grad computes the gradient of its object.
Reading the definition of operator== in the file fvMatrix.C and comparing it to
the implementation of the operator- in the same file, makes it evident that the two
operations are identical [9] . Hence the equation that is being solved is:
fvVectorMatrix UEqn
(
fvm::ddt(U)
+ fvm::div(phi,U)
-fvm::laplacian(nu, U)
- force
);
solve(UEqn==-fvc::grad(p));
This is valid for the decay of isotropic turbulence and forced isotropic turbulence.
For oter flow-fields without external force like the Taylor-Green vortex, the forcing
term must be cancelled.
3.2.4 enstrophy
Enstrophy is a quantity related to the turbulent kinetic energy of the flow and
for incompressible flow it is given by the square of the vorticity. This is ex-
actly the calculation procedure in enstrophy.C which can be found in the sub-
directory utilities/postProcessing/velocityField/enstrophy. Enstro-
phy will only be necessary when performing simulations with the Taylor-Green vortex
case and therefore is not going to be computed when working with DIT or FIT.
124-2014/2
3. OpenFOAM 12
1
In the file enstrophy.C, the enstrophy is calculated by the formula 2
▽ ×U which is
written in OpenFOAM by :
0.5*magSqr(fvc::curl(U))
where magSqr computes the square of the magnitude of the object and curl com-
putes the curl of its object. fvc calculates explicit derivatives as opposed to fvm that
calculates implicit derivatives.
Those calculations compute the average enstophy over space.
U~f · ∆t
CF L =
d~
where U~f is the velocity at the cell face and d~ is the vector connecting the cell center
on either side of the face. Furthermore, small time-steps are used thus contributing to
obtaining large CFL numbers.
It is important to underline that time is adimensional in OpenFOAM : it is not ex-
pressed in seconds but in ”adimensional time-units”. This adimensional unit is ob-
tained by multiplying the time step∆t by UL where U and L are the characteristic veloc-
ity and length respectively. This is equal to the inverse of the Stouhal number (St−1 ), a
dimensionless number which is used to describe the shedding frequency of eddies.
Similarly, a characteristic convective time can be defined as:
L
tc = (3.1)
U
upon which the physical duration of the computation can be based.
3.2.6 MapFields
During the various simulations , finer and finer grids will be necessary to get more
accurate results. The problem is that the initial solution for p and U is given usu-
ally for the coarser gird only. This is why a mapping utility is used to interpolate
this solution onto the finer grid. The MapFields utility maps one or more fields
relating to a given geometry onto the corresponding fields for another geometry.
The fields data that mapFields maps are read from the time directory secified by
124-2014/2
3. OpenFOAM 13
startFrom/startTime in the controlDict of the target case, i.e. that into which
the result are being mapped.
For example, if the initial solutions from a 323 case named case1 have to be interpo-
lated to be used as initial solutoins for a 643 case named case2 in the same directory
of case1, then the command mapFields has to be called from the directory case2
with the following syntax :
124-2014/2
4 Results
4.1.1 boxTurb16
As already mentioned, boxTurb16 is the starting example for decaying isotropic tur-
bulence. However, from a physical and numerical point of view, this case is of little
interest since the 163 grid is too coarse to provide results with sufficient resolution for
an accurate turbulent spectrum (see Figure 4.1). This is why, little effort was put into
running this case and a situation with a finer grid (323 ) was implemented almost from
the beginning.
-4
10
-6
10
-8
10
Energy spectrum
10-10
10-12
slope -5/3
10-14
t=3
t=4.5
10-16 t=6
t=7.5
10
-18 t=9
50 100 150
wavenumber
The figure above shows the energy spectrum as a function of wavenumber. The peak
at low wavenumbers (i.e. large wavelength) is due to the forcing term which acts in
this limited range only. The energy cascade takes place at intermediate wavenumbers
and the dissipation range is visible at the largest wavenumbers of the spectrum. It is
also noted as the slope of the energy spectrum curve is far from the reference slope
(dashed line), indeed it was found out to be ten times larger.
14
4. Results 15
It is worth specifying that the wavenumbers have been scaled accordying to the
Nyquist theorem. The maximum wavenumber will be given by :
2π π
kmax = = (4.1)
2∆x ∆x
where 2π is the reference length of the domain and ∆x is the cell size. If, for example,
a 323 cell is considered, then ∆x = 1/32.
4.1.2 boxTurb32
boxTurb32 is the reference name given to all those simulations that will implement
dnsFoam on a 323 grid. The first thing to do before using boxTurb32 is to map
the initial solution from boxTurb16 onto the new, finer mesh. To do this the util-
ity mapFields is used. Afterwards, the application is run through the command
./Allrun and the first results are displayed. What is particularly important as a
first confirmation is to spot the intertial subrange (characterized by a slope of −5/3
as mentioned in section 2.1, eq. 2.9) in the graph of the energy spectrum, furthermore,
a graphical visualization of the flow in the box (through visualization softwares like
tecplot or paraView) might be useful to better understand the behaviour of the flow
and the working-method of the code.
The value of Nfk influences the range of wavenumbers that are forced: a high N f k
means that a large range of wavenumber is forced and viceversa. It is worth noting
124-2014/2
4. Results 16
that the forcing term acts in the low wavenumber range only when the above trails are
performed.
It is of utter importance to select an appropriate N f k as this will influence the quality
of the energy spectrum : if N f k is too small, not enough energy is added to the flow;
on the other hand, if N f k is too large, there would be too much energy in the flow thus
altering the spectrum.
All in all, N f k should be chosen between 8 to 14 in order to have adequate results for
the energy spectrum.
First conclusions
Some general conclusions on the behaviour of the code can be drawn from the simu-
lations on this coarse grid of 323 cells. The main problem is to spot the correct slope
for the inertial subrange. From the graphs of the various tests (all with ν = 0.025)
the forcing region (low wavenumbers) and the dissipative region (high wavenumbers)
are clearly visible whereas the intermediate region where energy is transferred from
larger scales to smaller scales can’t be pointed out. This is most probably due to the
coarseness of the grid therefore tests with finer grids (643 or 1283 ) should be attempted.
Nevertheless, an improvement from the 323 grid case can be noted. In general, it is well
understood that the grid is still too coarse to show some satisfying results and there-
fore should be refined. For the sake of avoiding repetitions, here are the parameters
used in the various runs:
• ν = 0.025 ( Re = 40)
• ∆t = 0.0075
• N f k = 6, 12, 18
The ending time endTimewas chosen beween 15 and 30 time units in order to get
accurate results for the enrgy spectrum.
Y
X
100
Energy spectrum
-1
10
slope: -5/3
10 Nfk=20
10 Nfk=12
10 Nfk=6
20 40 60 80
wavenumber
Figure 4.2: U flow-field and Energy spectrum at t=10 for different Nfk
124-2014/2
4. Results 17
The flow-field picture provides a good overview of the quality of the simulation. It
shows how structures are resolved down to the smallest scales, large structures con-
taining energy can be identified and the chaotic behaviour typical of turbulence is
present.
4.2 boxTurb64
boxTurb64 is the reference name given to all those simulations that will implement
dnsFoam on a 643 grid. After mapping the initial conditions from the test cases with
163 or 323 cells, the case is ready to be run. On a 643 grid, some more detailed results are
expected. However, after examining the literature, it is found out that such a mesh may
be still too coarse to get accurate results, nevertheless, it can assist in understanding the
problems encountered so far.
The first run was carried out by using the following values:
• ∆t = 0.001
• Nfk = 6
• tend = 15
• Re = 1600
Resulting in a simulation time of about 7 h and 30 min for the serial code. The results
for this run are still unstatisfying, in particular, numerical errors are present at high
wavenumbers making the graph of the energy spectrum very oscillatory. Furthermore,
there seems to be no influence of the forcing term at low wavenumbers.
-4
10
-6
10
-8
10
Energy spectrum
10-10
10-12
50 100 150
wavenumber
124-2014/2
4. Results 18
It is worth trying to run the same simulation at a larger number of forced k and a
shorter running time since the results at early stages of the simulation are valid for our
purposes as well. The new simulation is started with the following parameters :
• ∆t = 0.0015
• N f k = 12
• tend = 15
• Re = 1600
-4
10
-6
10
slope : -5/3
t=3
Enenrgy spectrum
-8
10
t=6
t=9
10-10 t = 12
t = 15
10-12
10-14
10-16
-18
10
50 100 150
wavenumber
At low wavenumbers the influence of the forcing term is now clearly visible in the
energy spectrum. However, it is not influencing it correctly : the energy spectrum is
expected to be starting from a value of 100 instead of 10−10 . It is not clear why this is
happening, most probably because the pre-processing tool boxTurb doesn’t generate
a correct initial velocity field for this particular case.
The time step ∆t is increased to reduce the simulation time . For a simulation of 15
non-dimentional time units, the simulation time is almost 7 h.
Both simulations don’t display vortices at the small-scale level. Those small-scale vor-
tices were visible for the 323 -grid case though. The only thing that changed from the
323 -grid case to 643 -grid case are the mapped initial conditions. In subsection 4.2.1 the
effect of different initial conditions on the final results will be described. The absence
of small scale structures is not easy to explain.It might be due either to a problem with
the pre-proceccing tool or the mapping function.
124-2014/2
4. Results 19
Y
X
In OpenFOAM, the Reynolds number is determined by the value of the kinematic vis-
cosity ν which can be set from the file constant/trasportProperties.C. Indeed
the reference length is supposed to be equal to unity as well as the reference velocity.
The equation for the Reynolds number thus reduces to :
1
Re =
ν
The value assigned to the kinematc viscosity is ν = 0.000625 yielding Re = 1600.
New simulations are started with the same parameters as before except for ν = 0.00125
yielding Re = 800 but no small-scale structures can be observed. and ν = 0.00042
yielding a Reynolds number of approximately 2400.
Y
-4 X
10
-6
10
Energy spectrum
-8
10
10-10
slope : -5/3
t=1
10-12 t=2
t=3
t=4
10-14 t=5
50 100 150
wavenumber
124-2014/2
4. Results 20
structures.
Z
100
Y
-2 X
10
-4
10
Energy spectrum
-6
10
10-8
-10
10 slope : -5/3
t=1
-12 t=2
10 t=3
t=4
10
-14 t=5
50 100 150
wavenumber
Small-scale structures can be finally observed but they are not resolved down to the
Kolmogorov scales because the grid is too coarse for sucha a high Re.
More tests need to be carried out in order to acquire further knowledge on the working
method of OpenFOAM and solve these issues.
• The initial condition from boxTurb64 is the mapped initial condition from
boxTurb32
• The initial condition from boxTurb64 is the mapped final solution from
boxTurb32
• The initial condition from boxTurb64 is obtained by doubling the final values
of U from boxTurb32
Z Z
Y Y
X X
Figure 4.8: Example of different initial conditions : mapped final solution from
boxTurb32 on the left and mapped initial condition from boxTurb32 on the right
124-2014/2
4. Results 21
4.3 TGFoam 2D
The files necessary for the simulation of the 2D Taylor-Green vortex
can be downloaded from the website OpenFOAM Wiki at the address
http://openfoamwiki.net/index.php/Main ContribExamples/TaylorGreenVortex.
ui = −cos(x)sin(y)
vi = sin(x)cos(y) (4.2)
1
pi = (cos(2x) + cos(2y))
4
The pressure equation can be omitted because, for an incompressible flow, it doesn’t
necessarily need to be specified at the beginning of the numerical simulation since it is
newly computed after each time step. Specifying it would simply allow to obtain more
accurate results.
The spatial period is 2π in x and y directions. This was set from the
constant/polyMesh/blockMeshDict file by setting the parameter
convertToMeters to 6.28318531.
From the file constant/transportProperties, the viscosity is defined by ν = 1
for this tutorial.
The file that calls all processes is runAll which differs from former scripts like Allrun
since only two scripts are called in this file : blockMesh and taylorGreenVortex.
While blockMesh works in the same fashion as before, taylorGreenVortex con-
tains the functions previously solved by boxTurb and dnsFoam. For a more detailed
description of taylorGreenVortex.C refer to the next subsection.
For the sake of controlling the correctness of the code, a test run was done for
case 1/dt 0.0001.
124-2014/2
4. Results 22
0.8
0.6
Y
0.4
0.2
0
0 0.2 0.4 0.6 0.8 1
X
The velocity field is correct. These vortices at t = 0.34 have a lower velocity magni-
tude than the initial ones thus confirming that turbulence is being dissipated by vis-
cosity and no external source of energy is being added. Furthermore, symmetry and
periodicity are kept.
4.3.1 taylorGreenVortex.C
The aim of this section is to introduce the reader to a general overview of the file
taylorGreenVortex.C. This file is used as a base for the code to perform the analy-
sis of the 3D Taylor-Green vortex case in the next section.
In the frist part of the file, the initial conditions are provided. As shown in the previous
section, they are based on the analytical condition for t = 0 s.
forAll(U,cellI)
{
U[cellI].x()=-Foam::cos(U.mesh().C()[cellI].x())
*Foam::sin(U.mesh().C()[cellI].y());
U[cellI].y()=Foam::sin(U.mesh().C()[cellI].x())
*Foam::cos(U.mesh().C()[cellI].y());
p[cellI]=-0.25*(Foam::cos(2*U.mesh().C()[cellI].x())
+Foam::cos(2*U.mesh().C()[cellI].y()));
}
124-2014/2
4. Results 23
124-2014/2
4. Results 24
volScalarField analyticalp
(
IOobject
(
"analyticalp",
runTime.timeName(),
mesh,
IOobject::NO READ,
IOobject::AUTO WRITE
),
mesh,
dimensionedScalar("analyticalp",dimPressure,0)
);
DynamicList<scalar> E rms u;
DynamicList<scalar> E rms v;
DynamicList<scalar> E max u;
DynamicList<scalar> E max v;
scalar maxError;
OFstream sPtr1(runTime.path()/"Error");
Then the time loop is initialised by a while construction loop within which the ana-
lytical result for u, v and p are calculated at every time step in order to compute the
error. The momentum equation (without forcing term) is finally discretised by a finite
volume method and solved.
#include "readPISOControls.H"
124-2014/2
4. Results 25
#include "CourantNo.H"
// Analytical Solution
forAll(analyticalU,cellI)
{
analyticalU[cellI].x()=-Foam::cos(U.mesh().C()[cellI].x())
*Foam::sin(U.mesh().C()[cellI].y())
*Foam::exp(-2.0*runTime.value());
analyticalU[cellI].y()= Foam::sin(U.mesh().C()[cellI].x())
*Foam::cos(U.mesh().C()[cellI].y())
*Foam::exp(-2.0*runTime.value());
analyticalp[cellI]=-0.25*(Foam::cos(2*U.mesh().C()[cellI].x())
+Foam::cos(2*U.mesh().C()[cellI].y()))
*Foam::exp(-4.0*runTime.value());
}
fvVectorMatrix UEqn
(
fvm::ddt(U)
+ fvm::div(phi, U)
// + turbulence->divDevReff(U)
- fvm::laplacian(nu, U)
);
UEqn.relax();
if (momentumPredictor)
{
solve(UEqn == -fvc::grad(p));
}
Then the P ISO loop is enetered and pressure and velocity are corrected after every
iteration ( the number of iterations is given in the file system/controlMeshDict ).
124-2014/2
4. Results 26
U = rAU*UEqn.H();
phi = (fvc::interpolate(U) & mesh.Sf())
+ fvc::ddtPhiCorr(rAU, U, phi);
adjustPhi(phi, U, p);
fvScalarMatrix pEqn
(
fvm::laplacian(rAU, p) == fvc::div(phi)
);
pEqn.setReference(pRefCell, pRefValue);
if
(
corr == nCorr-1
&& nonOrth == nNonOrthCorr
)
{
pEqn.solve(mesh.solver("pFinal"));
}
else
{
pEqn.solve();
}
if (nonOrth == nNonOrthCorr)
{
phi -= pEqn.flux();
}
}
#include "continuityErrs.H"
124-2014/2
4. Results 27
U -= rAU*fvc::grad(p);
U.correctBoundaryConditions();
}
}
The velocity deviation errorVelocity and the maximum velocity errror maxError
are computed afterwards.
errorVelocity=U-analyticalU;
maxError=mag(errorVelocity[0]);
forAll(errorVelocity,cellI)
{
if (mag(errorVelocity[cellI])>maxError)
{
maxError=mag(errorVelocity[cellI]);
}
}
runTime.write();
return 0;
}
4.4 TG Foam
Since no scripts for the 3D simulation of the Taylor-Green vortex have been provided
in OpenFOAM and none is availble online, a modification of boxTurb and dnsFoam
scripts was expected in a way that they would have been able to simulate that particu-
lar test case.
These modified scripts were renamed TG3Dvort and TGFoam and put
124-2014/2
4. Results 28
fvVectorMatrix UEqn
(
fvm::ddt(U)
+ fvm::div(phi, U)
- fvm::laplacian(nu, U)
);
as visible, the forcing term is removed from the formulation to omit influences on the
final result.
For the preprocessing phase a new script TG3Dvort was written that assigns initial
values to the velocity in the x- and y-direction as well as a (optionary) pressure field.
As can be seen, the intial conditions are multiplied by 2π for scaling reasons. At the
same time, the parameter converToMeters in the controlDict script is set to 1.
Alternatively, the latter can be set to 2π and the scaling factor may be eliminated from
the equations.
Simulations were initially run on a 643 grid with the same time discretization and spa-
tial discretization schemes as chosen for the forced isotropic turbulence. A Reynolds
number of 200 was also chosen due to the availability of comparable literature for the
Taylor-Green vortex.
Although the file TG3Dvort generates a correct initial velocity field, the evolution of
the simulation is wrong.
124-2014/2
4. Results 29
Y
X
Nfk = 0
Re = 200
643 grid
Y
X
them.
4.5 TG Foam2D3D
As shown in the section 4.3, the simulation of the 2D Taylor-Green vortex provided
satisfactory results. For this reason it was chosen as a starting point to develop a similar
code, expected to be able to solve the 3D case. The changes and improvements made
to the original file can be found in subsection 4.5.1.
The directory containing all these files was named TG Foam2D3D.
In this 3D case, as mentioned in section 2.2., no analytical solution is available anymore.
Therefore, the computation of an error which is defined as the difference between the
analytical 2D- and the numerical solution becomes meaningless.
The the intial solutions can be simply expanded for the 3D case by adding consistently
a third dimension to the equations for the 2D case :
ui = sin(x)cos(y)cos(z)
vi = −cos(x)sin(y)cos(z)
wi = 0 (4.3)
1
pi = (cos(2x) + cos(2y))(cos(2z) + 2)
4
323 grid
Re = 200
Central dif f erencing
Euler explicit
The plot of the velocity field shows a nicely developing and decaying Taylor-Green
vortex at different time intervals.
124-2014/2
4. Results 31
Y
X
Furthermore, the plot of the average enstrophy over time displays the typical hill-
shape of this particualre test case. However, it can be observed that the curve doesn’t
exactly match the reference solution. This is due to the coarseness of the grid and the
low order of the method. Indeed, if a finer, 643 mesh is used, results will improve
dramatically.
Runs for Re = 200 and Re = 400 were also made for the 643 grid and results are
displayed in figure.
124-2014/2
4. Results 32
Re = 100
Re = 200
Re = 400
OpenFOAM, 64 cells
It can be seen how the agreement between the numerical result and the reference so-
lution becomes more and more marked as the Reynolds number decreases. Indeed, a
higher Re implies a more turbulent motion within the domain and makes vortex res-
olution more difficult as well as the achievement of accurate results. Two solutions to
this problem would be either to implement a finer grid (1283 or 2563 would be good) or
choose a higher order method both for the spatial discretisation and for the temporal
advancement.
forAll(U,cellI)
124-2014/2
4. Results 33
{
U[cellI].y()=-Foam::cos(U.mesh().C()[cellI].x())
*Foam::sin(U.mesh().C()[cellI].y())
*Foam::cos(U.mesh().C()[cellI].z());
U[cellI].x()=Foam::sin(U.mesh().C()[cellI].x())
*Foam::cos(U.mesh().C()[cellI].y())
*Foam::cos(U.mesh().C()[cellI].z());
p[cellI]=-0.25*(Foam::cos(2*U.mesh().C()[cellI].x())
+Foam::cos(2*U.mesh().C()[cellI].y()))
*(Foam::cos(2*U.mesh().C()[cellI].z()) + 2);
}
124-2014/2
4. Results 34
DynamicList<scalar> E rms u;
DynamicList<scalar> E rms v;
DynamicList<scalar> E max u;
DynamicList<scalar> E max v;
scalar maxError;
scalar avgEnstrophy;
OFstream sPtr1(runTime.path()/"Error");
Then the time loop is initialised as a while loop. Within whis loop the analytical result
for u, v and p are given at every time step in order to compute the error. The mo-
mentum equation (without forcing term) is discretised by a finite volume method and
solved.
while (runTime.loop())
{
Info<< "Time = " << runTime.timeName() << nl << endl;
#include "readPISOControls.H"
124-2014/2
4. Results 35
#include "CourantNo.H"
// Analytical Solution
forAll(analyticalU,cellI)
{
analyticalU[cellI].y()=-Foam::cos(U.mesh().C()[cellI].x())
*Foam::sin(U.mesh().C()[cellI].y())
*Foam::cos(U.mesh().C()[cellI].z())
*Foam::exp(-2.0*runTime.value());
analyticalU[cellI].x()= Foam::sin(U.mesh().C()[cellI].x())
*Foam::cos(U.mesh().C()[cellI].y())
*Foam::cos(U.mesh().C()[cellI].z())
*Foam::exp(-2.0*runTime.value());
analyticalp[cellI]=-0.25*(Foam::cos(2*U.mesh().C()[cellI].x())
+Foam::cos(2*U.mesh().C()[cellI].y()))
*(Foam::cos(2*U.mesh().C()[cellI].z()) + 2)
*Foam::exp(-4.0*runTime.value());
}
fvVectorMatrix UEqn
(
fvm::ddt(U)
+ fvm::div(phi, U)
// + turbulence->divDevReff(U)
- fvm::laplacian(nu, U)
);
UEqn.relax();
if (momentumPredictor)
{
solve(UEqn == -fvc::grad(p));
}
Then the P ISO loop is entered and pressure and velocity are corrected after each iter-
ation ( the number of iterations is given in the file system/controlMeshDict ).
124-2014/2
4. Results 36
{
volScalarField rAU(1.0/UEqn.A());
U = rAU*UEqn.H();
phi = (fvc::interpolate(U) & mesh.Sf())
+ fvc::ddtPhiCorr(rAU, U, phi);
adjustPhi(phi, U, p);
fvScalarMatrix pEqn
(
fvm::laplacian(rAU, p) == fvc::div(phi)
);
pEqn.setReference(pRefCell, pRefValue);
if
(
corr == nCorr-1
&& nonOrth == nNonOrthCorr
)
{
pEqn.solve(mesh.solver("pFinal"));
}
else
{
pEqn.solve();
}
if (nonOrth == nNonOrthCorr)
{
phi -= pEqn.flux();
}
}
#include "continuityErrs.H"
U -= rAU*fvc::grad(p);
124-2014/2
4. Results 37
U.correctBoundaryConditions();
}
}
errorVelocity=U-analyticalU;
enstrophy = 0.5*magSqr(fvc::curl(U));
avgEnstrophy = sum(enstrophy).value() / mesh.cells().size();
maxError=mag(errorVelocity[0]);
forAll(errorVelocity,cellI)
{
if (mag(errorVelocity[cellI])>maxError)
{
maxError=mag(errorVelocity[cellI]);
}
}
runTime.write();
return 0;
}
It is worth noting that, for a compilation of this last part, the createFields.H file
has to be modified to initialize enstrophy. Therefore, after initialisation of p and U,
124-2014/2
4. Results 38
volScalarField enstrophy
(
IOobject
(
"enstrophy",
runTime.timeName(),
mesh,
IOobject::NO READ
),
0.5*magSqr(fvc::curl(U))
);
124-2014/2
5 Conclusion & Recommendations
The Forced Isotropic Turbulence and the Taylor-Green vortex cases have been inves-
tigated to assess the capabilities of the software OpenFOAM as a Direct Numerical
Simulation (DNS) solver.
As far as Forced Isotropic Turbulence is concerned, a lot of effort was put in un-
derstanding the characteristics of the solver dnsFoam and the pre-processing tool
boxTurb. The absence of comments in the scripts made implementations of addi-
tional features a difficult process. The results for the energy spectrum and the velocity
field show the requirement of further grid refinement in order to get more accurate
results. Simulations on 1283 or even 2563 cells would be the next step.
The Taylor-Green vortex test-case at low Reynolds number, on the other hand, pro-
vided some satisfying results. The curve of the turbulent dissipation was calculated on
a 323 mesh and a refined 643 grid, for the latter one this curve was almost matching the
reference solution with significant improvements from one case to the other. Even for
this benchmark, finer grids are required.
As a general recommendation, higher order discretization methods should be inves-
tigated because of their potential in delivering higher accuracy with lower computa-
tional cost than low order methods for such cases.
An implicit time-stepping scheme was implemented in these simulations to allow
larger CFL numbers at the requirement of longer running times. Indeed, under the
chosen numerical parameters, OpenFOAM proved to be rather slow in solving DNS.
An investigation of the performances of explicit time-stepping schemes would be use-
ful to understand to what extent the software performances can be improved.
in summary, OpenFOAM has proven to be a good software for DNS. Results were
fairly accurate and improve dramatically on finer grids. From a programming point of
view, when code customization is needed to simulate a particular test case or an en-
tirely new case, the user must face additional challenges and issues due to the intrinsic
structure of the software.
39
Bibliography
[1] MENG Quingguo, On The Evolution Of Decaying Isotropic Turbulence. ACTA ME-
CHANICA SINICA, Vol.20, No.1 February 2004.
[2] T.S. Lundgren, Linearly forced isotropic turbulence. Center for Turbulence Research
Annual Research Briefs 2003.
[3] A.D. Beck, G.J. Gassner, Numerical Simulation of the Taylor-Green Vortex at Re =
1600 with the Discontinuous Galerkin SPectral Elelment Method for well-resolved and
underresolved scenarios. First International Workshop on High-Order CFD Methods
Nashville, TN, 2012.
[4] E. Komen, testing DNS capability of OpenFOAM and STAR-CCM+. TU Delft Master
Thesis, May 2011.
[5] N.N. Mansour, A.A. Wray, Decay of Isoropic turbulence at low Reynolds number.
Physics of Fluid, 1993
[7] G.N. Coleman, J. Kim, R.D. Moser, A numerical study of turbulent supersonic
isothermal-wall channel flow. Cambridge University Press, 1995.
[8] G.I. Taylor, A.E. Green, Mechanism of the Production of Small Eddies from Large Ones.
Proceedings of the Royal Society of London. Series A, Mathematical and Physical
Sciences, Vol. 158, No.895 Febraury 1937.
[10] Various Authors, High-Order CFD Methods : Current Status and Perspective. Inter-
national Journal for Numerical Methods in Fluids, 2012.
[13] http://en.wikipedia.org/wiki/OpenFOAM .
[14] http://www.iag.uni-stuttgart.de/nrg/research/turbulence/taylor-green-vortex
40
IB 124-2014/2
Z. Belligoli, H. Lüdeke
Verteiler:
21 Exemplare