Tag Archives: simpleFoam

The Ahmed Body

The Ahmed body is a geometric shape first proposed by Ahmed and Ramm in 1984. The shape provides a model to study geometric effects on the wakes of ground vehicles (like cars).

Image highlights:

In this post, I will use simpleFoam to simulate the Ahmed body at a Reynolds number of 10^6 using the k-omega SST turbulence model. The geometry was meshed using cfMesh which I will briefly discuss as well. Here is a breakdown of this post:

  1. Geometry Definition
  2. Meshing with cfMesh
  3. Boundary Conditions
  4. Results

The files for this case can be downloaded here:

Download Case Files

Note: I ran this case on my computer with 6 Intel – i7 (3.2 GHz) cores and 32 Gb of RAM. Throughout the simulation about 20-ish gigs of RAM were used.

Geometry Definition

STL Creation

The meshing utility cfMesh is similar to snappyHexMesh in that it depends on a geometry file of some type (.stl etc) to create the mesh. But it is different in that the entire domain must be part of the definition.

The ahmed body geometry can be found: http://www.cfd-online.com/Wiki/File:Ahmed.gif

For this simulation, I generated the geometry using SolidWorks. But this wasn’t for any particular reason other than that it was quick since I am familiar with it.

Preparation for Meshing

Once you have an STL file, you could go straight ahead to meshing it with cfMesh. However, some simple preparations to the STL geometry can improve the quality of the mesh created, and make setting up the case easier.

In particular, when you create the STL file in SolidWorks (or your 3D modeller of choice)  it contains no information about the boundaries and patches. As well, cfMesh works best if the geometry is defined using a .fms or .ftr file format.

Use surfaceFeatureEdge utility to extract edge information and create a .ftr file. Firstly let’s extract edge and face information from our STL file. We also define an angle. This angle tells cfMesh that any angle change large than this (in our case I chose 20 degrees) is a feature edge that must be matched.

surfaceFeatureEdge volume.stl volume.ftr -angle 20

After we run this, the new file volume.ftr contains a bunch of face and patch information. 13 surfaces with feature edges were extracted. The first 6 (volume_0 to volume_5) are the boundaries of the simulation (inlet, outlet, ground, front, back, and top).

mergeSurfacePatches volume.ftr ahmed -patchNames '(volume_6 volume_7 volume_8 volume_9 volume_10 volume_11 volume_12)'

After running this command, volume.ftr now contains 7 patches. We are now ready to move on to setting up cfMesh.

Meshing with cfMesh

Set up meshDict file in the system folder

Similar to snappyHexMesh and blockMesh, cfMesh using a dictionary file to control its parameters; meshDict. In this dictionary file we will be modifying a few parameters.

Tell cfMesh what file is to be meshed:

surfaceFile "volume_transformed.ftr";

Set the default grid size:

maxCellSize 0.2;

Set up refinement zones:

We want to set up two refinement zones; a larger one to capture most of the flow further away from the body (including the far wake), and a smaller more refined one to capture the near wake and the flow very close to the Ahmed body.

objectRefinements
{
 box1
 {
    cellSize 25e-3;
    type box;
    centre (2.4 0 6.5);
    lengthX 1;
    lengthY 1;
    lengthZ 3.5;
 }

box2
 {
    cellSize 5e-3;
    type box;
    centre (2.4 0 7);
    lengthX 0.5;
    lengthY 1;
    lengthZ 2;
 }

}

Set up boundaries to be renamed:

renameBoundary
{
 newPatchNames
 {
 volume_0
 {
 newName ground;
 type wall;
 }
 volume_1
 {
 newName back;
 type wall;
 }
 volume_2
 {
 newName inlet;
 type patch;
 }
 volume_3
 {
 newName front;
 type wall;
 }
 volume_4
 {
 newName outlet;
 type wall;
 }
 volume_5
 {
 newName top;
 type patch;
 }
 ahmed
 {
 newName ahmed;
 type wall;
 }
}

Set up boundary layering:

We require boundary layer on both the Ahmed body, as well as the volume_0 patch. Recall that the Ahmed body is surface mounted!

boundaryLayers
{
 patchBoundaryLayers
 {
 ahmed
 {
 nLayers 10;
 thicknessRatio 1.1;
 maxFirstLayerThickness 5e-3;
 }
 volume_0 
 {
 nLayers 10;
 thicknessRatio 1.05;
 maxFirstLayerThickness 10e-3;
 }

 }
}

Run cfMesh

We want to create a hex-dominant grid. This means that the 3D grid will consist primarily of hex cells. To achieve this we will use the cartesianMesh solver from cfMesh.

The results are shown below. The final mesh consisted of approximately 16.9 million cells. The majority of the cells were hexahedra (approximately 99%).

 

Boundary Conditions for the Solver

For this case, we are going to run a steady-state RANS simulation using the kwSST model and the solver simpleFOAM. This is simply to demonstrate the running of the solver.

The boundary conditions used are summarized in the following table:

bctable

As you can see I have used wall functions for the wall boundary conditions. This is due to the very small cell requirements that would be required to resolve the boundary layer on the ground, as well as on the Ahmed body which is at a Reynolds number of one million.

Simulation Results

The simulation took about a day and a half on 6 cores. Throughout the simulation, about 20 gb of RAM was used.

Cross-Section:

Streamlines and pressure on surface:

cropped-ahmedstreamliens.png

Vorticity surface in the near-wake

nearwake

Conclusions

In this post, we meshed and simulated a surface-mounted Ahmed body at a Reynolds number of one million. We meshed it using the open-source meshing add-on cfMesh. We then solved it as a steady-state RANS simulation using the kwSST turbulence model, and the simpleFOAM solver.

The results gave some nice figures and a qualitatively correct result! And it was pretty fun. cfMesh was extremely easy to use and required much less user input than its OpenCFD counterpart snappyHexMesh.

Some references:

For more information on the Ahmed body:

http://www.cfd-online.com/Wiki/Ahmed_body

Some papers studying the Ahmed body:

-See the reference on the above CFD Online page!

 

As usual please comment and let me know what you think!

 

Cheers,

curiosityFluids

curiosityFluidsLogo

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!

Grid_BoundaryTypes
Grid

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!

Results

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!

kOmegaCf
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:

kOmegauy
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!

Conclusions

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/