Basic introduction to Gmsh Ashvinkumar Chaudhari LUT School of Engineering Science BM20A5100 Scientific Computing and Numerics for PDEs
Task 1 Make a simple 2D square using following dimensions Mesh the domain using different techniques (0,0)(10,0) (10,10) (0,10) 10
Steps Point Line Surface (2D) Meshing
Lines and surfaces Make a straight lines using points Loop them to create surface (2D) Use script option for faster output Point(1) Point(2) Point(3) Point(4) Line(1) Line(2) Line(3) Line(4)
Mesh The default mesh in Gmsh Can be improved using “Transfinite”
Script file Faster using script file Add directly in the script (text) using any text editor Then press “Reload” to bring the new changes into Gmsh
Structural mesh Add directly the script file, save it and reload in Gmsh
Changing the mesh parameters Make finer mesh toward boundaries Use “Bump” option
Some more options Note the comment symbol “//”
Task 2: step D D 10D 3D 7D 2D Create the following geometry and grid it D=1 m
The script file for step // Gmsh project created on Mon Mar 21 16:43: Point(1) = {0, 0, 0, 1.0}; Point(2) = {3, 0, 0, 1.0}; Point(3) = {3, -1, 0, 1.0}; Point(4) = {10, -1, 0, 1.0}; Point(5) = {10, 1, 0, 1.0}; Point(6) = {3, 1, 0, 1.0}; Point(7) = {0, 1, 0, 1.0}; Line(1) = {7, 6}; Line(2) = {6, 5}; Line(3) = {5, 4}; Line(4) = {4, 3}; Line(5) = {3, 2}; Line(6) = {2, 1}; Line(7) = {1, 7}; Delete { Line{3}; } Line(8) = {6, 2}; Point(8) = {10, 0, 0, 1.0}; Line(9) = {5, 8}; Line(10) = {8, 4}; Line(11) = {2, 8}; Line Loop(12) = {1, 8, 6, 7}; Plane Surface(13) = {12}; Line Loop(14) = {2, 9, -11, -8}; Plane Surface(15) = {14}; Line Loop(16) = {11, 10, 4, 5}; Plane Surface(17) = {16}; Transfinite Line {1, 6} = 60 Using Progression 1; Transfinite Line {7, 8, 9} = 40 Using Progression 1; Transfinite Line {7} = 40 Using Progression 1; Transfinite Line {2, 11, 4} = 140 Using Progression 1; Transfinite Line {5, 10} = 40 Using Progression 1; Transfinite Surface {13}; Recombine Surface {13}; Transfinite Surface {15}; Recombine Surface {15}; Transfinite Surface {17}; Recombine Surface {17}; Physical Surface ("Fluid") = {13,15,17}; Physical Line ("inlet") = {7}; Physical Line ("out") = {9,10}; Physical Line ("walls") = {1,2,4,5,6}; 1 2
Spline curves Point(1) = {0,0,0,0.1}; Point(2) = {1,0.2,0,0.1}; Point(3) = {2,0,0,0.1}; Spline(1) = {1,2,3} ; Point(4) = {-0.5,1,0,0.1}; Point(5) = {1,1.2,0,0.1}; Point(6) = {2.5,1,0,0.1}; Spline(2) = {4,5,6} ; Line(3)={1,4}; Line(4)={3,6}; Line Loop(1) = {1,4,-2,-3} ; Plane Surface(1) = {1}; // Tell Gmsh how many cells you want per edge Transfinite Line{3,4} = 10; Transfinite Line{1,2} = 15; // Tell Gmsh what the corner points are(going clockwise or counter-clockwise): Transfinite Surface{1} = {1,3,6,4}; // Recombine the triangles into quads: Recombine Surface{1}; // Extrued for a psudo 2D mesh :) Extrude {0,0,0.15} {Surface{1}; Layers{1}; Recombine; } 1 2
Some tutorials from internet 2D axisymmetric stenosis Von Karman vortex street