|
[Sponsors] |
[Gmsh] Scripted version of "2D Mesh Generation Tutorial for GMSH" |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 2, 2013, 10:02 |
Scripted version of "2D Mesh Generation Tutorial for GMSH"
|
#1 |
New Member
Gerrit Laube
Join Date: Feb 2013
Posts: 5
Rep Power: 13 |
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! 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! |
|
April 14, 2013, 09:32 |
|
#2 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Greetings Gerrit,
Many thanks for adding this to the wiki page! Best regards, Bruno
__________________
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
decomposePar problem: Cell 0contains face labels out of range | vaina74 | OpenFOAM Pre-Processing | 37 | July 20, 2020 06:38 |
[snappyHexMesh] Multi Region Mesh of a car filter | Zephiro88 | OpenFOAM Meshing & Mesh Conversion | 3 | September 11, 2019 20:34 |
[snappyHexMesh] snappyHexMesh does not create any mesh except one for the reference cell | Arman_N | OpenFOAM Meshing & Mesh Conversion | 1 | May 20, 2019 18:16 |
[ICEM] Need urgent help for hybrid mesh generation | Pursuor | ANSYS Meshing & Geometry | 1 | August 29, 2012 17:04 |
[snappyHexMesh] snappyHexMesh won't work - zeros everywhere! | sc298 | OpenFOAM Meshing & Mesh Conversion | 2 | March 27, 2011 22:11 |