CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Meshing & Mesh Conversion

[Gmsh] Scripted version of "2D Mesh Generation Tutorial for GMSH"

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 3 Post By laubeg

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 2, 2013, 10:02
Default Scripted version of "2D Mesh Generation Tutorial for GMSH"
  #1
New Member
 
Gerrit Laube
Join Date: Feb 2013
Posts: 5
Rep Power: 13
laubeg is on a distinguished road
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.
laubeg is offline   Reply With Quote

Old   April 14, 2013, 09:32
Default
  #2
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings Gerrit,

Many thanks for adding this to the wiki page!

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Reply


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 Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 07:51.