<br>gmsh friends - <br><br>I have a question regarding gmsh and the gmshToFoam utility within OpenFOAM, one of which seems to be not acting as I had presumed.<br><br>I have a simple mesh problem which I've distilled down to the it's basic form. <br>
I am running a gmsh script (.geo) to create a 3D rectangular flow field with a circular cylinder in the middle.<br>When I run gmsh, it meshes succesfully. However, when I run gmshToFoam (conversion to the OpenFOAM polyMesh format), I end up with a mesh that is not usable. <br>
<br>First of all, I get a warning saying:<br><br><br>[warning]<br>--> FOAM Warning : <br> From function polyMesh::polyMesh(... construct from shapes...)<br> in file meshes/polyMesh/polyMeshFromShapeMesh.C at line 619<br>
Found 9022 undefined faces in mesh; adding to default patch.<br>[/warning]<br><br><br><br>Invoking the "checkMesh" utility results in the following errors:<br><br><br>[error]<br>Checking geometry...<br> Overall domain bounding box (0 0 -0.75) (9 6 0.75)<br>
Mesh (non-empty, non-wedge) directions (1 1 1)<br> Mesh (non-empty) directions (1 1 1)<br> Boundary openness (1.15651e-17 5.07766e-19 9.032e-18) OK.<br> ***High aspect ratio cells found, Max aspect ratio: 7.58943e+198, number of cells 3<br>
<<Writing 3 cells with high aspect ratio to set highAspectRatioCells<br> Minumum face area = 6.81219e-06. Maximum face area = 0.177405. Face area magnitudes OK.<br> Min volume = 1.33333e-300. Max volume = 0.0208743. Total volume = 80.8949. Cell volumes OK.<br>
Mesh non-orthogonality Max: 89.2144 average: 30.4407<br> *Number of severely non-orthogonal faces: 1046.<br> Non-orthogonality check OK.<br> <<Writing 1046 non-orthogonal faces to set nonOrthoFaces<br> ***Error in face pyramids: 8 faces are incorrectly oriented.<br>
<<Writing 8 faces with incorrect orientation to set wrongOrientedFaces<br> Max skewness = 2.23263 OK.<br> Coupled point location match (average 0) OK.<br><br>Failed 2 mesh checks.<br>[/error]<br><br><br><br>
The gmsh script (.geo file) is as follows:<br><br><br>[script]<br>// Everything is parameterized on the cylinder radius<br>rad = 0.15;<br><br>//Characteristic length - used for mesh sizing<br>lc = 4*rad;<br><br>//Plane dimesions<br>
planeLength = 60*rad;<br>planeWidth = 40*rad;<br><br>//Cyclinder constants<br>cir_x = 15*rad; //The absolute X distance of the center<br>cir_y = planeWidth / 2; //The absolute Y distance of the center<br><br>//The bottom plane number<br>
bottomPlaneNum = 16;<br><br>//The extrusion thickness<br>extThickness = rad*10;<br>zBottom = -(extThickness/2.0);<br>zTop = (extThickness/2.0);<br>z = zBottom; //The z-height of this plane. <br> // NOTE - For 2D, the plane is centered at 0, so<br>
// the z value used will be -(h/2) <br><br>//Rectangular plane (Counter-clockwise, starting in lower left corner)<br>Point(1) = {0, 0, z, lc};<br>Point(2) = {planeLength, 0, z, lc};<br>
Point(3) = {planeLength, planeWidth, z, lc};<br>Point(4) = {0, planeWidth, z, lc};<br><br>//Circle<br>Point(5) = {cir_x, cir_y, z, lc}; // Center point<br>Point(6) = {cir_x, cir_y + rad, z, lc}; // 12 o'clock<br>
Point(7) = {cir_x + rad, cir_y, z, lc}; // 3<br>Point(8) = {cir_x, cir_y - rad, z, lc}; // 6<br>Point(9) = {cir_x - rad, cir_y, z, lc}; // 9<br><br>//Lines<br>Line(1) = {1, 2};<br>Line(2) = {2, 3};<br>
Line(3) = {3, 4};<br>Line(4) = {4, 1};<br>Circle(5) = {6, 5, 7};<br>Circle(6) = {7, 5, 8};<br>Circle(7) = {8, 5, 9};<br>Circle(8) = {9, 5, 6};<br>Line Loop(9) = {1, 2, 3, 4};<br>Line Loop(10) = {5, 6, 7, 8};<br><br>//Surface<br>
// Don't add any line loop(s) specific to meshing<br>Plane Surface(bottomPlaneNum) = {9, 10};<br><br>//Extrude the bottom surface in the z direction a total of extThickness units.<br>// This extrusion is centered on 0 (from -h/2 to +h/2)<br>
newSurfs[] = Extrude {0,0,extThickness} { <br> Surface{bottomPlaneNum};<br>};<br><br>//Name the surfaces<br>Physical Surface("topAndBottom") = {bottomPlaneNum, newSurfs[0]};<br>Physical Surface("nearAndFar") = {newSurfs[2], newSurfs[4]};<br>
Physical Surface("outlet") = {newSurfs[3]};<br>Physical Surface("inlet") = {newSurfs[5]};<br>Physical Surface("cylinder") = {newSurfs[9], newSurfs[8], newSurfs[7], newSurfs[6]};<br><br>Physical Volume(1) = {newSurfs[1]};<br>
<br>//Meshing<br>fineness = 15;<br><br>Field[4] = Cylinder;<br>Field[4].Radius = 1.5*rad;<br>Field[4].VIn = lc / fineness;<br>Field[4].VOut = lc / 2;<br>Field[4].XAxis = 0.0;<br>Field[4].XCenter = cir_x;<br>Field[4].YAxis = 0.0;<br>
Field[4].YCenter = cir_y;<br>Field[4].ZAxis = 1.0;<br>Field[4].ZCenter = 0.0;<br><br>Field[6] = Box;<br>Field[6].VIn = lc / (fineness / 3);<br>Field[6].VOut = lc;<br>Field[6].XMin = cir_x - 3*rad; <br>Field[6].XMax = cir_x + 10*rad;<br>
Field[6].YMin = cir_y - 3*rad;<br>Field[6].YMax = cir_y + 3*rad;<br>Field[6].ZMin = zBottom -0.000001;<br>Field[6].ZMax = zTop +0.000001;<br><br>// Use minimum of all the fields as the background field<br>Field[100] = Min;<br>
Field[100].FieldsList = {4, 6};<br>Background Field = 100;<br><br>[/script]<br><br><br><br>I have no problem with the 2D case -- I use Layers{1} and Recombine within the extrusion command. This works well.<br><br>I have also seen that using many layers within the 3D case will also produce a mesh that passes the checkMesh utility. But this doesn't provide a good 3D mesh, as the domain is segregated throughout in these distinct layers, and it doesn't take into account the finer meshing (in the Z direction) around the cylinder.<br>
<br>So I'm wondering if this is an issue in the meshing of gmsh, or the gmshToFoam utility? And what remedy might be available. <br><br>Thank you very much for any help you are able to provide.<br><br>Madeleine P. Vincent<br>
<br>