Tag Archives: OpenFOAM

Time-Varying Cylinder Motion in Cross-flow: timeVaryingFixedUniformValue

This post is a simple demonstration of the timeVaryingFixedUniformValue boundary condition. This boundary condition allows a Dirichlet-type boundary condition to be varied in time. To demonstrate, we will modify the oscillating cylinder case.


Instead of using the oscillating boundary condition for point displacement. We will have the cylinder do two things:

  • Move in a circular motion
  • Move in a sinusoidal decay motion

The basics of this boundary condition are extremely simple. Keep in mind that although (here) we are modifying the pointDisplacement boundary condition for the cylinder, the basics of this BC would be the same if you were doing a time varying boundary condition for say pressure or velocity.

In the pointDisplacement file:

 type timeVaryingUniformFixedValue;
 fileName "prescribedMotion";
 outOfBounds clamp;

fileName points to the file where the time varying boundary condition is defined. Here we used a file called prescribedMotion however you can name it whatever you want. The outOfBounds variable dictates what the simulation should do if the simulation time progresses outside of the time domain defined in the file.

The additional file containing the desired motion prescribedMotion is formatted in the following way:

( 0 (0 0 0))
( 0.005 (-0.0000308418795848531 0.00392682932795517 0))
( 0.01 (-0.0001233599085671 0.00785268976953207 0))
( 0.015 (-0.000277531259507496 0.0117766126774107 0))
( 0.02 (-0.00049331789293211 0.0156976298823283 0))
( 9.99 (-0.0001233599085671 -0.00785268976953189 0))
( 9.995 (-0.0000308418795848531 -0.00392682932795479 0))
( 10 (0 -3.06161699786838E-016 0))

The first column is the time in seconds, and the vector defines the point displacement. In the present tutorial, these points were calculated in libreOffice and then exported into the text file.  I arbitrarily made up the motions purely for the sake of making this blog post.

The circular motion was defined as:

x=0.25\cos\left(\pi t\right)-0.25 and y=0.25\sin\left(\pi t\right)

Decaying sinusoidal motion was:

y=\sin(\pi t) \exp\left(-t/2\right)

The rest of the set-up is identical to the set-up in the oscillating cylinder example. The solver pimpleDyMFoam is then run.


Circular Motion


Sinusoidal Decay



This post demonstrated how a more complicated motion can be prescribed by using a little math and the timeVaryingUniformFixedValue boundary condition. Always like to hear questions and comments! Has anybody else done something like this?


Turbulent Zero Pressure Gradient Flat Plate – simpleFOAM, komegaSST

An excellent test case, and case to familiarize yourself with some of the turbulence models available in OpenFOAM is a 2D flat plate with zero pressure gradient. I will solve this problem using the solver simpleFoam and the komegaSST model.

Here are the sections of this post:

  1. Quick Overview: kω-SST (komegaSST) Boundary Conditions
  2. Case set-up and mesh
  3. Results
    • u+ vs. y+
    • Coefficient of friction
  4. Conclusions and useful resources

Download the case file here: kOmega Flat Plate Tutorial File

Quick Overview: kω-SST (komegaSST) Boundary Conditions

In this section I will describe the boundary set-up for komegaSST  where no wall functions are implemented. This requires that the y+ along the wall is less than or equal to one. For the komegaSST turbulence model the boundary conditions are as follows:

At the wall:

  • ω (omega) – specific dissipation rate
    • BC type: fixedValue
    • BC value: \omega_{wall}=10\frac{6\nu_\infty}{\beta_1\left(\Delta y_{wall}\right)^2}
  • k – turbulent kinetic energy
    • BC type: fixedValue
    • BC value: 0
  • nut – turbulent viscosity
    • BC type: fixedValue
    • BC value: 0

In the free-stream:

  • ω (omega) – specific dissipation rate
    • BC type: fixedValue
    • BC value: \frac{U_\infty}{L} < \omega_{\infty} < \frac{10 U_\infty}{L}
  • k – turbulent kinetic energy
    • BC type: fixedValue
    • BC value:\frac{10^{-5}U_\infty^2}{Re_L} < k_{\infty} < \frac{0.1U_\infty^2}{Re_L}
  • nut – turbulent viscosity
    • BC type: calculated
    • BC value: 0 (this is just an initial value)

where \beta_1=0.075, and \Delta y_{wall} is the normal distance from the wall to the first cell center.

Case set-up and mesh

Free-Stream Properties

For this case I have followed a similar set up to the 2D flat plate case used on the NASA turbulence modelling resource website. By doing this it gives me something to compare to! However, I am not going to use the exact set-up on that website. Since we are using simpleFoam, I am going to set up this case the way I prefer which is to use a velocity (U) of 1 m/s and scale all other properties accordingly. The simulation properties that I used are :

  • U∞=1 m/s
  • ν=4e-7 m2/s
  • L=2 m

These correspond to a Reynolds number at L=2m of 5 million .

Grid Generation

The grid used was generated in blockMesh. High inflation was used in the boundary layer region in order to achieve the desired y+ value of less than 1. For more details on grid generation using blockMesh see the OpenFOAM manual!


Boundary Conditions

For the incompressible solver simpleFoam, the minimum boundary conditions required for a simulation are p and U. However, if the simulation is a RANS simulation additional boundary conditions are required. For the kω-SST model we need to have a boundary condition on k and ω as well. The boundary conditions I defined in the zero (0) folder can be found in the attached tutorial file.

The only boundary condition that really needs any comment is omega. We calculate omega using \omega_{wall}=10\frac{6\nu_\infty}{\beta_1\left(\Delta y_{wall}\right)^2}. In our case the wall distance to the first cell center is 5.48316E-06. Using our free stream viscosity of 4E-7 this gives a value of omega at the wall of 10643595.39.

Tip for fvSolution

If you find that the results you are getting are wrong, it could be that the residuals for the different properties are too high! Certain properties converge before others and therefore you need to ensure that they all converge to a sufficiently low value!


First we compare the coefficient of friction to the .dat file available from the .DAT available from the NASA Turbulence modelling resource. NOTE: We simulated at Reynolds number of 5 million whereas the NASA setup is at 10 million. So the x coordinate in the following is plots is rescaled and in fact we are only using half of the data from the .DAT file!

Coefficient of Friction

We can see from the figure that the coefficient of friction from our simulation matches the expected data closely! Hurray!

Next let’s compare the u+ vs. y+ profile to the  universal profile for turbulent boundary layers. Recall that u+ is the velocity normalized by the friction velocity (u_*), and y+ is given by the following equation:

y^+ = \frac{u_* y}{\nu}

The u+ is vs y+ is plotted here:

u+ vs y+

We can see from the figure that our solution is pretty good! The y+ value of the first node is located around a y+ of approximately 0.5, the viscous sublayer matches very closely and the log law layer is not significantly off!


In this post we simulated a zero pressure gradient flat plate at a Reynolds number of 5 million. We compared the results for shear stress to the NASA turbulence modelling resource expected results and showed close agreement. Then the u+ vs y+ profile was compared to the universal law of the wall and again the results were okay!

Some useful references

The NASA Turbulence Modelling Resource, http://turbmodels.larc.nasa.gov/



Pressure Driven Nozzle Flow with Shock – rhoCentralFoam

In this post I will go over the set up and solution of a pressure driven nozzle flow with a shock located in the diverging section. This refers to the type of flow problem described by region b in my page covering stationary normal shock-waves.

Continue reading Pressure Driven Nozzle Flow with Shock – rhoCentralFoam