CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Meshing & Mesh Conversion (https://www.cfd-online.com/Forums/openfoam-meshing/)
-   -   [Gmsh] Default Faces on Boundary Layer (https://www.cfd-online.com/Forums/openfoam-meshing/61876-default-faces-boundary-layer.html)

axel August 7, 2008 10:20

Default Faces on Boundary Layer
 
I am using the 'new' GMSH boundary layer command. I meshed a 3D-wing and it looks really nice in GMSH (with all physical surfaces / volumes defined correctly).
I have many boundary layer volumes on the surface of the wing, outside a box filled with tetrahedras and the outer boundary layer surface (which is NOT a physical surface, thus should not be exported - loading .msh file in GMSH shows it correctly).

Conversion with gmsh2ToFoam results in many errors:
meshes/meshShapes/cellModel/cellModel::centre at line 76: zero or negative pyramid volume

and once:
meshes/polyMesh/polyMeshFromShapeMesh::polyMesh at line 577 found 19702 undefined faces in mesh -> adding to default patch

Somehow there are just 1678 faces in defaultFaces (but there should be none in there). These faces are partly randomly, partly symmetrically distributed over the wing. Sometimes connected, sometimes not. They are the outer hull of the boundary layer, but just ~20% of it.

checkMesh failed in 6 mesh checks. I have ~250000 prisms and ~250000 tets, and mysteriously 59 polyhedras.
The thing is that it worked correctly without the boundary layer.

One possible workaround could be to mark the defaultFaces patch as some kind of invisible, but I did not find such option.

If you need more information I'll be glad to post them. I could also post a simple box example that behaves similarly.

Help is greatly appreciated,

Axel

axel August 7, 2008 10:51

Ok, here comes one example whe
 
Ok, here comes one example where the main problem still occurs (the mysterious defaultFaces, but the checkMesh is OK.

Regards,

Axel

just copy and paste to GMSH and mesh it, then use gmsh2ToFoam to transform to OpenFOAM:

// ############ create inner box (wing) ############
scale = 1;

lcBox=0.1*scale;

xmax=+scale;
xmin=-scale;
ymax=+scale;
ymin=-ymax;
zmax=+scale;
zmin=-zmax;

// create points of sidewall
i=-1;
i=i+1; pBox[i]=newp; Point (pBox[i]) = {xmin, ymax, zmin, lcBox};
i=i+1; pBox[i]=newp; Point (pBox[i]) = {xmin, ymin, zmin, lcBox};
i=i+1; pBox[i]=newp; Point (pBox[i]) = {xmax, ymin, zmin, lcBox};
i=i+1; pBox[i]=newp; Point (pBox[i]) = {xmax, ymax, zmin, lcBox};
I=i;

// create lines of sidewall
ii[]={0:I,0};
For i In {0:I}
lBox[i] = newl; Line(lBox[i]) = {pBox[i],pBox[ii[i+1]]};
EndFor
// create line loop and surface of sidewall
llBox = newll; Line Loop (llBox) = {lBox[0]:lBox[I]};
sTmp = news; Ruled Surface (sTmp) = {llBox};

sBox[] = Extrude {0,0,zmax-zmin} {Surface{sTmp};};
vBox = sBox[1];
// delete box volume
Delete{Volume{vBox};}
sBox[1] = -sTmp;
slBox = newsl; Surface Loop (slBox) = {-sBox[]};


surfaceWing[] = sBox[];
slWing = newsl; Surface Loop (slWing) = {surfaceWing[]};
// create physical elements - only physical elements are exported in mesh
Physical Surface("Wing") = {surfaceWing[]};


// ############ create outer box ############

scale = scale*2;

lcBox=0.1*scale;

xmax=+scale;
xmin=-scale;
ymax=+scale;
ymin=-ymax;
zmax=+scale;
zmin=-zmax;

// create points of sidewall
i=-1;
i=i+1; pBox[i]=newp; Point (pBox[i]) = {xmin, ymax, zmin, lcBox};
i=i+1; pBox[i]=newp; Point (pBox[i]) = {xmin, ymin, zmin, lcBox};
i=i+1; pBox[i]=newp; Point (pBox[i]) = {xmax, ymin, zmin, lcBox};
i=i+1; pBox[i]=newp; Point (pBox[i]) = {xmax, ymax, zmin, lcBox};
I=i;

// create lines of sidewall
ii[]={0:I,0};
For i In {0:I}
lBox[i] = newl; Line(lBox[i]) = {pBox[i],pBox[ii[i+1]]};
EndFor
// create line loop and surface of sidewall
llBox = newll; Line Loop (llBox) = {lBox[0]:lBox[I]};
sTmp = news; Ruled Surface (sTmp) = {llBox};

sBox[] = Extrude {0,0,zmax-zmin} {Surface{sTmp};};
vBox = sBox[1];
// delete box volume
Delete{Volume{vBox};}
sBox[1] = -sTmp;
slBox = newsl; Surface Loop (slBox) = {-sBox[]};

// create physical elements - only physical elements are exported in mesh
Physical Surface("sidewalls") = {};
Physical Surface("inlet") = {sBox[1],sBox[2],sBox[5]};
Physical Surface("outlet") = {sBox[0],sBox[4],sBox[3]};

// ############ boundary layer creation ############
BLlayers = 2;
BLgrowth = 2;
cells[] = {1,1};
heights = lcBox/10;
heights[1] = heights * (BLgrowth+1);
For i In {2:BLlayers-1}
// Printf("new %g",i);
cells[i] = 1;
heights[i] = heights[i-1] + BLgrowth * (heights[i-1] -heights[i-2]);
EndFor

tmp[] = Extrude{Surface{surfaceWing[]};Layers{cells[],heights[]};Recombine;};

// all boundary layer volumes and top surfaces
vBL[] = {tmp[1]:tmp[# tmp[]-5]};
sBL[] = {tmp[0]:tmp[# tmp[]-6]:22};
slBL = newsl; Surface Loop (newsl) = {-sBL[]};

// ########## volume creation #############
vAir = newv; Volume(newv) = {slBox,slBL};
// create physical elements - only physical elements are exported in mesh
Physical Volume ("air") = {vAir,vBL[]};

ogloth August 7, 2008 14:08

That file creates a somewhat s
 
That file creates a somewhat strange grid for me: There is a boundary layer placed in the middle of the cube which is completely filled with hexes -- no connection between tetras and prisms ...

mattijs August 7, 2008 14:17

You have a defaultFaces patch
 
You have a defaultFaces patch inbetween your tets and prisms. Seems the tets and prisms use different points so the converter correctly says that they are not connected.

ogloth August 7, 2008 14:39

I am either doing something wr
 
I am either doing something wrong or the resulting grid is weird. There is a tet mesh inside and outside of the box ... The outer surface of the prisms seems to be connected to the outside tet mesh and the inside tet mesh (see attached image, prisms are the green things). http://www.cfd-online.com/OpenFOAM_D...ges/1/8665.jpg

axel August 8, 2008 04:14

Hi Oliver, you might need t
 
Hi Oliver,

you might need to download the nightly build of GMSH. The boundary layer command had a little error that has just recently been fixed.
It should look like this:
http://www.cfd-online.com/OpenFOAM_D...ges/1/8675.jpg

After conversion with gmsh2ToFoam it comes out like this:
http://www.cfd-online.com/OpenFOAM_D...ges/1/8674.jpg

@Mattijs
Thanks for your help, so you think the problem lies within GMSH and the boundary layer command?
If yes, do you have any idea on how to fix it, since the .geo file does not define multiple points / surfaces.
The weird thing is that there are just 8 faces in defaultFaces (in 2 groups of 4), but all other faces are OK.

axel August 20, 2008 03:47

Ok, I found the error. It lies
 
Ok, I found the error. It lies within GMSH and is due to the smoothing algorithm of the 3D mesh generation with Tetgen.
Using Netgen algorithm works fine.

boubalos September 17, 2009 14:59

This example really helped me a lot. I feel very grateful to you.
 
1 Attachment(s)
After seeing your example, I noticed that when creating boundary layer meshs by "Extrude{Surface{}...}" , gmsh will not show lines and points created. This is why people have difficulty using this method.

So I have to find these lines and points in Tools/Visibility

and I attach a geo file which is simpler and more straight-forward

Quote:

Originally Posted by axel (Post 192621)
Ok, here comes one example where the main problem still occurs (the mysterious defaultFaces, but the checkMesh is OK.

Regards,

Axel

just copy and paste to GMSH and mesh it, then use gmsh2ToFoam to transform to OpenFOAM:

// ############ create inner box (wing) ############
scale = 1;

lcBox=0.1*scale;

xmax=+scale;
xmin=-scale;
ymax=+scale;
ymin=-ymax;
zmax=+scale;
zmin=-zmax;

// create points of sidewall
i=-1;
i=i+1; pBox[i]=newp; Point (pBox[i]) = {xmin, ymax, zmin, lcBox};
i=i+1; pBox[i]=newp; Point (pBox[i]) = {xmin, ymin, zmin, lcBox};
i=i+1; pBox[i]=newp; Point (pBox[i]) = {xmax, ymin, zmin, lcBox};
i=i+1; pBox[i]=newp; Point (pBox[i]) = {xmax, ymax, zmin, lcBox};
I=i;

// create lines of sidewall
ii[]={0:I,0};
For i In {0:I}
lBox[i] = newl; Line(lBox[i]) = {pBox[i],pBox[ii[i+1]]};
EndFor
// create line loop and surface of sidewall
llBox = newll; Line Loop (llBox) = {lBox[0]:lBox[I]};
sTmp = news; Ruled Surface (sTmp) = {llBox};

sBox[] = Extrude {0,0,zmax-zmin} {Surface{sTmp};};
vBox = sBox[1];
// delete box volume
Delete{Volume{vBox};}
sBox[1] = -sTmp;
slBox = newsl; Surface Loop (slBox) = {-sBox[]};


surfaceWing[] = sBox[];
slWing = newsl; Surface Loop (slWing) = {surfaceWing[]};
// create physical elements - only physical elements are exported in mesh
Physical Surface("Wing") = {surfaceWing[]};


// ############ create outer box ############

scale = scale*2;

lcBox=0.1*scale;

xmax=+scale;
xmin=-scale;
ymax=+scale;
ymin=-ymax;
zmax=+scale;
zmin=-zmax;

// create points of sidewall
i=-1;
i=i+1; pBox[i]=newp; Point (pBox[i]) = {xmin, ymax, zmin, lcBox};
i=i+1; pBox[i]=newp; Point (pBox[i]) = {xmin, ymin, zmin, lcBox};
i=i+1; pBox[i]=newp; Point (pBox[i]) = {xmax, ymin, zmin, lcBox};
i=i+1; pBox[i]=newp; Point (pBox[i]) = {xmax, ymax, zmin, lcBox};
I=i;

// create lines of sidewall
ii[]={0:I,0};
For i In {0:I}
lBox[i] = newl; Line(lBox[i]) = {pBox[i],pBox[ii[i+1]]};
EndFor
// create line loop and surface of sidewall
llBox = newll; Line Loop (llBox) = {lBox[0]:lBox[I]};
sTmp = news; Ruled Surface (sTmp) = {llBox};

sBox[] = Extrude {0,0,zmax-zmin} {Surface{sTmp};};
vBox = sBox[1];
// delete box volume
Delete{Volume{vBox};}
sBox[1] = -sTmp;
slBox = newsl; Surface Loop (slBox) = {-sBox[]};

// create physical elements - only physical elements are exported in mesh
Physical Surface("sidewalls") = {};
Physical Surface("inlet") = {sBox[1],sBox[2],sBox[5]};
Physical Surface("outlet") = {sBox[0],sBox[4],sBox[3]};

// ############ boundary layer creation ############
BLlayers = 2;
BLgrowth = 2;
cells[] = {1,1};
heights = lcBox/10;
heights[1] = heights * (BLgrowth+1);
For i In {2:BLlayers-1}
// Printf("new %g",i);
cells[i] = 1;
heights[i] = heights[i-1] + BLgrowth * (heights[i-1] -heights[i-2]);
EndFor

tmp[] = Extrude{Surface{surfaceWing[]};Layers{cells[],heights[]};Recombine;};

// all boundary layer volumes and top surfaces
vBL[] = {tmp[1]:tmp[# tmp[]-5]};
sBL[] = {tmp[0]:tmp[# tmp[]-6]:22};
slBL = newsl; Surface Loop (newsl) = {-sBL[]};

// ########## volume creation #############
vAir = newv; Volume(newv) = {slBox,slBL};
// create physical elements - only physical elements are exported in mesh
Physical Volume ("air") = {vAir,vBL[]};


claco February 17, 2011 07:47

1 Attachment(s)
Quote:

Originally Posted by axel (Post 192620)
I am using the 'new' GMSH boundary layer command. I meshed a 3D-wing and it looks really nice in GMSH (with all physical surfaces / volumes defined correctly).
I have many boundary layer volumes on the surface of the wing, outside a box filled with tetrahedras and the outer boundary layer surface (which is NOT a physical surface, thus should not be exported - loading .msh file in GMSH shows it correctly).

Conversion with gmsh2ToFoam results in many errors:
meshes/meshShapes/cellModel/cellModel::centre at line 76: zero or negative pyramid volume

and once:
meshes/polyMesh/polyMeshFromShapeMesh::polyMesh at line 577 found 19702 undefined faces in mesh -> adding to default patch

Somehow there are just 1678 faces in defaultFaces (but there should be none in there). These faces are partly randomly, partly symmetrically distributed over the wing. Sometimes connected, sometimes not. They are the outer hull of the boundary layer, but just ~20% of it.

checkMesh failed in 6 mesh checks. I have ~250000 prisms and ~250000 tets, and mysteriously 59 polyhedras.
The thing is that it worked correctly without the boundary layer.

One possible workaround could be to mark the defaultFaces patch as some kind of invisible, but I did not find such option.

If you need more information I'll be glad to post them. I could also post a simple box example that behaves similarly.

Help is greatly appreciated,

Axel




Dear Sirs,

I have a great problem.
I have build the geometry of a simple wind tunnel, with a bump located
on the bottom. I built a boundary layer; the other part of the 3D (a 2D extrude mesh) mesh is a structured mesh.
I succeeded in doing that, but a terrible problem remains: there is an
unwanted intersection between the boundary layer mesh and the rest of
the structured mesh.
I cannot find the proper commands to prevent this intersection.
I would like to made the structured mesh starting from the edges where the boundary layers end.
I enclose the simple file.geo file along with a screen shot.
I hope You can Help me, or forward this e-mail to someone can resolve
this simple (and at the same time difficult) problem.


file.geo

lc = 0.5;

dx = 2.0;
dy = 1.0;
dz = 5.0;
dy_bl = 0.05;
nx = 100;
ny1 = 10;//0.9;//(dy/(2*dy_bl))*ny2;
ny2 = 100;
nz = 1;

//cx = dx/nx;
//cy = dy/ny;
//cz = (cx + cy)/2;

Point(1) = {0.0,0.0,0.0,lc};
Point(2) = {0,dy,0.0,lc};
Point(3) = {dx,dy,0.0,lc};
Point(4) = {dx,0,0.0,lc};
Point(5) = {dx,0,0.0,lc};
Point(6) = {dx/2,0,0.0,lc};
Point(7) = {dx/2-0.2,0,0.0,lc};
Point(8) = {dx/2-0.05,dy/8,0.0,lc};
Point(9) = {dx/2+0.05,dy/8,0.0,lc};
Point(10) = {dx/2+0.2,0,0.0,lc};
Point(11) = {0,dy_bl,0.0,lc};
Point(12) = {dx,dy_bl,0.0,lc};
Point(13) = {0,dy-dy_bl,0.0,lc};
Point(14) = {dx,dy-dy_bl,0.0,lc};
Line(2) = {2,3};
Line(3) = {14,12};
Line(5) = {11,13};
Line(1) = {1,11};
Line(6) = {12,4};
Line(7) = {13,2};
Line(8) = {3,14};


Spline(4) = {4,10,9,8,7,1};

Line Loop(5) = {1,5,7,2,8,3,6,4};

Plane Surface(6) = {5};
old = Geometry.ExtrudeReturnLateralEntities;
Printf("lateral entities = %g", old);
Geometry.ExtrudeReturnLateralEntities = 0;
e1[]= Extrude {0,0,1.000000} {Surface{6}; Layers{1}; Recombine;};

cells[0] = 0;
heights[0] = 0.01;
For i In {1:5}
cells[i] = 1;
heights[i] = heights[i-1] * 1.2;
EndFor
tmp[] = Extrude {Surface{49}; Layers{cells[],heights[]}; Recombine;};
Printf("top surface = %g", tmp[0]);
Extrude {Surface{19}; Layers{cells[],heights[]}; Recombine;};
Geometry.ExtrudeReturnLateralEntities = old;

// Top surface
//Physical Surface(33) = {15};

// Bottom surface
//Physical Surface(34) = {23};

// Left surface
//Physical Surface(35) = {19};

// Right surface
//Physical Surface(36) = {27};

// Front surface
//Physical Surface(37) = {28};

// Back surface
//Physical Surface(38) = {6};

// Box volume
//Physical Volume (39) = {32};

Transfinite Line {1,8} = (ny1) + 1 Using Progression 1;
Transfinite Line {7,6} = (ny1) + 1 Using Progression 1;
Transfinite Line {5,3} = (ny2) + 1 Using Progression 1.0;
Transfinite Line {2,4} = nx + 1 Using Progression 1.0;
//Transfinite Line {1,3} = ny + 1 Using Progression 1.0;
//Transfinite Line {14,18,13,22} = nz + 1 Using Progression 1.0;

Transfinite Surface {6} = {3,2,1,4};
Recombine Surface {6};
//Transfinite Surface {27} = {5,14,2,3};
//Transfinite Surface {15} = {5,3,4,6};
//Transfinite Surface {28} = {6,10,14,5};
//Transfinite Surface {23} = {14,2,1,10};
//Transfinite Surface {19} = {6,10,1,4};
//Surface Loop(1000) = {14:28:2}; // the sphere (only need for internal mesh)
Surface Loop(1001) = {72};//tmp[{0:14:2}]}; // The outside of the BL
Surface Loop(1002) = {21,25,29,33,6,37,41,45,49,50}; // the box (entire farfield surface loop)

//Volume(1000) = {1000}; /// inside the sphere
//Volume(1) = {1002, 1001}; /// FarField

Mesh.Algorithm3D = 4;
Mesh.Smoothing = 100;
Mesh.Optimize=1;
Mesh.OptimizeNetgen=1;
Mesh.OptimizeNetgen=1;


Morevoer, I would like to undertand how to use the new boundary-layer command present in the last release of GMSH.


Your Sincerely,


Claudio Comis


All times are GMT -4. The time now is 23:46.