Boundary conditions
Boundary conditions for each mesh boundary should normally be set in the Parameter File (.par), using the boundaryTypeMap parameter.
This is used within the VELOCITY, TEMPERATURE or SCALARXX sections to set the boundary conditions of the respective solvers for the case.
Available Types
All available boundary conditions are summarised in the command line help function for nekRS (nekrs --help par) and below.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
Key Value(s) Description / Comment
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
boundaryTypeMap <bcType for ID 1>, <bcType for ID 1>, ... boundary type for each boundary ID
none no-op (internal or periodic)
interpolation neknek boundary (int)
assign int values in codedFixedValue
zeroValue velocity only (w, wall)
codedFixedValue user specified Dirichlet (v, t, inlet)
specify okl function codedFixedValueVelocity
or codedFixedValueScalar in udf
zeroGradient (I, o, O, insulated, outlet, outflow)
codedFixedGradient user specified scalar Neumann (f, flux)
specify okl function codedFixedGradientScalar in udf
zeroXValue/zeroGradient symmetry x-normal plane (slipx, symx)
zeroYValue/zeroGradient symmetry y-normal plane (slipy, symy)
zeroZValue/zeroGradient symmetry z-normal plane (slipz, symz)
zeroNValue/zeroGradient unaligned symmetry (slip, sym)
zeroYZValue/zeroGradient (onx)
zeroXZValue/zeroGradient (ony)
zeroXYValue/zeroGradient (onz)
zeroXValue/codedFixedGradient traction x-normal plane (tractionx, shlx)
specify okl function codedFixedGradientVelocity in udf
zeroYValue/codedFixedGradient traction y-normal plane (tractiony, shly)
specify okl function codedFixedGradientVelocity in udf
zeroZValue/codedFixedGradient traction z-normal plane (tractionz, shlz)
specify okl function codedFixedGradientVelocity in udf
zeroNValue/codedFixedGradient unaligned traction (traction, shl)
specify okl function codedFixedGradientVelocity in udf
Tip
To setup some cases (e.g., cases that use third party meshes wherein boundaries are identified by a unique integer), you may need to use the boundaryIDMap parameter of the MESH section to apply the boundaryTypeMap options to the correct boundary IDs of the mesh (By default NekRS assumes that the boundaryIDs start at 1).
Assuming an inlet-outlet pipe flow, below is an example where the three boundary conditions are applied to the boundary IDs 389 (codeFixedValue - inlet), 231 (zeroGradient - outlet), 4 (zeroValue - walls).
[VELOCITY]
boundaryTypeMap = codedFixedValue, zeroGradient, zeroValue
[MESH]
boundaryIDMap = 389, 231, 4
Note
For conjugate heat transfer cases, it is necessary to also specify the velocity boundary map, boundaryIDMapv, separately to identify the interface conformal walls between the fluid and solid mesh.
Following the above example, assume that the pipe is enclosed in a solid annular insulated jacket where the boundary ID 4 corresponds to the conformal wall between the solid and fluid mesh, while remaining insulated walls of the solid mesh are 10, 20 and 30.
[MESH] boundaryIDMapV = codedFixedValue, zeroGradient, zeroValue boundaryIDMap = zeroGradient, zeroGradient, zeroGradient, codedFixedValue, zeroGradient [VELOCITY] boundaryTypeMap = 389, 231 ,4 [TEMPERATURE] boundaryTypeMap = 10, 20, 30, 389, 231
User Defined Value/Gradient
If a boundary condition requires a value setting rather than just a type, a suitable function will need to be provided within the .oudf file (or okl block section of .udf file).
The name of the function used should be in the form of codedFixed + Value/Gradient + Velocity/Scalar/Mesh, E.G. codedFixedValueVelocity, codedFixedGradientScalar and codedFixedValueMesh.
All of these functions are passed the bcData struct which has the following parameters available:
Name |
Type |
Description |
|---|---|---|
|
|
mesh index of boundary GLL |
|
|
array offset |
|
|
boundaryID |
|
|
current simulation time |
|
|
location coordinates of boundary GLL |
|
|
local normal vector components |
|
|
local tangent vector components |
|
|
local bi-tangent vector components |
|
|
local traction along tangent |
|
|
local traction along bi-tangent |
|
|
local velocity components |
|
|
local pressure |
|
|
interpolated velocity components |
|
|
scalar index |
|
|
scalar value (Dirichlet) |
|
|
scalar flux (Neumann) |
|
|
interpolated scalar value |
|
|
mesh velocity components |
|
|
\(\rho\) or \(\rho c_p\) |
|
|
diffusion coefficient |
|
|
pointer to user array |
Note
Some example cases are noted here for different user defined boundary condition types:
BC Type |
Example Case |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
Internal / Periodic
None is used when a internal boundary condition is required or a periodic boundary condition has been set as part of the mesh and it does not need to be considered as part of the standard processing of boundary conditions.
Perodicity is linked to the mesh connectivity and is handled by the meshing tool.
Turbulent Inflow (for LES/DNS)
Velocity Recycling
NekRS offers an in-built technique to impose fully developed turbulent inflow.
It comprises recycling the velocity from an offset surface in the domain interior to the inlet boundary resulting in a quasi-periodic domain.
The required routines are available through the velRecycling.hpp header file.
Sample .udf code to use velocity recycling is as follows,
#include "velRecycling.hpp"
#ifdef __okl__
void codedFixedValueVelocity(bcData * bc)
{
bc->u = bc->usrwrk[bc->idM + 0 * bc->fieldOffset];
bc->v = bc->usrwrk[bc->idM + 1 * bc->fieldOffset];
bc->w = bc->usrwrk[bc->idM + 2 * bc->fieldOffset];
}
#endif
void UDF_Setup()
{
nrs->o_usrwrk.resize(nrs->NVfields * nrs->fieldOffset);
const dfloat uBulk = 1.0; //mean bulk velocity
const int bID = 1; //boundary ID of inlet
const dfloat Dh = 1.0; //Hydraulic diameter
condt dfloat xOffset = 0.0; //x-offset of recycling surface
const dfloat yOffset = 0.0; //y-offset of recycling surface
const dfloat zOffset = 10.0 * Dh; //z-offset of recycling surface
velRecycling::setup(nrs->o_usrwrk, xOffset, yOffset, zOffset, bID, uBulk);
}
void UDF_ExecuteStep(double time, int tstep)
{
velRecycling::copy();
}
The above example assumes that the inlet surface, with boundary ID (bID) equal to 1, is perpendicular to the x-y plane.
The recycling surface is located at an offset distance equal to \(10 Dh\) from the inlet surface, where \(Dh\) is the hydraulic diameter of the inlet cross-section.
uBulk is the desired mean velocity at the inlet boundary.
Note
The recommended recycling length is \(8-10 Dh\) [Lund1998] to allow the resolution of largest eddies. The user must ensure that the boundary layer is not acted upon by significant pressure gradients or geometrical changes between the inlet and recycle plane.
The interpolated velocities from the recycling surface are stored in the nrs->o_usrwrk array which is accessible in the codedFixedValueVelocity kernel.
Therefore, nrs->o_usrwrk vector must be resized to accomodate the velocity data to nrs->NVfields * nrs->fieldOffset length.
The velRecycling::setup call setups up the necessary interpolation procedures to map the velocity from domain interior to the inlet surface.
Note the parameters passed as arguments to the setup routine.
The velRecycling::copy routine is called from the UDF_ExecuteStep routine at every time step.
It, internally, populates the nrs->o_usrwrk array with the scaled instantaneous velocity at the recycle plane based on specified ubulk.
Finally, the captured velocity is specified as inlet Dirichlet boundary condition in codedFixedValueVelocity in the okl block section, as shown above.
Note the proper indexing and offset specified using bc->idM and bc->fieldOffset for the three velocity components.