Sie sind auf Seite 1von 45

See

discussions, stats, and author profiles for this publication at: https://www.researchgate.net/publication/263281166

DNS of Simple Verification Test Cases Using


OpenFOAM

Article · March 2014


Source: DLR

CITATIONS READS

0 704

2 authors:

Zeno Belligoli Heinrich Luedeke


Delft University of Technology German Aerospace Center (DLR)
3 PUBLICATIONS 0 CITATIONS 106 PUBLICATIONS 300 CITATIONS

SEE PROFILE SEE PROFILE

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

The Anti-Fairing: reducing junction drag with a dent View project

All content following this page was uploaded by Heinrich Luedeke on 30 June 2016.

The user has requested enhancement of the downloaded file.


Bericht des Instituts für Aerodynamik und Strömungstechnik
Report of the Institute of Aerodynamics and Flow Technology

IB 124-2014/2

DNS of Simple Verification Test Cases Using OpenFOAM

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

Stufe der Zugänglichkeit: 1


Braunschweig, im März 2014

Institutsdirektor: Verfasser:
Prof. Dr.-Ing. habil. C.-C. Rossow BSc Z. Belligoli
Dr.-Ing. H. Lüdeke

Abteilung: Transportflugzeuge Der Bericht enthält:


Abteilungsleiter: 40 Seiten
14 Bilder
Dr.-Ing. H. von Geyr 0 Tabellen
14 Literaturstellen
Abstract
Direct Numerical Simulation (DNS) is a numerical technique to resolve turbulent flow
down to the smallest scales of the flow-field. Since this approach requires highly accu-
rate and efficient numerical solvers for calculations on extremely fine grids, the DNS
solver of the OpenFOAM software package will be validated within the scope of this
work. To do so, generic two- and three-dimensional test cases such as the Decay of
Isotrpic Turbulence (DIT) and the Taylor-Green (TG) vortex are calculated.
Both cases have been investigated to assess the capabilities of the software OpenFOAM
as a DNS solver by comparing the results with reference data from literature.
Contents

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

5 Conclusion & Recommendations 39

i
1 Introduction

Direct Numerical Simulation (DNS) is a numerical technique to resolve turbulent flow


down to the smallest scales of the flow-field. With increasing computational power,
DNS is becoming an interesting instrument for detailed investigation of turbulent and
transitional flow, for example for laminar-wing design. On the other hand, DNS re-
quires highly accurate and efficient numerical solvers for calculations on extremely
fine grids. In the scope of this work, the DNS OpenFOAM solver will be investigated
and validated by two- and three-dimensional test cases such as the Decay of Isotrpic
Turbulence (DIT) and the Taylor-Green (TG) vortex.
OpenFOAM (Open source Field Operation And Manipulation) is a C++ toolbox for
the development of customized numerical solvers, and pre-/post-processing utilities
for the solution of continuum mechanics problems, including computational fluid dy-
namics (CFD). The code is released as free and open source software. It is maintained
by The OpenFOAM Foundation, which is sponsored by the ESI Group, the owner of
the trademark to the name OpenFOAM.
Decaying Isotropic turbulence is an idealized problem for the development of turbu-
lence theories and models. The primary reason for this is that DIT is governed by only
two basic elements : nonlinearity and viscosity. DIT has two different periods : the
energy propagation and the final decay. The enrgy propagation period is referred to
as that the energy at large scales is propagated to small scales via nonlienar coupling.
The final decay period is referred as that the viscous effect is dominating and nonlin-
ear energy transfer could be neglected. For the present investigations, a forced version
of DIT is implemented in OpenFOAM which is beneficial in maintaining the isotropic
turbulent spectra autonomously.
The classical Taylor-Green Vortex problem constitutes the simplest flow for which a
turbulent energy cascade can be observed numerically. Starting from an initial ana-
lytical solution containing only a single length scale, the flow field undergoes a rapid
build-up of a fully turbulent dissipative spectrum because of non-linear interactions
of the developing eddies. Due to its simplicity in both initial and boundary condi-
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 average
enstrophy over time will be computed and then scaled to allow comparisons with re-
sults obtained with other CFD solvers for the disspiation rate.

1
2 Theoretical Background

In this part some general background will be given for the different test cases that are
going to be investigated.

2.1 Decaying Isotropic Turbulence


The most important characteristic of turbulent motion is the fact that velocity and pres-
sure at a point fluctuate with time in a random manner. The mixing in turbulent flow
is primarily due to these fluctuations. A turbulent flow is said to be isotropic if :

• Mean rotations and mean buoyancy are not important and can be neglected.

• There is no mean flow.

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 :

• There are no spatial gradients in any time-averaged quantity.

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:

E(k) = 2πk 2 φi,i (k) (2.2)

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 :

2νk 2 E(k) = F (k) (2.6)

for k 6= ki (beacuse ki = ∞) and consequently :


Z ∞
ǫ= F (k)dk (2.7)
0

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 :

2νk 2 E(k) = T (k) ≈ 0 (2.8)

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 :

E(k) = CK ǫ2/3 k −5/3 (2.9)

This is called ”Kolmogorov spectrum”. CK ≈ 1.6 is the ”Kolmogorov constant”. The


region of parameter space in k where the energy spectrum follows this law is known as
inertial range. In this range, energy cascades from larger scales into smaller ones and
ultimately to the dissipation scale.
One of the main differences in between DIT and FIT is the Energy spectrum. For FIT the
influence of the force is usually clearly visible at low wavenumbers since energy values
tend to increase up to a maximum and then decrease with the wavenumber increasing
further. For DIT, however, there is no such increase in energy at low wavenumbers and
energy starts decreasing right from the first wavenumber.

2.2 Taylor-Green Vortex


The Taylor-Green vortex problem constitutes a simple flow-field with numerically ob-
servable turbulent energy cascade. Starting from an analytical initial solution contain-
ing a single length scale, the flow field undergoes a rapid build-up of a fully turbulent
dissipative spectrum due to non-linear interactions of the developing eddies. The ini-
tial motion is usually represented by :

u = A cos ax sin by sin cz


v = B sin ax cos by sin cz (2.10)
w = C sin ax sin by cos cz

The equations are consistent if the incompressible continuity equation is satisfied :

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

where ω ~ is the vorticity vector ∇~ ×U ~ , Ω the integration domain, ρ0 the density at


freestream and and ρ the local density.
For the analysis of the results, the temporal evolution of enstrophy will be plotted and
scaled to be used for comparison with turbulent kinetic energy dissipation rate graphs
from literature. This latter quantity is defined as :

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

3.1 Overview of OpenFOAM


The word ”OpenFOAM” stands for Open Source Field Operation and Manipulation.
OpenFOAM is a C + + library used to create executables known as applications. These
applications can be solvers, designed to solve a specific problem in continuum mechan-
ics, or utilities, performing tasks which involve data manipulation. The OpenFOAM
distribution contains numerous solvers and utilities covering a wide range of prob-
lems. One of the strengths of OpenFOAM is the ability in creating new solvers and util-
ities by the user with some pre-requisite knowledge of the underlying method, physics
and programming techniques involved. However, code customization becomes more
challenging with increasing depth into the OpenFOAM library, owing to a lack of doc-
umentation.
OpenFOAM includes tools for meshing and for pre- and post-processing. There is
the possibility to run cases in parallel as well as standard, enabling the user to take
advantage of computer hardware at disposal.
To solve equations for a continuum, OpenFOAM uses a numerical approach with the
following features:

• 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.

• Equation coupling: The coupling between equations, particularly pressure and


velocity is performed using adapted versions of known algorithms such as e.g.
PISO and SIMPLE.

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.

• 1st Corrector Step : the pressure equation is solved to obtain an intermediate


pressure field. using this pressure field the momentum equation is solved again
resulting in a new velocity field which satisfies the continuity equation.

• 2nd Corrector Step : The 1st Corrector Step is repeated, yielding a final pressure
and velocity field.

the number of corrector steps can be increased.


The PISO algorithm can be seen as an extension of the SIMPLE algorithm, with a fur-
ther corrector step to enhance it. Although the method implies a considerable increase
in computational effort it has been found to be efficient and fast thanks to its higher
precision.
The choice of discretisation schemes is selected by the user at run time through the
fvSchemes file of the case being simulated. OpenFOAM has a comprehensive range
of discretisation schemes, allowing full control over accuracy, boundedness and con-
servation.

3.2 What is boxTurb ?


The aim of this work is to test OpenFOAM DNS capabilities. Among the various solver
applications available, the one that performs DNS is called dnsFoam. A very good start-
ing point to get acquainted with the solver is to download the tutorial ”A boxTurb16
and dnsFoam tutorial” by Martin De Mare’.
The case ”boxTurb16” is a standard OpenFOAM solver which simulates the decaying
or forced isotropic turbulence. The number ”16” stands for the number of cells that
form the mesh in each direction.
Once started by entering the directory and typing :

./Allrun

the following commands are called

• 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.

• dnsFoam : which solves the 3D flowfield by the DNS methodology. In order to


compensate the dissipation by turbulence a small amount of random fluctuations
are introduced in every time step.

124-2014/2
3. OpenFOAM 9

• enstrophy : a post-processing step where the enstrophy field is calculated from


the velocity field in each time step.

A deeper understanding of these tools is instructive in order to understand how Open-


FOAM works when it comes to DNS.

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:

• convertToMeters : it specifies a factor by which all vertex coordinates in the


mesh description are multiplied.
• vertices : it specifies the coordinates of the vertices of the blocks of the mesh.
• blocks : it specifies the number of cells required in each direction, the type of
cell and a list of cell expansion ratio in each direction.
• edges : Each edge joining 2 vertex points is assumed to be straight by default.
However any edge may be specified to be curved by entries in a list named edges.
The list is optional;if the geometry contains no curved edges, it may be omitted.
• boundary : it brakes boundary into patches (regions) and it specifies the bound-
ary conditions.

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 :

K/(mag(K) + 1.0e-6) ˆ forceGen.newField(), K.nn()

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

factor defined in Uoprocess.C and WeinerProcess is the type of random process


chosen for the forcing term.
The definition and solving of the differential equation in dnsFoam is :

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.

3.2.5 Default Settings


OpenFOAM uses a Finite Volume Method (FVM) which is second order accurate in
space. Different time stepping algorithms can be chosen but the default one is an im-
plicit Backward Euler method which is second order accurate in time. Implicit time
stepping is generally not used for DNS since equations need to be solved iteratively
but Backward Euler was chosen because implicit schemes allow for larger CFL num-
bers :

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 :

mapFields ../case1 -consistent


For further info, the reader is referred to the OpenFOAM online guide.

124-2014/2
4 Results

4.1 Decay of isotropic Turbulence (DIT)

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

Figure 4.1: Energy spectrum of boxTurb16 at different times

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 number of forced wavenumbers k

The continuous decay of turbulence is obtained in OpenFOAM thanks to a forc-


ing term that adds randomly energy to a certain range of wavenumbers which can
be modified by operating on the parameters UOKupper and UOKlower in the file
constant/turbulenceProperties as explained in section 3.2.3 . The default val-
ues are U0Kupper = 10 and U0Klower = 7 yielding 12 forced wavenumbers. Be-
low is a table of the various trials that have been made to understand how these pa-
rameters influence the number of forced k (Nfk).

U0Kupper U0Klower Nfk


9 7 0
10 7 12
11 7 12
12 7 20
13 7 26
15 7 50
12 10 8
13 11 14
9 6 6
9 2 6
8 1 6

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

10-14 slope : -5/3


t=3
10 -16 t=6
t=9
-18
t = 15
10

50 100 150
wavenumber

Figure 4.3: Energy spectrum at different times for Nfk=6

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

Figure 4.4: Energy spectrum at different times for Nfk=12

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

Figure 4.5: U-field for boxTurb64 at Re = 1600

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

Figure 4.6: Energy spectrum and U-field for Re = 800


The energy spectrum is again starting from a lower value than 100 , numerical errors are
present for highwavenumbers and the slope does not match the reference even though
it gets closer with time.
The velocity field, although displayung the chaotic motion, doesn’t show small scale

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

Figure 4.7: Energy spectrum and U-field for Re = 2400

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.

4.2.1 Different Initial Conditions


In this section the effect of different initial conditions on the final results is investigated.
Three different types of intial condition are implemented :

• 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

All in all, no significant change can be appreciated by implementing these different


initial conditions since no significant difference can be appreciated in the final solutions
of the velocity-field or the energy spectrum.

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.

The directory containing all these files was named TG Foam2D.


These files are part of a tutorial on the 2D Taylor-Green vortex. Two cases are initially
pesented, both using central differencing as a space discretisation scheme. However,
the first case uses Euler implicit whereas the second one uses Crank Nicolson for time
advancement. Within the two cases, different time steps and different grids were cho-
sen due to the purpose of the original tutorial to analyse the accuracy of the schemes.
The final time step is set to be 0.34 time units. The error between the analytical solution
and the numerical one was also calculated. The analytical solution for the 2D case is
given in equations 2.14
Whereas the initial solution for the numerical scheme is taken from the analytical so-
lution by setting t = 0. Hence:

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

Figure 4.9: U-field for the 2D taylor-Green vortex at t = 0.34

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.

Info<< "Calculating initial conditions" << endl;

// Initial conditions based on analytical solution at t=0

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

Afterwards, the varibles errorVelocity, analyticalU, analyticalp are de-


clared. The first two are vectorial fields whose values are located at cell centers whereas
the last one is a scalar field. Finally the scalar maxError is declared.

// Error of the velocity component


volVectorField errorVelocity
(
IOobject
(
"errorVelocity",
runTime.timeName(),
mesh,
IOobject::NO READ,
IOobject::AUTO WRITE
),
mesh,
dimensionedVector("errorVelocity",dimVelocity,vector::zero)
);

// Analytical Solution for Velocity


volVectorField analyticalU
(
IOobject
(
"analyticalU",
runTime.timeName(),
mesh,
IOobject::NO READ,
IOobject::AUTO WRITE
),
mesh,
dimensionedVector("analyticalU",dimVelocity,vector::zero)
);

// Analytical Solution for Pressure

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");

sPtr1<<"# Time(s)"<<" "<<"dx"<<" "<<"Error"<< " "<<endl;

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.

Info<< "\nStarting time loop\n" << endl;


while (runTime.loop())
{
Info<< "Time = " << runTime.timeName() << nl << endl;

#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());
}

// Pressure-velocity PISO corrector


{
// Momentum predictor

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

// --- PISO loop


for (int corr=0; corr<nCorr; corr++)
{
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);

// Non-orthogonal pressure corrector loop


for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
// Pressure corrector

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]);
}
}

Finally some information of ExecutionTime and ClockTime is displayed.

sPtr1<<runTime.value()<<" "<< U.mesh().C()[1].x() -


U.mesh().C()[0].x() <<" "<<maxError<< " "<<endl;

runTime.write();

Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"


<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}

Info<< "End\n" << endl;

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

into the sub-directory applicatons/utilities/preProcessing and


applications/solvers/DNS respectively. For simplicity, it was chosen to
use the old dnsFoam script without the force term instead of a new TGFoam script for
these simulations. Indeed, creating a new script doesn’t only imply the modification
of the source file but also of other sources called by the main script. This has proven
to be too much effort for the sake of this investigation and was eventually discarded.
As mentioned, the dnsFoam script was modified in the following way :

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.

const vectorField centers(mesh.C());


const scalar pi2 = 2.0*constant::mathematical::pi;
forAll(centers, celli)
{
vector cCenter = centers[celli];
U[celli].x() = ::sin(cCenter.x()*pi2)*::cos(cCenter.y()*pi2)
*::cos(cCenter.z()*pi2);
U[celli].y() =-::cos(cCenter.x()*pi2)*::sin(cCenter.y()*pi2)
*::cos(cCenter.z()*pi2);
p[celli] = 0.125*(::cos(2*cCenter.x()*pi2)
+::cos(2*cCenter.y()*pi2))*(::cos(2*cCenter.z()*pi2) + 2);

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

Figure 4.10: Non-symmetrical U-field


This because the final solution is not symmetrical as expected for this scenario. This
happens very early thus meaning that short simulations can be run to check for the
origin of this problem.
The first thing to be noticed is the presence of a forcing term even though it was previ-
ously removed. For these tests, the number of f orced k (N f k) was 12. Such a number
is obtained when U0Kupper = 10 and U0Klower = 7. If these values are both set
to zero, then the N f k is zero as well.
After re-running the simulation with these new settings :

Nfk = 0
Re = 200
643 grid

the final result is now symmetrical (Figure 4.11).


Z

Y
X

Figure 4.11: Symmetrical U-field


Besides symmetry, a good resolutions fo the turbulent scales down to the small ones
can be observed. The initial vorteces are deformed as a result of the interaction between
124-2014/2
4. Results 30

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

The spatial period is 2π in the x, y and z directions. This was set


from the constant/polyMesh/blockMeshDict file by setting the parameter
convertToMeters to 6.28318531 as in the 2D case.
In the file constant/trasnportProperties, the value of ν is defined. It will be set
to 0.05 (Re = 200) for the first set of runs.
The file that starts all the processes is and adapted version of Allrun for this special
case. The file starts the following processes : blockMesh, taylorGreenVortex 3D
and enstrophy.
The first, test simulation was started with the following parameters :

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

Figure 4.12: U-field for 323 grid and Re = 200

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.

OFoam, 64 cells, Re = 100


OFoam, 64 cells, Re = 200

Figure 4.13: Average enstrophy over time

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

Figure 4.14: Average enstrophy over time

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.

4.5.1 taylorgreenvortex 3D.C


This modified file makes the simulation of a 3D Taylor-Green vortex possible. Besides
the necessary changes to adapt the original 2D file to perform three dimensional simu-
lation, some lines of code were added to allow the computation of average enstrophy
in order to compare the final results with those from the literature.
As before, the frist part of the file calculates the initial conditions. They have been
modified for a 3D case.

Info<< "Calculating initial conditions" << endl;

// Initial conditions based on analytical solution at t=0

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);
}

Afterwards, the varibles errorVelocity, analyticalU, analyticalp are de-


clared. The first two are vector fields whose values are located at cell centers whereas
the last one is a scalar field located in the centers as well. Finally the scalar maxError
and the new scalar avgEnstrophy are declared.

// Error of the velocity component


volVectorField errorVelocity
(
IOobject
(
"errorVelocity",
runTime.timeName(),
mesh,
IOobject::NO READ,
IOobject::AUTO WRITE
),
mesh,
dimensionedVector("errorVelocity",dimVelocity,vector::zero)
);

// Analytical Solution for Velocity


volVectorField analyticalU
(
IOobject
(
"analyticalU",
runTime.timeName(),
mesh,
IOobject::NO READ,
IOobject::AUTO WRITE
),
mesh,
dimensionedVector("analyticalU",dimVelocity,vector::zero)
);

124-2014/2
4. Results 34

// Analytical Solution for Pressure


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;
scalar avgEnstrophy;

OFstream sPtr1(runTime.path()/"Error");

sPtr1<<"# Time(s)"<<" "<<"dx"<<" "<<"Error"<< " "<<endl;

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.

Info<< "\nStarting time loop\n" << endl;

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());
}

// Pressure-velocity PISO corrector


{
// Momentum predictor

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 ).

// --- PISO loop

for (int corr=0; corr<nCorr; corr++)

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);

// Non-orthogonal pressure corrector loop


for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
// Pressure corrector

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();
}
}

The velocity deviation errorVelocity, the maximum velocity error maxError


(even though they are meaningless for the 3D Taylor-Green vortex case) and the
enstrophy are computed in the next step.

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]);
}
}

Finally some informations on the ExecutionTime and ClockTime are displayed.


Furthermore, the values of the enstorphy after each time step will be written in a file
named Error, along with Time, the cell size dx and the deviation from the solution
called Error which, as mentioned already, has no meaning for this 3D case since no
analytical solution is available.

sPtr1<<runTime.value()<<" "<< U.mesh().C()[1].x() -


U.mesh().C()[0].x() <<" "<<maxError<< " "<< avgEnstrophy <<"
"<<endl;

runTime.write();

Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"


<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}

Info<< "End\n" << endl;

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

this module-file is appended by :

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

[6] R.S. Rogallo, Numerical Experiments in homogeneous Turbulence. NASA Technical


Memorandum 81315, September 1981.

[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.

[9] M. De Mare’, A boxTurb16 and dnsFoam tutorial. November 2011.

[10] Various Authors, High-Order CFD Methods : Current Status and Perspective. Inter-
national Journal for Numerical Methods in Fluids, 2012.

[11] S.B. Pope, Turbulent Flows. Cambridge University Press, 2000.

[12] OpenFOAM User Guide, http://www.openfoam.org/docs/user/.

[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

DNS of Simple Verification Test Cases Using OpenFOAM

Z. Belligoli, H. Lüdeke

Verteiler:

Institut für Aerodynamik und Strömungstechnik, BS ..... 1 Exemplar


Institut für Aerodynamik und Strömungstechnik, GÖ .... 1 Exemplar
Verfasser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . je 2 Exemplare
Dr.-Ing. H. von Geyr ..................................... 1 Exemplar
Dr.-Ing. A. Seitz .......................................... 1 Exemplar
Prof. Dr.-Ing. habil. C.-C. Rossow ......................... 1 Exemplar
Prof. Dr.-Ing. A. Dillmann ................................ 1 Exemplar
Deutsche Bibliothek Frankfurt am Main .................. 2 Exemplare
Niedersächsische Landesbibliothek Hannover ............ 1 Exemplar
Technische Informationsbibliothek Hannover ............ 1 Exemplar
Zentralbibliothek ........................................ 2 Exemplare
Reserve .................................................. 5 Exemplare

21 Exemplare

View publication stats

Das könnte Ihnen auch gefallen