CFD Tutorial 2a - Mesh Regions and Porous Media (snappyHexMesh)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 28
At a glance
Powered by AI
The CFD Workbench guides users through setting up and running CFD simulations in FreeCAD. It helps with selecting physics models, defining materials, generating meshes, applying boundary conditions, and running solvers.

The CFD 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.

To create the initial mesh, a new CfdAnalysis is created, the cube object is highlighted to activate meshing tools, snappyHexMesh is selected as the meshing utility, and a base element size is specified before generating the mesh.

FreeCAD-CFD Workbench

Tutorial 2: Multi-region mesh generation and porous


media using snappyHexMesh
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 (https://openfoam.com/download/)
install dependencies ● Install Paraview
● 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) [email protected],
Oliver Oxtoby (CSIR, 2016-2018) [email protected],
Alfred Bogaers (CSIR, 2016-2018) [email protected],
Part Design
2
1
Create Cube
● As part of this tutorial, we are going
to create a long thin cube with an
internal porous zone and a porous
baffle. 3
● To create the first cube, activate
the “Part” workbench.
● Click on the predefined primitive 4
“Cube” icon.
● To change the cube’s length, width
and height:
○ Highlight the “Cube” object
○ Within the “Data” tab, change the
properties
Length: 500mm, Width: 500mm, Height: 5
40000mm
Add 1 More Cube
● Create 1 more cube:

Length: 500mm, Width: 500mm, Height: 1000mm

● This cube will become our porous


zone and we would like it to be
placed in the centre of our large
cube.
● To move the cube
○ Click on “Placement” in the data tab.
○ Edit the z-”Position” property to
move the cube to z=1500mm
Mesh generation and mesh
refinement with
snappyHexMesh
Activate CfdOF Workbench
● To activate the CfdOF Workbench, click on
the dropdown menu in the taskbar, and
select “CfdOF”
● Once activated, the CfdOF task bar should
appear.

CfdOF Task bar:


Creating the Initial Mesh 1 3

● In order to create a cartesian mesh using


snappyHexMesh, we first need to create a
new CfdAnalysis 2
● Highlight the Cube object which will
activate the meshing icons.
● Click on the Mesh icon.
6
● Select snappyHexMesh as the mesh
utility.
● Set base element size as 50mm (NOTE: if 4
nothing is set a default size will 5
automatically be set based on the object
size).
● Click “Mesh”.

NOTE: The tetrahedral mesh is only for illustrative purposes. The


real mesh is a cut-cell cartesian mesh. To see the real mesh, please
use the paraview post processor (by clicking on the “Paraview”
button).
Refining Selected Regions
● Highlight the mesh object, which will
activate the mesh region icon.
● Click on the mesh region icon (or select
“Mesh Region” from the CFD drop down
menu).
● A “MeshRegion” object will now have been
created (if not visible, expand the
“Box_CartesianMesh” object by clicking on
the “+”).
● Double click “MeshRegion” which will open
the “Mesh region” task panel.
● In this task panel, we can now select
shapes in the form faces to be locally
refined.
Making specific objects visible 3
1

● We wish to now select specific faces to refine,


which may not be visible. 2
● It is possible to only make some of the parts
visible, to assist in selecting specific regions,
or faces to refine.
● To make specific shapes visible or invisible,
click on the “Model” tab.
● Objects can be made visible by clicking on
them in the list of objects, and pressing
“spacebar”, or right-clicking and selecting
“Show Selection” or “Hide Selection”.
● Make the middle cube, the Cube001 object
visible.
● With the middle cube now visible, return to
the mesh region task panel, by clicking on the
“Tasks” tab.
Select regions and setting for refinement
● We wish to refine all the faces within the 4
central region. 2
● Click “Add reference”, then systematically
go about selecting all of the faces
belonging to the Cube001 object. 3
● Set refinement levels to 1.
● Click Ok.

NOTE: Refinement level when using snappyHexMesh


1
relates to the number of times the mesh falling along the
chosen surfaces are to be refined. A value of 1, means
the mesh along the chosen surfaces will be refined
once, and therefore will be half the size of the original
mesh.
Re-compute the new mesh
● In the list of objects, double-click on the
parent (“Box_CartesianMesh”) mesh
object (or right-click and select
“Transform”).
● Click “Mesh” to re-compute the mesh with
the new refined region.
● The new mesh should now be locally
refined along the centre.

NOTE: The tetrahedral mesh is for representative purposes only. To


view the true cut-cell cartesian mesh click on the “Paraview” button.
Porous-zones
1
Adding porous-zone
● Click on the porous-zone icon.
5
● For the test problem, we wish to make the
central cube a porous region. 2
● Select the central cube and click “Add
solid”.
● NOTE: Porosity will be added to all the
cells contained inside, and intersected by
the selected shape (in our case “Box001”). 3
● There are two types of porosity
approximations currently included
○ Darcy-Forcheimer
○ Jakob staggered tube bundle 4

Tip: porous zones are coloured purple once selected.


Adding the remaining boundaries
● Following the instructions provided in Outlet:
Walls: Static pressure
Tutorial #1, add boundary conditions, for
Slip P=0
the inlet, side walls and outlet.
● The remaining settings include:
○ Fluid: air
○ Initialise with potential flow

Inlet:
Uniform Velocity
U = (0,0,1 m/s)
Porous zone results
● With the problem setup we can now write
the test case, and run the solver.
● We show here the residual plot and
pressure results for the porous zone test
problem.
● Notice the large pressure drop across the
porous zone.

NOTE: The pressure solved for by OpenFOAM is p = P/density.


Porous baffle
Creating a porous baffle
● A porous baffle is created by setting the
“Baffle” option within snappyHexMesh
refinement regions, and then adding a
corresponding “baffle” boundary condition.
● We reset our previous simulation and
remove the previously created porous
zone.
● We now need to create a face, which we
will position within the centre of our
analysis domain.
Initialise the sketch
● There are multiple ways of creating faces.
● We are going to do so by creating a sketch
of a rectangle, and creating a face from
the edges.
● Activate the sketcher workbench.
● Highlight the leftmost face, and click on
the “sketcher” icon. This will open a
prompt asking where to place the sketch.
● Select “FlatFace”, this is the current face
you have highlighted, allowing us to create
a sketch directly onto the highlighted face.
Draw a rectangle 1

● We start by creating reference lines.


These lines link the edges from the
already existing Cube object to our newly
created sketch.
● To do so, click on the create edge link 2
icon, then select the edges of pre-existing 3
cube face.
● We now draw a rectangle, and make the
corners coincident with our reference
lines.
● Once all the corners of the rectangle are
coincident with the reference lines, there
should now be a rectangle of equal size to
that of the Cube’s face.
1
Create face from edges
● In order to change our sketch into a face,
activate the “Part” workbench.
● Click on the “Advanced shape utility” icon. 2
● Select “Face from edges” option.
● Select all the edges of our newly created
sketch (NOTE: hold in “Ctrl” to select more
than one edge simultaneously).
● Click “Create”.

3 4
Move face
● Move the newly created face to the centre
of the 3 cubes. To do so: 1
○ Highlight the “Face” in the list of objects.
○ Within the “Data” tab, change the
z-Position to 2000mm.
● As before, create a snappyHexMesh with
a characteristic length of 50mm.
3
2
Set mesh baffle mesh region
1
● After having created a snappyHexMesh
object, highlight the mesh object and click
on the MeshRegion icon. 6
● As before, click on “Add reference”, select 3
the face and set the levels of refinement.
● Importantly, ensure that the “Baffle” option
4
is selected. By selecting the Baffle option,
guarantees that snappyHexMesh
generates an internal face of 0 thickness. 5
2
Re-compute the new mesh
● In the list of objects, double-click on the
parent (“Box_CartesianMesh”) mesh
object (or right-click and select
“Transform”).
● Click “Mesh” to re-compute the mesh with
the new refined region.
● The mesh should now be locally refined in
the vicinity of the newly created internal
face.
Add porous baffle 1

● A porous baffle is added by adding the


“Baffle” boundary condition.
● Click on the boundary condition icon.
● Select “Baffle” from the Boundary Type.
2
● Click on the “Face” and click “Add face”
● Specify either the “Pressure loss
parameters” or “Wire screen parameters”.

TIP: Recall, that various objects can be made visible or hidden in 4 3


the “Model” tab by highlighting the objects and pressing spacebar
(or right-clicking and selecting Show/Hide). This may be necessary
to select the “Face”. 5

TIP: The baffle Face can alternatively be added by highlighting the


“Face” object in the list of objects under the “Model” tab, and then
clicking “Add face” within the still open CFD boundary condition
“Tasks” tab.
Adding the remaining boundaries
● Following the instructions provided in
Tutorial #1, add the remaining inlet, side
walls and outlet boundary conditions. Outlet:
Walls: no-slip (viscous) Static pressure
● The remaining settings include:
P=0
○ Fluid: air
○ Initialise with potential flow

Inlet:
Uniform velocity
U=(0,0,1 m/s)
Porous baffle results
● With the problem setup we can now write
the test case, and run the solver.
● We show here the residual plot and
pressure results for the baffle test problem
● Notice the large distinct pressure drop
across the porous baffle.

NOTE: The pressure solved for by OpenFOAM is the density


normalised pressure:
p = P/density.
The End

You might also like