# Scripted version of "2D Mesh Generation Tutorial for GMSH"

 Register Blogs Members List Search Today's Posts Mark Forums Read

 April 2, 2013, 09:02 Scripted version of "2D Mesh Generation Tutorial for GMSH" #1 New Member   Gerrit Laube Join Date: Feb 2013 Posts: 5 Rep Power: 6 Hi, I came across the 2d mesh generation tutorial for gmsh by aeroslacker: http://www.cfd-online.com/Forums/ope...rial-gmsh.html and http://openfoamwiki.net/index.php/2D...ial_using_GMSH which was very useful as a first step with gmsh/openfoam. I just didn't like the thought of using both the graphical user interface (GUI) and the Editor so I changed it a tiny bit to make scripting possible. The main difference is the usage of "vector[] = Extrude {...}{...}" instead of "Extrude {...}{...}", where "vector[]" is a vector containing the surfaces and volumes created by the Extrude-command. This way, you get rid of the intransparent numbering of the surfaces. I also added an optional structuring of the mesh, just as a hint that structuring is possible. Here is all the code: Code: ```// sripted version of "2D Mesh Tutorial using GMSH" by CFD-online Member "aeroslacker", taken from openfoamwiki.net // All numbering counterclockwise from bottom-left corner Point(1) = {-100, -100, 0, 1e+22}; Point(2) = {100, -100, 0, 1e+22}; Point(3) = {100, 100, 0, 1e+22}; Point(4) = {-100, 100, 0, 1e+22}; Line(1) = {1, 2}; // bottom line Line(2) = {2, 3}; // right line Line(3) = {3, 4}; // top line Line(4) = {4, 1}; // left line Line Loop(5) = {1, 2, 3, 4}; // the order of lines in Line Loop is used again in surfaceVector[] Plane Surface(6) = {5}; /* start optional: structured mesh */ // Transfinite Surface{surface}={edge points}; forces later meshing to contain structured triangles Transfinite Surface{6} = {1,2,3,4}; Recombine Surface{6}; //combine triangles to quadrangles /* end optional */ surfaceVector[] = Extrude {0, 0, 10} { Surface{6}; Layers{1}; Recombine; }; /* surfaceVector contains in the following order: [0] - front surface (opposed to source surface) [1] - extruded volume [2] - bottom surface (belonging to 1st line in "Line Loop (6)") [3] - right surface (belonging to 2nd line in "Line Loop (6)") [4] - top surface (belonging to 3rd line in "Line Loop (6)") [5] - left surface (belonging to 4th line in "Line Loop (6)") */ Physical Surface("front") = surfaceVector[0]; Physical Volume("internal") = surfaceVector[1]; Physical Surface("bottom") = surfaceVector[2]; Physical Surface("right") = surfaceVector[3]; Physical Surface("top") = surfaceVector[4]; Physical Surface("left") = surfaceVector[5]; Physical Surface("back") = {6}; // from Plane Surface (6) ... // File must end with a free line to avoid errors! So insert line below this comment!``` Do you think I should add this "scripted" version of the Tutorial as an optional way to the openfoamwiki? In my opinion programming geometry has some advantages over using the GUI, especially when you keep in mind, that the .geo-format is more of a programming language (including loops, if/else...) than just a point-list. In my case, one boundary is described by a sine-wave, which is hard to implement via GUI. Regards! wyldckat, JR22 and fportela like this.

 April 14, 2013, 08:32 #2 Super Moderator   Bruno Santos Join Date: Mar 2009 Location: Lisbon, Portugal Posts: 10,036 Blog Entries: 39 Rep Power: 110 Greetings Gerrit, Many thanks for adding this to the wiki page! Best regards, Bruno __________________ OpenFOAM: FAQ | Getting started Forum: How to get help, to post code/output and forum guide What am I doing/planning: blog/wiki Read this before sending me PM

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Kryo OpenFOAM Native Meshers: snappyHexMesh and Others 8 September 13, 2012 09:28 Pursuor ANSYS Meshing & Geometry 1 August 29, 2012 16:04 sc298 OpenFOAM Native Meshers: snappyHexMesh and Others 2 March 27, 2011 21:11 chelvistero OpenFOAM 11 January 15, 2010 20:43 Gang Sun Main CFD Forum 5 September 16, 1998 00:24

All times are GMT -4. The time now is 08:15.