[Gmsh] Problems with Extrude command

Kushagra Vidyarthi kushagra.vidyarthi at ymail.com
Sat Oct 22 19:08:06 CEST 2016


Dear Gmsh experts,

I'm a beginner in Gmsh. I have been trying to create a structured mesh 
for CFD simulations in opemfoam using Gmsh. I have had success in doing 
so. I now want to automate the geometry creation in Gmsh, by use of a 
python script. My geometry is 2D. My grid is an o-grid around an 
ellipse, and I have made a boundary layer around the ellipse as well. I 
have to extrude the 2D mesh in 3D space using the Extrude command. Gmsh 
no longer supports explicit specification of surface and curve numbers 
created by extrusion of 2D geometry. So a work-around for this would be 
extract somehow the surface numbers, so that this data can be used for 
defining physical groups etc. I did this by the following line of code:

//extrude 2D mesh to 3D
surfaceVector[] = Extrude {0, 0, 0.1}
{
   Surface{26, 28, 30, 32, 34, 36, 38, 40};
   Layers{1};
   Recombine;
}

When I load the script with this code, gmsh throws the following error:

Error   : '/home/kushagra/gmsh_work/o-grid_bl (copy).geo', line 117 : 
syntax error (Physical)
Error   : '/home/kushagra/gmsh_work/o-grid_bl (copy).geo', line 125 : 
Unknown variable 'surfaceVector'

I guess the error is due to multiple surfaces being extruded. I have 
searched a lot through the documentation, but I'm unable to resolve this 
error. My .geo file is attached. Please advise on how I can fix this issue.

Regards,

Kushagra

-------------- next part --------------
// Gmsh project created on Tue Oct 18 14:53:18 2016

//geometry creation
//reference points
Point(1) = {0, 0, 0, 0.01}; //global center
Point(2) = {-0.02, 0, 0, 0.1}; //reference point 1
Point(3) = {0.02, 0, 0, 0.01}; //reference point 2

//ellipse: major axis 0.075, minor axis 0.009375
// 1st arc
Point(4) = {-0.0375, 0, 0, 0.01};
Point(5) = {-0.026516504, 0.003314563, 0, 0.01};
Ellipse(1) = {4, 1, 2, 5};

//arc 2
Point(6) = {0, 0.0046875, 0, 0.01};
Ellipse(2) = {5, 1, 2, 6};

//arc3
Point(7) = {0.026516504, 0.003314563, 0, 0.01};
Ellipse(3) = {6, 1, 3, 7};

//arc4
Point(8) = {0.0375, 0, 0, 0.01};
Ellipse(4) = {7, 1, 3, 8};

//arc5
Point(9) = {0.026516504, -0.003314563, 0, 0.01};
Ellipse(5) = {8, 1, 3, 9};

//arc6
Point(10) = {0, -0.0046875, 0, 0.01};
Ellipse(6) = {9, 1, 2, 10};

//arc7
Point(11) = {-0.026516504, -0.003314563, 0, 0.01};
Ellipse(7) = {10, 1, 2, 11};

//arc8
Ellipse(8) = {11, 1, 2, 4};

//domain
Point(12) = {-2.5, 0, 0, 0.01};
Point(13) = {-1.7677669, 1.7677669, 0, 0.01};
Point(14) = {0, 2.5, 0, 0.01};
Point(15) = {1.7677669, 1.7677669, 0, 0.01};
Point(16) = {2.5, 0, 0, 0.01};
Point(17) = {1.7677669, -1.7677669, 0, 0.01};
Point(18) = {0, -2.5, 0, 0.01};
Point(19) = {-1.7677669, -1.7677669, 0, 0.01};

Circle(9) = {12,1,13};
Circle(10) = {13,1,14};
Circle(11) = {14,1,15};
Circle(12) = {15,1,16};
Circle(13) = {16,1,17};
Circle(14) = {17,1,18};
Circle(15) = {18,1,19};
Circle(16) = {19,1,12};

//block lines
Line(17) = {4,12};
Line(18) = {5,13};
Line(19) = {6,14};
Line(20) = {7,15};
Line(21) = {8,16};
Line(22) = {9,17};
Line(23) = {10,18};
Line(24) = {11,19};

// surface creation
Line Loop(25) = {1, 18, -9, -17};
Plane Surface(26) = {25};
Line Loop(27) = {2, 19, -10, -18};
Plane Surface(28) = {27};
Line Loop(29) = {3, 20, -11, -19};
Plane Surface(30) = {29};
Line Loop(31) = {4, 21, -12, -20};
Plane Surface(32) = {31};
Line Loop(33) = {5, 22, -13, -21};
Plane Surface(34) = {33};
Line Loop(35) = {6, 23, -14, -22};
Plane Surface(36) = {35};
Line Loop(37) = {7, 24, -15, -23};
Plane Surface(38) = {37};
Line Loop(39) = {8, 17, -16, -24};
Plane Surface(40) = {39};

// line division
Transfinite Line {1,9,4,12,5,13,8,16} = 50 Using Progression 1;
Transfinite Line {2,10,3,11,6,14,7,15} = 50 Using Progression 1;
Transfinite Line {17:24} = 150 Using Progression 1.1;
//+
Transfinite Surface {26} = {4,12,13,5} Right;
Transfinite Surface {28} = {5,13,14,6} Right;
Transfinite Surface {30} = {6,14,15,7} Right;
Transfinite Surface {32} = {7,15,16,8} Right;
Transfinite Surface {34} = {8,16,17,9} Right;
Transfinite Surface {36} = {9,17,18,10} Right;
Transfinite Surface {38} = {10,18,19,11} Right;
Transfinite Surface {40} = {11,19,12,4} Right;

Recombine Surface{26,28,30,32,34,36,38,40};

Mesh.Smoothing = 2;

//extrude 2D mesh to 3D
surfaceVector[] = Extrude {0, 0, 0.1} 
{
  Surface{26, 28, 30, 32, 34, 36, 38, 40};
  Layers{1};
  Recombine;
}

//defining surfaces for 
//+
Physical Surface("front") = {surfaceVector[0]};
//+
Physical Surface("back") = {26, 28, 30, 32, 34, 36, 38, 40};
//+
Physical Surface("farfield") = {57, 79, 101, 123, 145, 167, 189, 211};
//+
Physical Surface("ellipse") = {49, 71, 93, 115, 137, 159, 181, 203};
//+
Physical Volume("fluid") = {surfaceVector[1]};

//Define boundary layer
Field[1] = BoundaryLayer;
Field[1].EdgesList = {1,2,3,4,5,6,7,8,47,48,70,92,136,158,180,42,64,86,108,130,152,174,196};
Field[1].NodesList = {4,6,8,10,20,36,52,68};
Field[1].FacesList = {49, 71, 93, 115, 137, 159, 181, 203};
//Field[1].FanNodesList = {};
Field[1].FansList = {1,2,3,4,5,6,7,8,42,64,86,108,130,152,174,196};
Field[1].hfar = 0.05;
Field[1].hwall_n = 0.000005;
Field[1].thickness = 0.01;
Field[1].ratio = 1.1;
Field[1].AnisoMax = 10;
Field[1].Quads = 1;
Field[1].IntersectMetrics = 0;
BoundaryLayer Field = 1;



More information about the gmsh mailing list