Chapter 2
Computation of the base flow

We must first create an appropriate base flow. Since, in hydrodynamic stability theory, it is assumed that the base flow is incompressible, this can be computed using the incompressible Navier-Stokes solver ($NEK/IncNavierStokesSolver).
Tip: Note that the incompressible Navier-Stokes solver ($NEK/IncNavierStokesSolver) executable encapsulates the nonlinear equations as well as the stability tools. Therefore, when you setup either a nonlinear incompressible problem or an incompressible stability problem you should use the same executable - i.e.:
$NEK/IncNavierStokesSolver file.xml.
The instructions for running one or the other are specified on the XML file.
For the problem considered here, the specified boundary conditions will be no-slip on the walls and periodic for the inflow/outflow. In this case, since it is not a constant pressure gradient that drives the flow, it is necessary to use a constant body-force in the streamwise direction. It can be shown that this should be equal to 2ν.

In the folder $NEKTUTORIAL/base you will find the file Channel-Base.xml which contains the geometry along with the necessary parameters to solve the problem. The GEOMETRY section defines the mesh of the problem and it is generated automatically as you have seen in the previous task. The expansion type and order is specified in the EXPANSIONS section. An expansion basis is applied to a geometry composite, where by composite we mean a collection of mesh entities (specifically here, a collection of mesh elements), specified in the GEOMETRY section. A default entry is always included by the $NEK/NekMesh utility. In this case the composite C[0] refers to the set of all elements. The FIELDS attribute specifies the fields for which this expansion should be used. The TYPE attribute specifies the kind of the polynomial basis functions to be used in the expansion. For example,

1<EXPANSIONS> 
2   <E COMPOSITE="C[0]" NUMMODES="11" FIELDS="u,v,p" TYPE="GLL_LAGRANGE"/> 
3</EXPANSIONS>.

Note that all the results obtained in this tutorial refers to the expansion parameters just defined (i.e. NUMMODES="11" FIELDS="u,v,p" TYPE="GLL_LAGRANGE").

In order to complete the problem definition and generate the base flow we need to specify a section called CONDITIONS in the session file. If we examine Channel-Base.xml, we can see how to define the conditions of the particular problem to solve.

In particular, the CONDITIONS section contains the following entries:

  1. Solver information (SOLVERINFO) such as the equation, the projection type (Continuous or Discontinuous Galerkin), the evolution operator (Nonlinear for non-linear Navier-Stokes, Direct1 , Adjoint or TransientGrowth for linearised forms) and the analysis driver to use (Standard, Arpack or ModifiedArnoldi), along with other properties. The solver properties are specified as quoted attributes and have the form
    1<SOLVERINFO> 
    2   <I PROPERTY="[STRING]" VALUE="[STRING]" /> 
    3   ... 
    4</SOLVERINFO>

    Task: 2.1 In the SOLVERINFO section of Channel-Base.xml:

    Note: The bits to be completed are identified by …in this file.

    • set EQTYPE to UnsteadyNavierStokes to select the unsteady incompressible Navier-Stokes equations,
    • set the EvolutionOperator to Nonlinear in order to select the non-linear Navier-Stokes,
    • set the Projection property to Continuous in order to select the continuous Galerkin approach,
    • set the Driver to Standard in order to perform standard time-integration.

  2. The parameters (PARAMETERS) are specified as name-value pairs:
    1<PARAMETERS> 
    2   <P> [KEY] = [VALUE] </P> 
    3   ... 
    4</PARAMETERS>

    Parameters may be used within other expressions, such as function definitions, boundary conditions or the definition of other subsequently defined parameters.

    Task: 2.2 Declare the two parameters Re, that represents the Reynolds number, and Kinvis, which represents the kinematic viscosity. Now set the Reynolds number to 7500 and the kinematic viscosity to 1∕Re - i.e.
    <P> Re = 7500 </P>
    <P> Kinvis = 1/Re </P>
    Note that you can put previously defined parameters in the VALUE entry which can be an expression.

  3. The declaration of the variable(s) (VARIABLES).
    1<VARIABLES> 
    2   <V ID="0"> u </V> 
    3   <V ID="1"> v </V> 
    4   <V ID="2"> p </V> 
    5</VARIABLES>
  4. The specification of boundary regions (BOUNDARYREGIONS) in terms of composites defined in the GEOMETRY section and the conditions applied on those boundaries (BOUNDARYCONDITIONS). Boundary regions have the form
    1<BOUNDARYREGIONS> 
    2   <B ID="[INDEX]"> [COMPOSITE−ID] </B> 
    3   ... 
    4</BOUNDARYREGIONS>

    The boundary conditions enforced on a region take the following format and must define the condition for each variable specified in the VARIABLES section to ensure the problem is well-posed.

    1<BOUNDARYCONDITIONS> 
    2   <REGION REF="[B−REGION−INDEX]"> 
    3      <[TYPE] VAR="[VARIABLE_1]" VALUE="[EXPRESSION_1]"/> 
    4      <[TYPE] VAR="[VARIABLE_2]" VALUE="[EXPRESSION_2]"/> 
    5      ... 
    6   </REGION> 
    7   ... 
    8</BOUNDARYCONDITIONS>

    The REF attribute for a boundary condition region should correspond to the ID="[INDEX]" of the desired boundary region specified in the BOUNDARYREGIONS section.

  5. The definition of the (time- and) space-dependent functions (FUNCTION), in terms of x, y, z and t, such as initial conditions, forcing functions, and exact solutions. The VARIABLES represent the components of the specific function in a specified direction and they must be the same for every function.
    1<FUNCTION NAME="[NAME]"> 
    2   <E VAR="[VARIABLE_1]" VALUE="[EXPRESSION]"/> 
    3   <E VAR="[VARIABLE_2]" VALUE="[EXPRESSION]"/> 
    4   ... 
    5</FUNCTION>

    Alternatively, one can specify the function using an external Nektar++ field file. For example, this will be used to specify the InitialConditions or ExactConditions.

    1<FUNCTION NAME="[NAME]"> 
    2   <F FILE="[FILENAME]"/> 
    3</FUNCTION>

    Task: 2.3 Define a function called ExactSolution. For the Poiseuille flow with a streamwise forcing term the exact solution is:

    U = (y + 1)(1 − y) (2.1)
    V = 0 (2.2)
    P = 0 (2.3)

    Note: You need to use the first definition of FUNCTION where you can set an EXPRESSION.

Tip: If you are interested in the meaning of the other parameters and options present in the XML file, they should be available in the User-Guide. If not - just ask and we should be able to answer!
Task: 2.4 Define a body forcing function in the streamwise direction (called BodyForce): fx = 2ν = 2*Kinvis.
Note that for using the body force you need the following additional tag outside the section CONDITIONS:

1<FORCING> 
2   <FORCE TYPE="Body"> 
3      <BODYFORCE> BodyForce </BODYFORCE> 
4   </FORCE> 
5</FORCING>

It is possible to specify an arbitrary initial condition. In this case, it was decided to start from the exact solution of the problem in order to have a steady state in just few iterations. If the initial condition is not specified, it will be set to zero by default.

This completes the specification of the problem.

Task: 2.5 Compute the base flow using the Channel-Base.xml session file by typing:

$NEK/IncNavierStokesSolver Channel-Base.xml

At the end of the simulation, the fields will be written to a binary file Channel-Base.fld and the L2 error (using the given exact solution) and the L error will be printed on the terminal for each of the variables.

In particular, the terminal screen should look like this:

======================================================================= 
                EquationType: UnsteadyNavierStokes 
                Session Name: Channel-Base 
                Spatial Dim.: 2 
          Max SEM Exp. Order: 11 
              Expansion Dim.: 2 
             Projection Type: Continuous Galerkin 
                   Advection: explicit 
                   Diffusion: explicit 
                   Time Step: 0.001 
                No. of Steps: 1000 
         Checkpoints (steps): 500 
            Integration Type: IMEXOrder3 
======================================================================= 
Initial Conditions: 
  - Field u: (y+1)*(1-y) 
  - Field v: 0 
  - Field p: 0 
Writing: "Channel-Base_0.chk" 
Steps: 100      Time: 0.1          CPU Time: 1.296s 
Steps: 200      Time: 0.2          CPU Time: 0.440151s 
Steps: 300      Time: 0.3          CPU Time: 0.440857s 
Steps: 400      Time: 0.4          CPU Time: 0.438776s 
Steps: 500      Time: 0.5          CPU Time: 0.441416s 
Writing: "Channel-Base_1.chk" 
Steps: 600      Time: 0.6          CPU Time: 0.439318s 
Steps: 700      Time: 0.7          CPU Time: 0.438448s 
Steps: 800      Time: 0.8          CPU Time: 0.443955s 
Steps: 900      Time: 0.9          CPU Time: 0.443197s 
Steps: 1000     Time: 1            CPU Time: 0.440219s 
Writing: "Channel-Base_2.chk" 
Time-integration  : 5.26234s 
Writing: "Channel-Base.fld" 
------------------------------------------- 
Total Computation Time = 6s 
------------------------------------------- 
L 2 error (variable u) : 1.7664e-12 
L inf error (variable u) : 3.59475e-12 
L 2 error (variable v) : 4.79197e-13 
L inf error (variable v) : 1.12599e-11 
L 2 error (variable p) : 1.68712e-11 
L inf error (variable p) : 5.2737e-12

The final step regarding the base flow is to visualise the flow fields. Specifically, we need to convert convert the .fld file into a format readable by a visualisation post-processing tool. In this tutorial we decided to convert the .fld file into a VTK format and to use the open-source visualisation package called Paraview .

Task: 2.6 Convert the file:

$NEK/FieldConvert Channel-Base.xml Channel-Base.fld Channel-Base.vtu

Now open Paraview and use File ->Open, to select the VTK file, click the ’Apply’ button to render the geometry, and select each field in turn from the left-most drop-down menu on the toolbar to visualise the output.

Note: You can also open this type of file in VisIt.

In figure 2.1 we show how the base flow just computed should look like.


PIC

Figure 2.1: u-component of the velocity


Tip: Note that Nektar++ supports also Tecplot. To obtain a Tecplot-readable file you can run the following command:

$NEK/FieldConvert Channel-Base.xml Channel-Base.fld Channel-Base.dat