Friday 16 January 2009

Gmsh 2.2.3: Ordered mesh, tube of elements.


gmsh version 2.2.3. Version 2.3.0 produces extra elements; I dunno how to tame it, yet.

// Gmsh project created on Tue Aug 5 18:29:53 2008
l = 0.01; // length
h = 0.01; // duct height
my = 1; // y mesh
mz = 1; // mesh density across width.
mx = 10; // mesh along the length.

// Bottom surface; extrude from here, up.=========================NODES
Point(1) = { 0, 0, 0, 1}; // bottom, rear left corner.
Point(2) = { l, 0, 0, 1}; // bottom, front left corner.
Point(3) = { 0, 0, h, 1}; // bottom, rear right corner.
Point(4) = { l, 0, h, 1}; // bottom, front right corner.

// Square creation. Duct. ==============================================Squares
Line(1) = {1, 2}; // left, bottom edge.
Line(2) = {1, 3}; // rear, bottom.
Line(3) = {4, 2}; // front, bottom.
Line(4) = {3, 4}; // right, bottom.

// Define closed loops and planes for the shapes just created. These were
// selected in GMSH, rather than in the script as the negative values control
// the direction of the path. ============================================Planes
// Duct.
Line Loop(5) = {3,-1,2,4}; // bottom line loop.
Plane Surface(6) = {5}; // bottom surface.

// The following code is required to make the mesh ordered =====================
// Set the lines above, as 'transfinite'. Duct (setting most of the mesh):
Transfinite Line{1,4} = mx + 1 Using Progression 1.0; // lines 1 and 4 (sides). Set mesh.
Transfinite Line{2,3} = mz Using Progression 1.0; // lines 2 and 3 (width) set mesh.

// Create new, 'transfinite' surfaces. Matching surface numbers above and
// referencing same node numbers (waste of time, it seems). Had to inspect
// these from gmsh. Note, curly brackets, not parentheses.
// {surface} = {nodes}
Transfinite Surface{6} = {1,2,3,4};

// Without the following recombine, the elements are tri primative.
// Duct.
Recombine Surface{6};


// End of extra code to get ordered mesh ***************************************
//
// Extrude {vector} { Surface{n}; Layers{mz} ; Recombine; }
// with surface number(s) n extruded, mesh density mz1.
// Assign result to var[], to allow further work with the new surface, in var[0]
// Entries 0 to 5 are returned for these extruded faces, so steps of 6 to
// get the faces for different volumes appended to the list.
//
// Extrude to form duct thickness: -------------------------
// upper middle.
num[] = Extrude { 0, h, 0} {
Surface {
6
};
Layers{my}; Recombine;
};

No comments:

Post a Comment