Professional Documents
Culture Documents
Nozzle
Note:
● This tutorial has only didactic purpose, aiming to help beginners, and it does
not guarantee quality of simulation results. Verification and validation of the
results, and also the study of mesh refinement and other analyzes are left as
responsibility of the user.
● This offering is not approved or endorsed by OpenCFD Limited, producer and
distributor of the OpenFOAM software via www.openfoam.com, and owner of
the OPENFOAM® and OpenCFD® trade marks.
● This tutorial was created within the context of an UFSC extension project and
it is not approved by GMSH and OpenFOAM® developers.
● This tutorial was prepared by the undergraduate student Juliano Simon, under
the supervision of Filipe Dutra da Silva.
● Please quote this page if you use this material. Questions and suggestions
can be sent to the contact addresses shown at the end of this page.
In this tutorial it will be presented the process of creating a mesh and a structured
mesh for the simulation of flow in an axisymmetric nozzle using the Gmsh code.
There are two ways of using Gmsh: through the commands of the graphical interface
of the software or editing the script with extension .geo, which is generated by the
software. Both ways of using the software will be shown here. To open the script, go
to Modules → Geometry and click on Edit Script.
The first step is the declaration of geometry coordinates. In the file .geo type the
geometry coordinates in the format “Point(1) = (0,0,0,1.0);”, where the first three
terms are, respectively, x, y and z coordinates. Thus, the file should have the
following setting:
Point(1) = {-0.254,0,0,1.0};
Point(2) = {-0.199,0,0,1.0};
Point(3) = {0,0,0,1.0};
Point(4) = {2.496,0,0,1.0};
//-----
Point(16) = {2.496,0.3762,0,1.0};
Point(17) = {-0.254,0.6,0,1.0};
Point(18) = {-0.199,0.608,0,1.0};
Point(19) = {0,0.6369,0,1.0};
Point(20) = {2.496,1,0,1.0};
//================================
//+
Line(1) = {1, 2};
//+
Line(2) = {2, 3};
//+
Line(3) = {3, 4};
//+
Line(4) = {4, 16};
//+
Line(5) = {16, 20};
//+
Line(6) = {20, 19};
//+
Line(7) = {19, 18};
//+
Line(8) = {18, 17};
//+
Line(9) = {17, 11};
//+
Line(10) = {5, 1};
//+
Line(11) = {2, 6};
//+
Line(12) = {12, 18};
//+
Line(13) = {3, 10};
//+
Line(14) = {10, 19};
//+
Line(15) = {10, 16};
The nozzle contour will be defined in two parts. The first with a straight line and the
second with a spline. Sometimes the characteristics of the spline require the setting
of a large number of points in order to get the shape of the nozzle. First we connect
the two points of the flat part of the nozzle with a line.
To create a spline in the script, type “Spline(nº) = {6, 7, 8, 9, 10};” (the spline has the
same numbering as the lines). The numbers in curly braces represent the points that
will be connected according to the order in which they are typed.
Note: To define the spline in the graphical interface, go to Modules→Geometry →
Elementary entities → Add → Spline and select all the points you want to connect and
press the “e” key to confirm.
Repeat the same process with the outside of the nozzle.
//+
Line(18) = {11, 12};
//+
Spline(19) = {12, 13, 14, 15, 10};
Select the four lines that will define each surface and press the “e” key to confirm. If
the process was done correctly, dotted lines should appear inside the surfaces.
//+
Curve Loop(1) = {1, 11, -16, 10};
//+
Plane Surface(1) = {1};
//+
Curve Loop(2) = {11, 17, -13, -2};
//+
Plane Surface(2) = {2};
//+
Curve Loop(3) = {13, 15, -4, -3};
//+
Plane Surface(3) = {3};
//+
Curve Loop(4) = {9, 18, 12, 8};
//+
Plane Surface(4) = {4};
//+
Curve Loop(5) = {12, -7, -14, -19};
//+
Plane Surface(5) = {5};
//+
Curve Loop(6) = {15, 5, 6, -14};
//+
Plane Surface(6) = {6};
//+
The “Curve Loop” tool defines the lines that edge the surfaces and the “Plane
Surface” creates the surface. The negative signs in the number of some lines
indicate their orientations, depending on the order of the points that define them.
Select all the faces and press the “e” key to confirm. In this way, the geometry will be
rotated by -2,5° to compensate for the extrusion of 5° that will be made later.
In the script, these changes should be as shown below.
// ROTATION:
Rotate {{1, 0, 0}, {0, 0, 0}, -Pi/72} {
Surface{1}; Surface{2}; Surface{3}; Surface{4}; Surface{5};
Surface{6};
}
For the creation of a structured mesh, Gmsh offers the “Transfinite” option that must
be applied to all lines. This option allows us to define the number of volumes that
your mesh will have and the rate of growth of those volumes along the lines.
// TRANSFINITE:
//+
Transfinite Curve {20} = 10 Using Progression 1;
The value 10 indicates the number of divisions made in the mesh for that line and
the value 1 indicates the size ratio between two consecutive volumes. To facilitate
later editing of these values, we can replace them by variables.
// TRANSFINITE:
a=10;
//+
Transfinite Curve {20} = a Using Progression 1;
Note: opposite lines in the same block must have the same number of divisions for
the final mesh to be structured, so it is recommended to place the same variable for
these lines.
For better organization, the creation of Transfinites will follow this order: first the
internal horizontal lines of the nozzle, then the external horizontal lines in front of the
nozzle, the internal vertical lines, the horizontal lines of the external part of the
nozzle and the vertical lines of the external part of the nozzle. Following this order,
the result is like that:
// TRANSFINITE:
// internal horizontal lines of the nozzle :
a = 14;
b = 160;
//+
Transfinite Curve {20} = a Using Progression 1;
//+
Transfinite Curve {22} = a Using Progression 1;
//+
Transfinite Curve {26} = b Using Progression 1;
//+
Transfinite Curve {24} = b Using Progression 1;
// horizontal lines in front of the nozzle:
c = 225;
//+
Transfinite Curve {29} = c Using Progression 1;
//+
Transfinite Curve {27} = c Using Progression 1;
//+
Transfinite Curve {38} = c Using Progression 1;
g = 100;
//+
Transfinite Curve {30} = g Using Progression 1;
//+
Transfinite Curve {32} = g Using Progression 1;
//+
Transfinite Curve {35} = g Using Progression 1;
//+
Transfinite Curve {37} = g Using Progression 1;
//+
Transfinite Surface {1};
//+
Transfinite Surface {2};
//+
Transfinite Surface {3};
//+
Transfinite Surface {4};
//+
Transfinite Surface {5};
//+
Transfinite Surface {6};
//+
Recombine Surface {1, 2, 3, 4, 5, 6};
Now the 2D mesh can be viewed by clicking on Modules → Mesh → 2D. The result
should be like that:
If the mesh is not structured, redo the previous steps.
The values of the function Transfinite must be changed to get the required mesh
refinement. First change the variable “a” to 14 and reload the script. Note that the
number of volumes at the inlet will increase.
Then change the following variables: b=160 , c= 225, d = 40, e=14, f=160 and
g=100.
Now the growth volume rate must be changed to obtain a more refined mesh in
certain regions. This is done by changing the variable “Progression” in the Transfinite
function. First change the growth rate of the second nozzle division.
a = 14;
b = 160;
//+
Transfinite Curve {20} = a Using Progression 1;
//+
Transfinite Curve {22} = a Using Progression 1;
//+
Transfinite Curve {26} = b Using Progression 1/1.02;
//+
Transfinite Curve {24} = b Using Progression 1/1.02;
e = 14;
f = 160;
//+
Transfinite Curve {31} = e Using Progression 1;
//+
Transfinite Curve {33} = e Using Progression 1;
//+
Transfinite Curve {36} = f Using Progression 1/1.02;
//+
Transfinite Curve {34} = f Using Progression 1.02;
And finally the vertical lines above the nozzle:
g = 100;
//+
Transfinite Curve {30} = g Using Progression 1/1.047;
//+
Transfinite Curve {32} = g Using Progression 1.047;
//+
Transfinite Curve {35} = g Using Progression 1.047;
//+
Transfinite Curve {37} = g Using Progression 1/1.005;
The next step is to extrude the geometry so that it generates the wedge shape. This
procedure is required to run the axisymmetric case in OpenFOAM. To do this, go to
Modules → Elementary Entities → Extrude → Rotate and set the window as shown
below.
Then, select all the surfaces and press “e” to confirm. The result should be as shown
below.
To do this process via script, set the following changes to the Extrude function in the
.geo file.
// EXTRUSION:
//+
Extrude {{1, 0, 0}, {0, 0, 0}, Pi/36} {
Surface{1}; Surface{2}; Surface{3}; Surface{4}; Surface{5};
Surface{6};
Layers{1};
Recombine;
}
Now it is possible to see the 3D mesh by clicking on Modules → Mesh → 3D. The
result should be as shown below. If the mesh has not been structured, review the
previous steps.
The last step is to define the surface names where the boundary conditions will be
set. The names used here will be: inlet, atmosphere, nozzle, wedge_1, wedge_2 and
volume. Go to Modules → Geometry → Physical Groups → Add → Surface. Type “inlet”,
select the corresponding surface and press “e”.
Do the same for the surfaces corresponding to atmosphere, as shown in the figure:
Repeat the process for the faces of the wall:
The wedge_1:
The wedge_2
Go to Modules → Geometry → Physical Groups → Add → Volume, and select the yellow
spheres and press “e” to confirm:
The setting in .geo file should be the following:
//+
Physical Surface("inlet") = {9};
//+
Physical Surface("atmosphere") = {17, 20, 22, 27, 26, 15};
//+
Physical Surface("nozzle") = {18, 24, 11, 8};
//+
Physical Surface("wedge_1") = {10, 13, 16, 21, 25, 28};
//+
Physical Surface("wedge_2") = {1, 2, 3, 4, 5, 6};
//+
Physical Volume("volume") = {1, 2, 3, 4, 5, 6};
Finally , add the command “Mesh 3;” in the .geo file and then the mesh creation is
finished. To create the file to be used in OpenFOAM click on File → Export, choose the
directory where you want to save it and save with .msh extension. Then, a window
showing “MSH Options” will appear, select the format “Version 2 ASCII” and click on
save. The output file will be imported in OpenFOAM®.