100% found this document useful (1 vote)
435 views

CFD Tutorial 1 - Elbow

The document provides instructions for setting up a CFD simulation of flow through an elbow pipe using the FreeCAD CFD workbench. It describes installing the necessary software, creating the pipe geometry, generating a mesh, assigning boundary conditions including inlet velocities, an outlet pressure, and slip conditions on pipe walls and end faces, and initializing the simulation. The tutorial is intended to introduce the basic functionality and workflow of the CFD workbench for a simple test case of pipe elbow flow.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
435 views

CFD Tutorial 1 - Elbow

The document provides instructions for setting up a CFD simulation of flow through an elbow pipe using the FreeCAD CFD workbench. It describes installing the necessary software, creating the pipe geometry, generating a mesh, assigning boundary conditions including inlet velocities, an outlet pressure, and slip conditions on pipe walls and end faces, and initializing the simulation. The tutorial is intended to introduce the basic functionality and workflow of the CFD workbench for a simple test case of pipe elbow flow.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

FreeCAD-CFD Workbench

Tutorial 1: Elbow
CFD Workbench
WORKBENCH
This workbench aims to help users set up and run CFD analysis. It guides the user in selecting the relevant physics, specifying the
material properties, generating a mesh, assigning boundary conditions and setting the solver settings before running the
simulation. Where possible best practices are included to improve the stability of the solvers.

INSTALLATION

WINDOWS: LINUX:
● https://www.freecadweb.org/wiki/Download ● https://www.freecadweb.org/wiki/Install_on_Unix
● Install CfdOF from Tools | Addon manager ● Install CfdOF from Tools | Addon manager
● Go to Edit | Preferences | CFD to check and ● Install OpenFOAM (5.0 recommended) (https://openfoam.org/download/)
install dependencies ● Install Paraview (tested with 5.0.1)
● Optional - Install GMSH (optional, 2.13+)
● Go to Edit | Preferences | CFD to check dependencies and install cfMesh

LATEST INFORMATION
Please see the CfdOF README file for up-to-date information.

LEAD DEVELOPERS
Johan Heyns (CSIR, 2016-2018) jaheyns@gmail.com,
Oliver Oxtoby (CSIR, 2016-2018) oliveroxtoby@gmail.com,
Alfred Bogaers (CSIR, 2016-2018) abogaers@csir.co.za,
Background Outlet

● We aim to introduce the basic functionality of


the CFD workbench on a simplistic pipe
elbow with two inlets.
● The pipe flow benchmark problem is usually
modelled in 2D. Unfortunately, the CFD
workbench is currently limited to 3D problems
only. We will therefore model the problem as
a thin sliver, where the front and back faces
Inlet 1
will be treated with a slip condition.
● It is assumed that the user is familiar with
FreeCAD geometry creation.

Inlet 2
Elbow design
Part Design
2
1
Start a new sketch
A certain familiarity with the sketching
environment within FreeCAD is expected. For 3
more information on sketching and part design
see:

https://www.freecadweb.org/wiki/Sketcher_tutorial
4

https://www.freecadweb.org/wiki/Basic_Part_Design_Tutorial
6
Alternatively, have a look at the Eskom-FEM
tutorial slides. 5
Sketch
● Create the sketch on the right, with the given set
of dimensions.
● The sketch is easily created by first constructing
the primitives in the form of interconnected lines
and arcs. Then use the various constraint tools to
insert horizontal, vertical, length and radius
constraints where applicable.
● Nice tooltip descriptions of each function is shown
by hovering the mouse pointer over any of the
icons. The basic toolbars for sketch creation are

Basic primitives toolbar

Constraints toolbar
Pad the sketch
● Once the sketch has been completed,
close the sketch creation.
● While still in the “Part Design” workbench,
click on the “Pad” icon.
● Choose a length of 1m (1000mm) of Type
Dimension.
● The pad function, takes a sketch and
extrudes it in the 3rd direction.
● Click “Ok”
Fluid flow
Case setup
Activate CFD workbench
● To activate the Cfd Workbench, click on
the dropdown menu in the taskbar, and
select “CfdOF”
● Once activated, the CFD task bar should
appear.

CFD Task bar:


New CFD analysis
● To create a new analysis, click on the
“CFD” icon button (or by selecting
“Analysis Container” from the “CFD” drop
down menu).
● Along with the “CfdAnalysis” object, the
following objects are automatically
created, with a set of default values
assigned, which we will now go about
modifying for the simulation:
○ PhysicsModel
○ FluidProperties
○ IntialiseFields
○ OpenFOAM
Physics model selection
● The Physics Model Selection is where the
user specifies the desired simulation type.
● Upon creating a new analysis, default
values is applied to the “PhysicsModel”
object in the form of:
○ Steady state, incompressible, laminar flow.
● The simulation types that are not yet
supported have been grayed out.
● For the current simulation we retain the
default values as shown in the Figure.
● Click “OK” to save.
Select fluid properties
● Click on the material icon (or alternatively
double click on “FluidProperties” object or
select “Add fluid properties” from the Cfd
dropdown menu).
● The mechanical material tab will appear.
● Properties can be set by either choosing
an item from the predefined library, or by
manually entering the desired values.
● Choose “Air” from the predefined library.
● Click “OK” to save

NOTE: To change the units used by FreeCAD, or increase the number of significant figures that are displayed, see Edit->Preferences->Units
Initialise the internal flow variables
● The internal flow variables need to be
initialised prior to starting the simulation.
● Click on the initialise icon (or double click
on the “InitialiseFields” object or select
“Initialise” from the CFD dropdown menu).
● Internal flow variables can be initialised
either by using PotentialFoam, or by
individually entering the initial flow or
variables.
● Select “Potential flow” for the current
tutorial.
● Click “OK” to save.
NOTE: Potential flow uses OpenFOAM’s PotentialFoam solver to
automatically initialise internal flow variables by solving a set of
incompressible, potential flow equations.
2
Creating the mesh
● Highlight the 3D object “Pad” by clicking on it 1
in the list of objects. This will activate the
mesh Icon
● Click on the mesh Icon.
● In the Mesh task panel, choose ‘Gmsh’ as the
meshing utility (for a tetrahedral mesh)
● Enter 800 mm as the max element size 4
characteristic length (as a start, you can make
a more coarse mesh by setting it to 1500
mm). 3
● Click on the “Mesh” button.
TIP: When meshing, start with as coarse a mesh as
possible. Once a mesh has been successfully created,
only then is it advised to refine the mesh. It can take a
very long time to create highly refined meshes.

NOTE: In the follow up tutorials, we will show how a mesh


with different refinement regions can be generated. For
now, we make use of a constant sized mesh.
Adding boundary conditions: Inlet 1 1
● To add a new boundary condition, click on
the boundary condition icon.
● Let’s add the first inlet boundary condition.
○ Click on the first inlet face, and click 6 3
“Add Face” button. 2
○ Change “boundary” to “Inlet”
○ Change “subtype” to “Uniform velocity”
○ Specify cartesian velocity components
to U=(1m/s,0m/s,0m/s). (this can also
be done by specifying “Magnitude and
4
normal”).
○ Change the object name to “Inlet1”.
The object name can be changed by
pressing “F2” on the object list or by 5
right clicking and choosing “Rename”.
Adding boundary conditions: Inlet 2
● As with “Inlet1”, choose the corresponding
face and click “Add face”.
● Choose Boundary: “Inlet”
● Choose Subtype: “Uniform velocity”
● Enter velocity corresponding to
U=(0m/s,3m/s,0m/s).
● Rename the object to “Inlet2”.

Note: Inlet boundary conditions are colored blue.


Adding boundary conditions: Outlet
● Select the correct face, and click “Add
face” button.
● Change Boundary: “Outlet”
● Change Subtype: “Static pressure”
● Set Pressure: 0 m/kg/s^2.
● Change object name to “Outlet”

Note: Output faces are colored in red.

Note: In incompressible simulations, pressure is treated as a


relative value (‘gauge pressure’)
Adding boundary conditions: Pipe walls
● Add all the wall faces and set the walls as Boundary:
“wall”, Subtype: “slip”
● Multiple faces can be added in one of two ways:
1. Click on “Add face” without having selected any
faces. All the faces can then one by one be
added. Once all the desired faces have been
selected, click “Add face” button again to deselect
the button.
2. Multiple faces can be simultaneously
highlighted/selected by holding in the “Ctrl” button
while clicking on multiple faces.

Note: Walls are colored in dark grey.


Adding boundary conditions: Front and back slip
● Finally, we add the front and back face
boundary conditions.
● To emulate a 2D simulation in 3D, we set
the front and back faces to a “slip”
boundary condition.

Tip: Boundary faces that are not specified default to “slip”.


Final set of properties
● If correctly set up, CfdAnalysis should now
contain the following set of items.
● To make sure all boundary conditions
have been allocated correctly, as a final
check you can hide all objects, and one by
one make each of the boundaries visible.
Click on the item and press “spacebar” or
right-click, and select “toggle visibility”.
● We are now ready to run the CFD
simulation.
Solver control settings
● The solver settings can be modified by
○ Highlighting the “OpenFOAM” object.
○ At the bottom select the “Data” tab.
● The following settings can be modified
○ Parallel: True/False
○ Parallel Cores: If Parallel=True, set the number of
cores to be used
○ End Time:
■ Steady state: Maximum number of
iterations
■ Transient: End time
○ Time Step: Time step size for transient simulations
(default = 1 for steady state, 0.001 for transient).
○ Write Interval: How frequently information is stored
to the hard drive for post processing.
○ Convergence Criteria: default = 1e-4.

Note: Convergence criteria will not necessarily be achievable if transient flow


structures are present, which will result in residuals flattening out at a nonzero
value. If in doubt, convergence of quantities being calculated (e.g. lift) should
be checked.
Write the case to a directory
● Click on the solver icon (or double click on
“OpenFOAM” or select “Solver job control”
from the CFD dropdown menu). Initial If successful
● “Working Directory” is the directory where the
simulation will be temporarily stored.
WARNING: If the case within the directory
already exists, it will be overridden.
● Click “Write” button.
● Depending on the mesh size, writing the case
directory may take some time.
● If successful, the output message will state so
accordingly.
● The “Edit” button will open the case directory
for manual editing.
Running the CFD simulation
● If the case was successfully created, the
“Run” button will become active.
● Clicking “Run” starts the simulation which
can be terminated at any time by clicking
“Stop”.
● A dynamic residual plot will be shown.
● The solver stops naturally once the
convergence criteria has been satisfied or
maximum number of iterations have been
reached. Default convergence criteria is
1e-4 for Ux,Uy,Uz and pressure.
● To view the results, click the “Paraview”
button.
Post-processing: Paraview
What to plot, Time step
An assortment of eg. U or to plot
post-processing tools, pressure.
such as plotting glyphs,
streamlines,
cross-section, contours
etc.

Refresh button: If
simulation is still
running, refresh to load
new information as it
becomes available.

For more information visit: http://www.paraview.org/Wiki/The_ParaView_Tutorial


Optional: Creating a 2D mesh
● Since we are modelling a 2D problem, we would
like to have a mesh with only one element
through the thickness
● First delete the previous ‘slipWalls’ boundary
condition by right-clicking it in the tree view and
selecting ‘Delete’
● Now create a boundary condition for the front
plane, selecting Boundary: ‘Constraint’ and
Subtype: ‘2D bounding plane’
● For the back plane, create a second boundary
condition in the same way
● Now, re-generate the mesh and re-run the
analysis

Note: Currently, a full 3D mesh is first created and then extruded to form the
2D mesh, so it is best to mesh a thin object to avoid spending too much time
generating lots of unused cells
The End

You might also like