RANS Channel

This tutorial describes the essential setup details for a wall-resolved RANS simulation, illustrated through a 3D channel case. The \(k-\tau\) RANS model is employed for this tutorial, which is the recommended RANS model in nekRS. For more information see here.

Before You Begin

It is highly recommended that new users familiarize themselves with the basic nekRS simulation setup files and procedures outlined in the Fully Developed Laminar Flow and perhill tutorials before proceeding.

Mesh and Boundary Conditions

The mesh is generated with genbox using the following input file

base.rea
-3                     spatial dimension  ( < 0 --> generate .rea/.re2 pair)
1                      number of fields
#=======================================================================
#
#    Example of .box file for Taylor-Green
#
#    If nelx (y or z) < 0, then genbox automatically generates the
#                          grid spacing in the x (y or z) direction
#                          with a geometric ratio given by "ratio".
#                          ( ratio=1 implies uniform spacing )
#
#    Note that the character bcs _must_ have 3 spaces.
#
#=======================================================================
#
Box
-5  -12  -4                                          nelx,nely,nelz for Box
0 8 1.                                               x0,x1,gain  (rescaled in usrdat)
0 1 1.                                               y0,y1,gain  (rescaled in usrdat)
0 1 1.                                               z0,z1,gain
P  ,P  ,W  ,SYM,P  ,P                                bc's  (3 chars each!)

It creates an infinite 3D half-channel of non-dimensional width \(1\). The streamwise (\(x\)) direction has 5 elements with periodic (P) boundary conditions. The wall-normal (\(y\)) direction has 12 geometrically spaced elements with a symmetry (SYM) boundary condition specified at the bottom face and a wall (W) boundary on the top face. The spanwise (\(z\)) direction has 4 elements with periodic (P) boundary conditions. The elements expand from the bottom of the domain to the top with a ratio of \(0.35\).

Note

Boundary conditions for the turbulent scalars are specified in the .udf file.

Control Parameters (.par file)

Details of the structure of the parameter file can be found here. For RANS simulations it is critical to include two additional scalars which correspond to the \(k\) and \(\tau\) fields respectively. Here, they are included as the [SCALAR01] and [SCALAR02] cards. In addition, it is essential to also include the [PROBLEMTYPE] card and enable variableViscosity.

For this particular tutorial, the simulation is non-dimensionalized and flow properties are density=1.0 and viscosity=-43500. It is strongly recommended to run RANS simulations in non-dimensional form. By assigning a negative value to the viscosity, nekRS will treat it as a Reynolds number. This setup corresponds to \(Re = 43,500\), which is well above the critical Reynolds number for a channel. density and diffusivity for SCALAR01 and SCALAR02 should be assigned identical values as density and viscosity for velocity field for consistency.

[GENERAL]
polynomialOrder = 7
#startFrom = "r.fld"+time=0
stopAt = endTime
endTime = 50
dt = 5e-02
timeStepper = tombo2

checkpointControl = simulationTime 
checkpointInterval = 50

constFlowRate = meanVelocity=1.0 + direction=X

[PROBLEMTYPE]
equation = navierStokes+variableViscosity

[PRESSURE]
residualTol = 1e-04

[VELOCITY]
boundaryTypeMap = wall, slipY
residualTol = 1e-06
density = 1.0
viscosity = -43500. 

[TEMPERATURE]
#solver = none
boundaryTypeMap = inlet, insulated 
residualTol = 1e-06
rhoCp = 1.0
conductivity = -43500. 

[SCALAR01] # k
boundaryTypeMap = inlet, insulated 
residualTol = 1e-08
rho = 1.0
diffusivity = -43500. 

[SCALAR02] # tau
boundaryTypeMap = inlet, insulated 
residualTol = 1e-06
rho = 1.0
diffusivity = -43500. 

The Temperature field is also solved in this tutorial, but can be turned off by uncommenting the Solver = None line on the .par file.

User Routines (.usr file)

This section describes the essential code snippets required in the .usr file for RANS simulations. Other details of all the subroutines can be found here.

Foremost, it is essential to include the following header at the beginning of the .usr file.

Files in the above relative locations in the nekRS repo load the essential RANS subroutines.

RANS initialization is done through the rans_init subroutine call from usrdat2. The required code snippet is shown below.

The rans_init subroutine sets up the necessary solver variables to use RANS models. This includes loading the model coefficients, setting up the character boundary condition (cbc) array for the turbulent scalars, and calculating the regularization [Tombo2018] for the \(k-\omega\) models. The ifld_tke and ifld_tau variables specify the field index location of the transport variables of the two-equation RANS model. The specific RANS model used is identified by the m_id variable. All available RANS models are annotated in the above code. The recommended \(k-\tau\) model is invoked with m_id=4. Selecting ifcoeffs=.false. sets the standard RANS coefficients outlined in [Wilcox2008]. Advanced users have the option of specifying their own coefficients which have to populated in the coeffs array, with ifcoeffs=.true.. The final parameter to be aware of is the wall distance function code w_id. The recommended value for it is w_id=2 which provides a smoother distance function, populated in the wd array. A cheaper option is available through w_id=1 which provides “taxicab” distance and can search across periodic boundaries. The user also has the option of specifying their own wall distance array by setting w_id=0 which will require wd array to be populated with user computed wall distance before the rans_init call.

Diffusion coefficients for all fields in RANS simulation runs must be modified to include eddy viscosity. This is done by the following inclusions in the uservp subroutine

As above, eddy viscosity, mu_t, is added to the momentum diffusion coefficient and \(k\) and \(\tau\) diffusion coefficients are modified as described by Eq. ktau in the RANS theory section.

Note

The transport and diffusion coefficients (utrans and udiff) for the RANS scalars are set with the field coefficient array vaules (cpfld) for field 1, velocity. This is done to ensure consistency in the problem setup.

Source terms in the \(k-\tau\) transport equations, Eq. ktau, are added with the following inputs in the userq subroutine

Implicit source terms contributions are specified to the avol variable, while remaining terms are in the qvol variable.

For the wall-resolved \(k-\tau\) RANS model, the wall boundary conditions for \(k\) and \(\tau\) are both zero. These are set in userbc as

The velocity boundary condition is checked in cb1 for a wall on the highlighted line. For this periodic case, this is not strictly necessary. However, for any inlet/outlet case it is needed to distinguish between the Dirichlet BC values for \(k\) and \(\tau\) on the wall versus an inlet, where cb1 would have a value of v.

Initial conditions are specified in the useric routine. For RANS simulations, positive non-zero initial values for \(k\) and \(\tau\) are recommended. The following is used for the channel simulation,

SIZE file

The SIZE file can be copied from the available template included at the nekRS/core/SIZE.template and changing the basic parameters as necessary for this case. The user needs to ensure that the auxiliary fields specified in the SIZE file is at minimum ldimt=3 for RANS simulations. This includes the reserved field for temperature and the two additional fields for the turbulent scalars. In order to use the stress formulation, additional memory must be allocated by setting, lx1m=lx1 These two changes are highlighted below. Other details on the contents of the SIZE file can be found here.

Compilation

All required case files for RANS wall-resolved channel simulation can be downloaded using the links below:

  • chan_WR.usr

  • chan_WR.par

  • chan_WR.re2

  • chan_WR.ma2

  • SIZE

Results

For reference, the results obtained from the \(k-\tau\) RANS wall-resolved simulation are shown below and compared with results from low-Re \(k-\tau\) (m_id=5), regularized \(k-\omega\) (m_id=0) and low-Re regularized \(k-\omega\) (m_id=1) models.

tutorials/rans/U1.png

Fig. 9 Normalized stream-wise velocity from different RANS models.

tutorials/rans/k1.png

Fig. 10 Normalized TKE from different RANS models.

RANS models may be simply switched by using the appropriate m_id in usrdat2. The low-Re versions of the model should be employed only for capturing the near wall TKE peak. It may require additional resolution in the near-wall region and has only minimal impact on the velocity profile.