Skip to content

Tutorials

1. Channel flow example

This example shows how to carry out the DNS of an indefinite turbulent plane channel flow, with periodic boundary conditions along the and wall-parallel directions. The setup has analytical description of the geometry, uses a 100^3 grid and nDecompCubes=2, and starts with a fictitious initial condition where a sinusoidal perturbation is superimposed to a power-law velocity profile. Note that such initial condition is not effective to initiate a channel flow DNS. Also, the setup corresponds to a very large Reynolds number, and the simulation is highly under-resolved.

Preprocessor

Compile the preprocessor with

make preproc

and run it with:

mpirun -n 2 ./preproc examples/channel

The execution time is negligible.

Solver

Compile the solver with

make solver

and run as:

mpirun -n <N> ./solver examples/channel

where the value of the MPI rank N can be 1 or 2. Its maximum value is nTotCubes, whose value can can be read from preproc-log.dat. In settings.in, solver is configured to run a simple CFG simulation (see below) with prescribed time step, and to stop after 100 steps. Its (serial or parallel) output, recorded in examples/channel/runtimedata.dat must be identical to examples/channel/reference-output.dat.

Postproc

Compile the postprocessor with

make postproc

and run as:

mpirun -n <N> postproc examples/channel

where <N> can be 1 or 2, as for solver. The execution time is negligible. Depending on configuration in settings.in, postproc outputs binary files for statistics and/or flow fields, and converts them into .vtk legacy files for visualization. In this example, only two snapshots are saved, and the corresponding three-dimensional field for the mean longitudinal velocity um is produced. Moreover, a spatial average for um over the two homogeneous directions is carried out, and a smaller ASCII file with lower-dimensionality statistics is written. It can be conveniently plotted with the gnuplot utility, by prepending the command set key autotile columnhead to skip plotting the first line. Details on the output capabilities of postproc can be found in the dedicated Section.

Channel with STL

The same channel example can be run with geometry described by STL: 6 STL files are needed for the 6 planes defining the bounding box. Each can be described by two triangles only, and therefore can be written by hand. As a convenient alternative, in the folder utilities the utility createChannelSTL.cpl can be used to set the lengths of the box sides, and to write the required 6 STL files in the case folder. Compile the utility with:

make createChannelSTL

and execute it as:

./utilities/createChannelSTL examples/channel

to write the required STL files in examples/channel/geometry/.

With the STL files in place, the procedure above can be repeated. First, in headers.cpl the line #define GEOMETRY_IS_ANALYTIC must be commented out. Then, everything must be recompiled and rerun, starting from preproc. Note that slight differences between screen output and reference-output.dat are expected: with STL, the algorithm used to discriminate interior and exterior points leads to minor (roundoff) differences in the grid along the wall-normal directions.

A note on non-dimensionalization

The code uses variables with physical dimensions, as dimensionless parameters of general use cannot be defined. However, this may be disturbing when dealing with simple flows like channel or pipe flow, where a dimensionless description is easier and more compact, and reasoning in terms of a Reynolds number is more natural.

One can run the channel flow simulation via the settings.in file in (at least) two ways: constant pressure gradient (CPG) and constant flow rate (CFR). The latter case is an extension of the former. They are described in detail in this paper.

  • CPG. The natural choice of Reynolds number is the friction Reynolds number , built with the friction velocity , half the gap with and the fluid viscosity. One starts with selecting the numerical value of ; deciding the working fluid via the value of nu sets the value of the product , so that picking a value for sets the value of . In settings.in, the input variable Lz must be set to the value . Instead, the value of leads to the value of the input variable headx given by .

  • CFR (currently not implemented). The natural choice of Reynolds number is the bulk Reynolds number , built with the bulk velocity , half the gap with and the fluid viscosity. One starts with selecting the numerical value of ; deciding the working fluid via the value of nu sets the value of the product , so that picking a value for sets the value of . In settings.in, the input variable Lz must be set to the value . Instead, the value of leads to the value of the input variable meanu given by .

Flow in the human nose

This example shows how to carry out the DNS of the flow within a human nose, for a steady inspiration driven by the external ambient and the outflow boundary at the throat. The STL of an anatomy derived from a CT scan is provided (at a very coarse resolution). The setup uses about 5.93 million grid points, among which 1.78 million are internal. The simulation is reasonable but quite under-resolved, yielding an approximately isotropic spatial resolution of 0.5 millimeters. Also, the STL anatomy is coarse. The initial condition is quiescent fluid.

Before compilation of preproc, this case requires the following changes to the source files:

  • header.cpl: make sure that macros GEOMETRY_IS_ANALYTIC and GRID_IS_NONUNIFORM are not set;
  • solver.cpl: at lines 43/44, switch to USE modules-common/specifics-nose.

Now, follow the procedure above to run in sequence preproc, solver and postproc with case folder examples/nose, like:

mpirun -n 4 ./preproc examples/nose

Similarly to the channel flow tutorial, here solver and postproc can be run with a number of ranks between 1 and 4. Note that preproc in this case takes a little while to establish complete topological information. Five snapshots of the evolving flow field are saved and then converted to VTK; mean-flow statistics for mean velocity and pressure are also produced.