manual
Karri Keskinen
Department of Energy Technology, Aalto University
karri.keskinen@aalto.fi
December 14, 2015
Contents
1 Introduction 2
1.1 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Package components 8
2.1 Components intended for user editing . . . . . . . . . . . . . . . . . . . 8
2.2 Other components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.3 Saved fields and variables . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.4 Notes on Matlab/Octave interchangeability . . . . . . . . . . . . . . . . 14
3 Run Examples 15
3.1 Laminar flow - coarse grid . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.2 Turbulence initialization - coarse grid . . . . . . . . . . . . . . . . . . . 16
3.3 Turbulence development - fine grid . . . . . . . . . . . . . . . . . . . . 16
1
1 Introduction
The DNSLab package, containing both the NS2DLab two-dimensional pseudospectral
code and the Channel3DLab three-dimensional finite difference code, is provided as a
pedagogic gateway kit to eddy-resolving turbulent flow simulation. The software is
compatible with both the commercial Matlab software, and the open-source Octave
software.
This document is intended to aid the user of the Channel3DLab package by explaining
the properties of different scripts and functions contained within the archive. A quick
example of running the code is given in subsection 1.1. The most relevant points for
code permutation are provided in section 2. Later, in subsection 3, guidelines are
provided for running the channel flow solver from start to finish, i.e. from a laminar
flow initialization to a fully developed turbulent flow.
The computational code operates using a finite difference formulation. This means
that variables are stored in point locations (nodes), and derivatives of the variables
are computed according to values in the node itself and its neighbors. However, the
node spacing here complies with the cell-centered approach presented by Hirsch [1].
Hence, the present formulation, applied to Cartesian grids, has similarities with the
2
finite volume method, which is more commonly used for CFD.
2. Go to folder DNSLab/Channel3DLab
4. The program will present the utilized computational setup, as well as several op-
tions that can be subsequently modified (Figure 2). After the necessary operators
have been loaded, the simulation will start. Progress is indicated on the command
window
5. With the default setup, the first result visualizations (Figures 3-6*) will appear
after 10 steps, and will be updated every 5 steps. The visualizations can be moved
and resized freely, and are formed within the ThreeDChannel_Visualize.m script.
3
The relevant source data can be observed in the Workspace window, and is saved
to a date-coded .mat file in the root directory
*NB: With Octave, only Figures 3 and 4 are available due to availability of 3D visualization components
4
Figure 3: Mean velocity profile (top left), componentwise fluctuation profiles (top right),
Reynolds shear stress profile (bottom left), evolution of solution kinetic energy and mean
friction Reynolds number (bottom right).
5
Figure 4: Streamwise velocity field cutouts in an XY-plane (top), an XZ-plane within
the boundary layer (center), and two ZY-planes (bottom).
6
Figure 5: Three-dimensional cutout representation of streamwise velocity.
7
2 Package components
2.1 Components intended for user editing
The main script of the package is ThreeDChannelFlow_Run. Use this to run the simu-
lation. All of the relevant parameters to the computational setup and visualization can
be accessed via the ThreeDChannel_Casesetup script. The variable runmode refers to
the state of the case which is being simulated.
The retain option determines whether currently computed result variables are saved,
and resume determines whether the simulation run is restarted from the saved result.
Similarly, the retainoperators option saves generated differential operators and pre-
conditioners, carried out in ThreeDChannel_DifferentialOperators and
ThreeDChannel_Preconditioners, respectively. The former is a time-consuming op-
eration with large grids.
With the resumeoperators option, the user is able to import previous differential
operators for a rapid start to the simulation. With runmode=2, preconditioners are also
loaded. While preconditioner generation is typically a minor operation, Octave versions
older than 4.0.0 do not intrinsically support the contemporary implementation of the
incomplete LU matrix decomposition.
The interpolatenew option determines whether the pre-existing velocity fields are fed
to the interpolation function ThreeDChannel_newgridvelocity, yielding an interpo-
lated velocity field on the new grid.
TIM lets the user select a temporal discretization method. Four schemes have been
preset in the form of Butcher tableaus: the explicit Euler scheme (not suitable for
8
turbulence simulation), as well as 2nd, 3rd and 4th order Runge-Kutta methods (all
of which can be used for turbulence simulation). If the user wishes to implement their
own scheme in the code, it can be done easily via the butchertableau script. Note
that the code only supports explicit schemes.
Select the linear equation solver by setting either sbicg or spcg to 1. This refers to
the biconjugate gradient method and the conjugate gradient method, respectively. By
default, sbicg should be used, since it is compatible with an asymmetric coefficient
matrix. This is generated for the Poisson equation if the grid is non-equispaced in one
of the three coordinate directions (usually, this is the wall-normal coordinate).
Next, we have settings related to the solution of the linear equation system. Here, the
primary point of interest should be the tolerance (bicgtol,pcgtol), which determines
how accurately the system is required to be solved. The effect of the tolerance on result
quality may vary case-by-case. However, the tolerance has a significant effect on the
speed of the solver.
9
Table 4: Geometry parameters for computational domain.
Variable Explanation
res Node number per Cartesian direction (in default width and
length scale setup).
Wscale,Lscale Geometry width and length scale (default = 0.5). Changing
this parameter will change the geometry, and also change the
number of nodes placed in the specified direction.
ctanh This variable determines how strongly the computational
mesh is condensed towards the wall for resolution of the
boundary layer. For a uniform mesh in the wall-normal di-
rection, set this to a very small number, e.g. 1E-10. The
default value (5E-2) yields a y + value of ca. 0.6 for the first
computational node in the case of the Re = 180 turbulent
channel flow.
Parameters for visualization are provided in Table 5, while parameters for movie gen-
eration** are given in Table 6.
10
Table 6: Parameters for movie generation.
Variable Explanation
recmovie Select whether movie recording is on (1) or off (0).
nframes Select how many frames are included in the movie. A frame
is captured at each visualization interval.
fr Select the desired framerate (frames per second)
The generated movies will, by default, be named e.g. mov11_date.avi. Thus, if you
intend to generate several movies on the same day, be sure to rename movies that have
already been saved.
11
2.2 Other components
Editing of the following scripts and functions is not required for use of the package.
Hence, the essential content of each component is presented in Tables 7 and 8 briefly.
12
Table 8: Brief presentation of package components (solver).
Component name and Explanation
ThreeDChannel_AdjustTimeStep
If the dynamic time step is selected, this routine will change the time
step according to the computed maximum Courant number.
ThreeDChannel_Solver
The main solver script. Here, 3D velocity arrays U,V,W are first re-
shaped into vectors, which are then operated on by the differentia-
tion matrices. The solver structure is built for explicit Runge-Kutta
schemes and the
fractional step method. Evaluation of the convection
ui ui uj 2 ui
term C n = 12 uj x j
+ xj
, diffusion term D n
= x2j
, and body
force term gi commences, followed by pressure correction.
ThreeDChannel_Projection
This pressure correction script, located within
ThreeDChannel_Solver, performs velocity projection by solving
the discrete form of the Poisson equation p = C n . Upon
solution, intermediate velocities ui are corrected by the pressure
p
gradient, i.e., ui = ui x i
.
ThreeDChannel_RunPostProcessing
Contains scripts for post-processing, which are run at a frequency
according to the interval parameter.
ThreeDChannel_Analyze_Fluctuations_Compact
Computes field means and RMS-values of Reynolds stresses (velocity
fluctuations).
ThreeDChannel_ComputeQCriterion
Computes the field Q = 21 (Sij Sij ij ij ). A large Q signifies
vorticity dominance, whereas a low Q signifies strain dominance.
ThreeDChannel_Visualize
Plots different data to figures according to the case setup variables.
13
2.3 Saved fields and variables
Octave 4.0.0: The package can be utilized without modification, but three-dimensional
visualization features available in the Matlab version will be disabled.
14
3 Run Examples
This section contains a short guideline for those who want advance from laminar to
turbulent channel flow without using any predefined turbulent flow field as an initial
condition. This process can be divided into the following parts:
Importing the coarse grid turbulent flow onto a finer grid, and achieving a devel-
oped state(runmode=2)
It should be noted that the presented steps are, by no means, the only method of
generating a turbulent channel flow. However, when using this package, the steps
presented are simple to follow and have proven to be reasonably robust.
15
3.2 Turbulence initialization - coarse grid
Note that if you wish to generate high-quality statistics, you will want to run the
runmode=2 case for ca. 1000 steps, and restart a new case from that state. Guidelines
for the resume and resumeoperators options:
if you wish to load the velocity field or operators for a certain runmode, ensure
that the case setup parameter res complies with the fields loaded.
The default fields and operators (provided with the archive) assume that res =
36 when runmode = 0 or 1, and that res = 72 when runmode = 2.
If you wish to run a simulation with a different res or ctanh parameter than in
the existing fields and operators, be sure to set resume and resumeoperators to
0.
References
[1] Hirsch C, Numerical Computation of Internal and External Flows, Butterworth-
Heinemann, Massachusetts, 2nd edition, 2007.
16