Skip to main content

Ahmed Body Modeling and OpenFOAM Connection

!cover image

In this tutorial, you will learn how to model the Ahmed Body, which is a simplified, standardized vehicle model widely used in computational fluid dynamics (CFD) research and automotive aerodynamics. In the second part of the tutorial you will learn how to connect an OpenFOAM with CAESES and how to visualize the results.

  • Start by downloading the CAESES project, which will be our starting point:
Download Starting Model

note

The starting project file does not contain any geometry yet. However, it comes with a starting point for the OpenFOAM software connection in the Connect workspace.

Ahmed Body Modeling

Parameters

In the first step, create all parameters that define the parametric geometry of the Ahmed Body and can later be used in an optimization process if converted to Design Variables with bounds.

  • Create a Scope via Model > CAD > Scope and set the name to 01_parameter.
  • Turn this scope into the Working Scope by clicking on its symbol in the tree with the middle mouse button. This ensures that all newly created parameters are stored inside this scope.
  • Create the Parameter via Model > CAD > Parameter and set:
    • Name: x_LOA
    • Value: 1.044
  • Create additional parameters as shown in the following table:
Parameter NameValue
front_contour_radius0.1
y_full_model_width0.389
z_body_height0.288
slant_angle40
slanting_section_length0.222
x_stand_front-0.842
x_stand_rear-0.372
y_stands0.1635
z_stand_height0.05
stand_diameter0.03

!cover image

Points

Utilizing the above created parameters, we create parametric points which will be used for the outline of the Ahmed Body.

  • Create a new Scope via Model > CAD > Scope and name it 00_points.
  • Create a 3D Point via Model > CAD > Points > 3D Point.

Enter the following coordinates:

  • X: -|01_parameter|x_LOA + |01_parameter|front_contour_radius
  • Y: |01_parameter|y_full_model_width / 2
  • Z: |01_parameter|z_stand_height + |01_parameter|z_body_height

and set its name to p0.

Create four more points with the following values:

p1

  • X: -(cos(|01_parameter|slant_angle) * |01_parameter|slanting_section_length)
  • Y: |01_parameter|y_full_model_width / 2
  • Z: |01_parameter|z_stand_height + |01_parameter|z_body_height

p2

  • X: -|01_parameter|x_LOA + |01_parameter|front_contour_radius
  • Y: |01_parameter|y_full_model_width / 2
  • Z: |01_parameter|z_stand_height + |01_parameter|z_body_height

p3

  • X: -|01_parameter|x_LOA + |01_parameter|front_contour_radius
  • Y: |01_parameter|y_full_model_width / 2
  • Z: |01_parameter|z_stand_height + |01_parameter|z_body_height

p4

  • X: -|01_parameter|x_LOA + |01_parameter|front_contour_radius
  • Y: |01_parameter|y_full_model_width / 2
  • Z: |01_parameter|z_stand_height + |01_parameter|z_body_height

!cover image

Curves

From the created points, curves representing the contour of the body are generated. The geometry is divided into a body and stands.

  • Create a new scope via Model > CAD > Scope and name it 01_curves.
  • Inside this scope, create another scope named body.
  • Select it with the middle mouse button to make it active (green scope icon).
  • Select all points from 00_points and create a curve via Model > CAD > Point Based > Polyline.
  • Rename this curve to body_contour.
caution

To close the contour, the first point (p0) must be listed twice in the Polyline input – once at the beginning and once at the end.

  • In the curve settings under Input > Points, add another point at the end by writing in the empty field: |00_points|p0.

!cover image

Rounded Front – Upper Part

To model the rounded front upper contour of the Ahmed Body:

  1. Create a Circle Arc inside the scope 01_curves > body via Model > CAD > Arc > Circle and name it front_upper.
  2. Set the arguments as:
    • Start Angle: 90
    • End Angle: 180
    • Radius: |01_parameter|front_contour_radius
  3. Add a new operation via add new operation > Transformations > Rotation and set the arguments:
    • Angle: -45
    • Origin: [0, |01_parameter|front_contour_radius, 0]
  4. Add another operation via add new operation > Transformations > Rotation and set the arguments:
    • Dx: |00_points|p4:X
    • Dy: |00_points|p4:Y - |01_parameter|front_contour_radius
    • Dz: |00_points|p4:Z

Rounded Front – Lower Part

Similarly, for the front lower contour:

  1. Create a Circle Arc inside the scope 01_curves > body via Model > CAD > Arc > Circle and name it front_lower.
  2. Set the arguments as:
    • Start Angle: 90
    • End Angle: 180
    • Radius: |01_parameter|front_contour_radius
  3. Add a new operation via add new operation > Transformations > Rotation and set the arguments:
    • Angle: 45
    • Origin: [0, |01_parameter|front_contour_radius, 0]
  4. Add another operation via add new operation > Transformations > Rotation and set the arguments:
    • Dx: |00_points|p0:X
    • Dy: |00_points|p0:Y - |01_parameter|front_contour_radius
    • Dz: |00_points|p0:Z

!cover image

Stands

The next step is to model the stands of the Ahmed Body.

  • Inside 01_curves, create another scope via Model > CAD > Scope and set the name to stand.
  • Create a Circle Arc via Model > CAD > Arc > Circle and set the following arguments:
    • Name: front
    • Radius: |01_parameter|stand_diameter / 2
    • Add a new operation via add new operation > Transformations > Translation
    • Set Dx to |01_parameter|x_stand_front and Dy to |01_parameter|y_stands
  • Select the arc front in the tree and create another arc via Model > CAD > Arc > Circle with the arguments:
    • Name: rear
    • Add a new operation via add new operation > Transformations > Translation
    • Set Dx to |01_parameter|x_stand_rear and Dy to |01_parameter|y_stands

!cover image

Surface and BReps

In this step, a surface is created from the two curves of the rounded front. With this surface and the body contour curve, a BRep can be created and extruded. The stands are also modeled in this step by extruding the stand curves.

Front Surface

  • Create another scope via Model > CAD > Scope and set the name to 02_surfaces.
  • Inside this scope create a Ruled Surface via Model > CAD > Surface > Ruled and set the name to front.
  • For Curve A select |00_half_model|01_curves|body|front_upper and for Curve B select |00_half_model|01_curves|body|front_lower.

!cover image

BRep Body

  • Create another scope via Model > CAD > Scope and set the name to 03_breps.
  • Inside this scope create a Brep via Model > CAD > BRep and name it body.
  • Click the pencil icon next to Operations > Sources | add sources.
  • Fill in the Sources: 02_surfaces|front.
  • Add the operation Face from Planar Curves to body via add new operations > Closing > Face from Planar Curves.

A window with sources opens automatically.

  • Add into Sources: |01_curves|body|body_contour.

To create a three-dimensional body, the BRep will be extruded.

  • Add the operation Extrude Edges to Plane via add new operations > Extrusion > Extrude Edges to Plane.
  • Inside the extrude settings select for Plane: Y-(Z,X) and for Plane Position: 0.
  • Also enable the Close Extrusion checkbox.

!cover image

The stands are extruded as well.

  • Create another BRep via Model > CAD > BRep and name it stands.
  • Click the icon next to Operations > Sources | add sources.
  • Fill in the Sources: |01_curves|stand|front and |01_curves|stand|rear.
  • Add the operation Extrude Edges to Plane via add new operations > Extrusion > Extrude Edges to Plane.
  • Inside the extrude settings select for Plane: Z-(X,Y) and for Plane Position: |01_parameter|z_stand_height + 0.01.
  • As for the body, also activate for stands the Close Extrusion checkbox.

!cover image

To store everything in one scope:

  • Select 00_points, 01_curves, 02_surfaces, 03_breps and create another scope via Model > CAD > Scope and set the name to "00_half_model".

!cover image

OpenFOAM Setup

In this step an OpenFOAM connection will be created.

OpenFOAM Files

An OpenFOAM setup for the Ahmed Body is already imported in this project.

  • Set the workspace with the left navigation bar to Connect.
  • Click on the already existing ahmed_body software connection via Connect > Connection > Computations > ahmed_body.

On the right you can see in the Input Files area all the relevant OpenFOAM files. You can add more or different files if needed by drag and drop or by clicking on the plus icon in the upper left corner of the Input Files.

  • Double-click on the file BlockMeshDict to open it inside CAESES.

To create the correct folder structure of OpenFOAM, the name of each file needs to contain the relative file path.

  • Change the name of the BlockMeshDict via the field next to Template Name to system/blockMeshDict.

!cover image

  • Do the last two steps with all the other files as well and change the names as shown in the picture.

!cover image

The OpenFOAM commands are executed via an Allrun.sh script.
If you use the Windows version of CAESES, WSL2 (Windows Subsystem for Linux) can be used to run OpenFOAM, since OpenFOAM is a Linux-based application only.

Prerequisites
  • WSL2 must be installed and configured.
  • OpenFOAM must already be installed in WSL.

To start WSL and run the Allrun script, a run.bat file is used.
This batch file is triggered directly from CAESES via the connector.

  • Click on the computation ahmed_body via Connect > Connection > Computation > ahmed_body.
  • In the Execution Settings, click the plus icon next to the Application field to create a new application.
  • Name the new application: "OpenFOAM"
  • In the field Executable, enter: run.bat
tip

If you run CAESES on linux, the batch script is not needed and you can directly use the Allrun.sh file.

!cover image

Export Geometry

In this step, the geometry for OpenFOAM will be specified.

  • Create a new scope via Model > CAD > Scope and set the name to "02_OpenFOAM".
  • Inside this scope, create another Scope named "00_geometry".
  • Inside 00_geometry, create a BRep via Model > CAD > BRep and name it export_geometry.
  • Add sources by clicking the icon next to Operations > Sources | Add Sources and fill in the Sources: |00_half_model|03_breps|body.
  • In Sources, assign a color to the body.

You can also create a new color by clicking on the icon next to the field. To merge the stands into the body:

  • Add a new operation to export_geometry via Add New Operations > Boolean > Boolean Operation.
  • In this operation, set the sources to: |00_half_model|03_breps|stands.
  • Assign a color which is different from the color of the body.

!cover image

To connect the export_geometry to OpenFOAM:

  • Switch the workspace to Connect using the left navigation bar. Open the connection ahmed_body via Connect > Connection > Computations > ahmed_body.
  • Add an Input Geometry by clicking the plus icon in the top-left corner of the Input Geometry area.

In the automatically opening dialog, enter:

  • File Name: constant/triSurface/ahmed.stl
  • Export Type: MultiBodySTL
  • Entry Value: Filename only
  • In the empty field below Entry Value, enter: |02_OpenFOAM|00_geometry|export_geometry

!cover image

Simulation Parameters

In this step, certain OpenFOAM simulation parameters are linked to CAESES parameters.

Step 1: Create New Entry in Configurations

  • Switch to the Connect workspace.
  • Open the ahmed_body connection and double-click the file system/controlDict.
  • Select the line containing endTime (highlighted in green).

A new Entry is automatically created in the configuration tree on the left.

Step 2: Create a Parameter from the Entry

  • Highlight the value (e.g., 60).
  • Right-click and choose Create Parameter.
  • Rename the parameter to endTime.

!cover image

Repeat Step 1 and Step 2

Repeat this process for all parameters listed below:

Entry NameOpenFOAM FileLineParameter Name
flowVelocity0.orig/include/initialConditions9flowVelocity
nu_airconstant/transportProperties19nu_air
magUInfsystem/forceCoeffs27magUInf
IRefsystem/forceCoeffs28IRef
Arefsystem/forceCoeffs29Aref
numberOfSubdomainssystem/decomposeParDict17nProcs
nProcsAllrun.sh13nProcs

!cover image

Organizing Parameters

To keep the parameters structured, create scopes inside 02_OpenFOAM:

  • Create a new scope inside 02_OpenFOAM via Model > CAD > Scope and set the name to 01_run_controls.
  • Drag and drop the parameters endTime and nProcs into this scope.
  • Create a new scope inside 02_OpenFOAM via Model > CAD > Scope and set the name to 02_physics.
  • Drag and drop the parameters flowVelocity and nu_air into this scope.
  • Create a new scope inside 02_OpenFOAM via Model > CAD > Scope and set the name to 03_reference_values.
  • Drag and drop the parameters Aref and lRef into this scope.

!cover image

OpenFOAM Environment Setup

The OpenFOAM environment is defined in the Allrun.sh script. Here, the path to the OpenFOAM bash script must be specified.

  • Create in the scope 01_run_controls a String Parameter via Model > CAD > More > String Parameter.
  • Name it: foamDotFile and fill in your path to the OpenFOAM bash script (for example: "/opt/OpenFOAM/OpenFOAM-v2012/etc/bashrc").
  • Open the Allrun.sh script and highlight the path behind the source command (line 6).
  • Right-click the highlighted string and choose New Entry.
  • Double-click the newly created entry, rename it to OFPath.
  • In the value field, enter: |02_OpenFOAM|01_run_controls|foamDotFile.
  • Store this string parameter inside the scope 02_OpenFOAM|01_run_controls.

This links the CAESES parameter directly to the OpenFOAM environment path.

!cover image

Post-Processing

Simulation results (e.g., force coefficients) can be made accessible inside CAESES.

  • Switch the workspace to Connect and open the ahmed_body computation via Connect > Connection > Computation > ahmed_body.
  • To store it in the folder structure of OpenFOAM, double-click on the file coefficient.dat in the Result Values area.
  • Change the subfolder via General > Subfolder to: postProcessing/forceCoeffs1/0/.

To read the last column of this file:

  • Click the plus icon in Values next to the entry Name.

Set the following arguments:

  • Change the entry Name to Cd.
  • Line: 212.
  • Column: 1.

To create a parameter from the result coefficient:

  • Click the parameter icon f(x) in the Results Preview.
  • Change the name of the parameter to Cd.

!cover image

To also read the lift coefficient, create another result value with:

  • Name: Cl.
  • Line: 212.
  • Column: 3.
  • Click the parameter icon f(x).
  • Change the name of the parameter to Cl.

Both result parameters should be stored in a scope:

  • Create a new scope via Model > CAD > Scope and set the name to 04_results inside the scope 02_OpenFOAM.
  • Drag and drop the parameters Cd and Cl inside this scope.

Run Simulation

In this step, the simulation is triggered:

  • Open the computation ahmed_body via Connect > Connection > Computation > ahmed_body.
  • Click the green play icon next to the name entry.

!cover image

Visualization

To show the pressure or velocity field:

  • Open in the Connect workspace the Post-Processing via Connect > Post-Processing > Results > ahmed_body > internalMesh.
  • Select from the drop-down menu in the Visualization settings create new.

!cover image

  • In Data Extraction click on FGridPlaneCut.

In the GridPlaneCut1 settings:

  • Position: 0.01.

  • Plane: Y-(Z,X).

  • Click in the Visualization field in the empty entry and select from the drop-down menu create new.

!cover image

  • Select FContourPlot.
  • In contourPlot1 set the Mapped Data to [U].

In the 3D view the velocity field should now be displayed. If you want to see the pressure field, select p for Mapped Data. To hide or show the data in the 3D view:

  • Click on the icon next to internalMesh.

!cover image

Final Setup

CAESES Project File

If you want to take a look at the finalized model, you can find the resulting CAESES project file ahmed-body-open-foam.cdb here:
Load Final Model