First of all, we are reusing the Gmsh tutorial files. If you have any doubt about the use of these files, please refer to the Gmsh Tutorial, and consider following it entirely first.
In this example we are going to use t1.geo
and t2.geo
, which we will edit slightly.
All alterations are mentioned below the sample code:
t1.geo
lc = 0.0125;
Point(1) = {0, 0, 0, lc};
Point(2) = {.1, 0, 0, lc} ;
Point(3) = {.1, .3, 0, lc} ;
Point(4) = {0, .3, 0, lc} ;
Line(1) = {1,2} ;
Line(2) = {3,2} ;
Line(3) = {3,4} ;
Line(4) = {4,1} ;
Curve Loop(1) = {4,1,-2,3} ;
Plane Surface(1) = {1} ;
// --> Dolfyn-Edit :: everything after this line is not useful and commented out
Note
We edited the following (line numbers according to original document):
- line 13 – Points will have different characteristic length
- line 54 and beyond – commented everything out
As you can see, 4 Point
s are declared, which are then connected using Line
s. Then a Surface
is created using a list of Curve Loop
. This is shown in the picture below, which shows all entities.
t1.geo
can then be read in by t2.geo
, which will then on its turn change some parts, and add others.
t2.geo
Include "t1.geo";
Point(5) = {0, .6, 0, lc};
Line(5) = {4, 5};
Translate {-0.05, 0, 0} { Point{3}; }
Translate {0, 0.3, 0} { Duplicata{ Point{3}; } }
Line(7) = {3, 6};
Line(8) = {6, 5};
Curve Loop(10) = {5,-8,-7,3};
Plane Surface(11) = {10};
my_new_surfs[] = Translate {0, 0, 0.12} { Duplicata{ Surface{1}; } };
Printf("New surfaces '%g' and '%g'", my_new_surfs[0]);
//Point(100) = {0., 0.3, 0.13, lc}; Point(101) = {0.08, 0.3, 0.1, lc};
//Point(102) = {0.08, 0.4, 0.1, lc}; Point(103) = {0., 0.4, 0.13, lc};
Line(110) = {1, 8}; Line(111) = {2, 12};
Line(112) = {4, 7}; Line(113) = {3, 16};
//Line(114) = {103, 100}; Line(115) = {100, 101};
//Line(116) = {101, 102}; Line(117) = {102, 103};
Curve Loop(118) = {111, 15, -113, 2}; Plane Surface(119) = {118};
Curve Loop(120) = {110, -13, -112, 4}; Plane Surface(121) = {120};
Curve Loop(122) = {1, 111, -14, -110}; Plane Surface(123) = {122};
Curve Loop(124) = {3, 112, -16, -113}; Plane Surface(125) = {124};
//Curve Loop(126) = {115, 116, 117, 114}; Plane Surface(127) = {126};
Surface Loop(128) = {1, 119, 121, 123, 125, 12};
Volume(129) = {128};
Extrude {0, 0, 0.12} { Surface{11}; }
Characteristic Length {2, 3, 6, 12, 16, 28} = lc * 2;
//
// Note these Physical Volume and Surfaces:
//
Physical Volume("Fluid") = {129,130};
Physical Surface("Inlet") = {123};
Physical Surface("Outlet") = {142};
Note
We edited the following (line numbers according to original document):
- line 17 – Point 5 is placed on y=0.6
- line 29 – Point translated to match point 5: Ty= 0.3
- line 48 – Only surface 1 is translated in z-direction instead of x
- line 54 – Removed second surface from print-statement
- line 68-69 – Lines adjusted to other point numbers
- line 73-76 – Curves adjusted to correct line numbers
- line 79 – Surface adjusted to correct Curve numbers
- line 88 – Extrude other existing surface due to removal of duplicate
- line 93 – Choosing other points to change characteristic length
- Commented out lines:
- line 65, 66 – Points not needed
- line 70, 71 – Lines not needed
- line 77 – Curve and Surface not needed
- Added lines (important!):
- 108,109 – to define an inlet and outlet which will be used by dolfyn.
As you can see, some new commands are introduced to make your life easier. It can also make it a bit harder to remember all the id’s for all the instances, but we have a tip!
Tip: In gmsh go to Tools > Options > Geometry, and tick the desired labels, such that you can find out which surface is which.
Lastly, we want to briefly talk about the t2d.din
file. This file contains all the simulation parameters. Please read the DINGuide which is available on the Downloads page to understand the following file.
dolfyn input file *.din
title Test Gmsh t2.geo model
steps 200 1.e-3
#restart init
opendx off
use gmsh fluid
vislam 20.e-6
density 1.2
relax 0.5 0.25 0.5
thermal on
turbulence ke 0.01
init,field,0.0 0.0 0.0,,1.e-4,1e-4
scheme UVW LUX 0.8
scheme KEPS UD
scheme T GAMMA
slope UVW vnf
slope P vnf
slope KEPS vnf
slope T vnf
#post p cell
post p vert
#post k cell
#post k vert
#
#post eps cell
#post eps vert
#
#post vis cell
#post vis vert
post t cell
post t vert
boundary,0
wall
noslip
0.0 0.0 0.0
fixed
273 - 20 0.0
boundary,inlet
inlet
0.0 0.1 0.0
1.2
273 + 20
inle
0.05 0.01
boundary,outlet
outlet
1.0
In this case, you first see some General Commands and Fluid Properties being declared. This is followed by Control Parameters and lastly the Boundary Conditions.
Important to understand is that on line 6, gmsh is defined as an output format. Selectable options for gmsh output are:
use gmsh
– a file with results only.use gmsh fluid
– a full file, but the results on the boudaries will be ommitted.use gmsh full
– a full file containing the mesh, boudaries (including the default boundaries, region 0) will be written.
The next sections will elaborate on why it is important to be aware of this, and how to deal with the output.