BoundaryLayer setup for Gmsh 3D meshing

copyright (C) qingfeng Xia 2011-2020 CC-BY-NC 4.0

Precise control of the thickness of the first cell normal to wall, is crucial for  turbulence models like k-epsilon, k-omega. Before moving to turbulence flow simulation for CFD workbench of FreeCAD

2D meshing with boundary layer, tutorial

3D boundary meshing for simple cube is also done, based on FreeCAD FEM workbench example of 3D cantilever.
CAD and Gmsh setup files are embeded.
photo and progress will be updated on the FreeCAD Fem post

 

// geo file for meshing with GMSH meshing software created by FreeCAD

// open brep geometry
Merge "./Box_Geometry.brep";

// group data
//Physical Surface("FEMMeshGroup") = {6};

Physical Surface("FemConstraintFixed") = {1};
Physical Surface("FemConstraintForce") = {2};

// Characteristic Length
// Characteristic Length according CharacteristicLengthMap
// Face6
//Characteristic Length { 3, 1, 7, 5 } = 100.0;

// min, max Characteristic Length
Mesh.CharacteristicLengthMax = 1e+22;
Mesh.CharacteristicLengthMin = 0.0;

// optimize the mesh
Mesh.Optimize = 1;
Mesh.OptimizeNetgen = 0;
Mesh.HighOrderOptimize = 0;  //probably needs more lines off adjustment in geo file

// mesh order
Mesh.ElementOrder = 1;


// boundary layer, need background mesh
Field[4] = BoundaryLayer;
//Field[4].EdgesList = {3, 1,};  // EdgesList for 2D, not necessary for 3D BL
Field[4].FacesList = {1};  // FacesList  for 3D,  
Field[4].hfar = 100;
Field[4].hwall_n = 10;
Field[4].hwall_t = 9;
Field[4].thickness = 30;  // must be bigger than hwall_n
Field[4].ratio = 1.1;

BoundaryLayer Field = 4;


// mesh algorithm
// 2D mesh algorithm (1=MeshAdapt, 2=Automatic, 5=Delaunay, 6=Frontal, 7=BAMG, 8=DelQuad)
Mesh.Algorithm = 2;  //  2 and 8 both working for 3D BL
// 3D mesh algorithm (1=Delaunay, 2=New Delaunay, 4=Frontal, 5=Frontal Delaunay, 6=Frontal Hex, 7=MMG3D, 9=R-tree)
Mesh.Algorithm3D = 8;
// meshing
Mesh  3;

// save
Mesh.Format = 2;
// For each group save not only the elements but the nodes too.;
Mesh.SaveGroupsOfNodes = 1;
// Needed for Group meshing too, because for one material there is no group defined;
// Ignore Physical definitions and save all elements;
Mesh.SaveAll = 1;
Save "./Box_Mesh_TmpGmsh.unv";


//////////////////////////////////////////////////////////////////////
// GMSH documentation:
// http://gmsh.info/doc/texinfo/gmsh.html#Mesh
//
// We do not check if something went wrong, like negative jacobians etc. You can run GMSH manually yourself: 
//
// to see full GMSH log, run in bash:
// /usr/bin/gmsh - /tmp/shape2mesh.geo
//
// to run GMSH and keep file in GMSH GUI (with log), run in bash:
// /usr/bin/gmsh /tmp/shape2mesh.geo

 

the CAD model file

DBRep_DrawableShape

CASCADE Topology V1, (c) Matra-Datavision
Locations 2
1
              1               0               0               0 
              0               1               0               0 
              0               0               1               0 
2  1 -1 0
Curve2ds 24
1 0 0 1 0 
1 0 0 1 0 
1 1000 0 0 -1 
1 0 0 0 1 
1 0 -1000 1 0 
1 0 0 1 0 
1 0 0 0 -1 
1 0 0 0 1 
1 0 0 1 0 
1 0 8000 1 0 
1 1000 0 0 -1 
1 8000 0 0 1 
1 0 -1000 1 0 
1 0 8000 1 0 
1 0 0 0 -1 
1 8000 0 0 1 
1 0 0 0 1 
1 0 0 1 0 
1 1000 0 0 1 
1 0 0 1 0 
1 0 0 0 1 
1 0 1000 1 0 
1 1000 0 0 1 
1 0 1000 1 0 
Curves 12
1 0 0 0 0 0 1 
1 0 0 1000 -0 1 0 
1 0 1000 0 0 0 1 
1 0 0 0 -0 1 0 
1 8000 0 0 0 0 1 
1 8000 0 1000 0 1 0 
1 8000 1000 0 0 0 1 
1 8000 0 0 -0 1 0 
1 0 0 0 1 0 -0 
1 0 0 1000 1 0 -0 
1 0 1000 0 1 0 -0 
1 0 1000 1000 1 0 -0 
Polygon3D 0
PolygonOnTriangulations 24
2 1 2 
p 16.6666666666667 1 0 1000 
2 1 4 
p 16.6666666666667 1 0 1000 
2 2 3 
p 16.6666666666667 1 0 1000 
2 1 2 
p 16.6666666666667 1 0 1000 
2 4 3 
p 16.6666666666667 1 0 1000 
2 1 4 
p 16.6666666666667 1 0 1000 
2 1 4 
p 16.6666666666667 1 0 1000 
2 1 2 
p 16.6666666666667 1 0 1000 
2 1 2 
p 16.6666666666667 1 0 1000 
2 2 3 
p 16.6666666666667 1 0 1000 
2 2 3 
p 16.6666666666667 1 0 1000 
2 4 3 
p 16.6666666666667 1 0 1000 
2 4 3 
p 16.6666666666667 1 0 1000 
2 2 3 
p 16.6666666666667 1 0 1000 
2 1 4 
p 16.6666666666667 1 0 1000 
2 4 3 
p 16.6666666666667 1 0 1000 
2 1 2 
p 16.6666666666667 1 0 8000 
2 1 4 
p 16.6666666666667 1 0 8000 
2 4 3 
p 16.6666666666667 1 0 8000 
2 1 4 
p 16.6666666666667 1 0 8000 
2 1 2 
p 16.6666666666667 1 0 8000 
2 2 3 
p 16.6666666666667 1 0 8000 
2 4 3 
p 16.6666666666667 1 0 8000 
2 2 3 
p 16.6666666666667 1 0 8000 
Surfaces 6
1 0 0 0 1 0 -0 0 0 1 0 -1 0 
1 0 0 0 -0 1 0 0 0 1 1 0 -0 
1 0 0 1000 0 0 1 1 0 -0 -0 1 0 
1 0 1000 0 -0 1 0 0 0 1 1 0 -0 
1 0 0 0 0 0 1 1 0 -0 -0 1 0 
1 8000 0 0 1 0 -0 0 0 1 0 -1 0 
Triangulations 6
4 2 1 0
0 0 0 0 0 1000 0 1000 1000 0 1000 0 0 0 1000 0 1000 -1000 0 -1000 2 4 3 2 1 4 
4 2 1 0
0 0 0 8000 0 0 8000 0 1000 0 0 1000 0 0 0 8000 1000 8000 1000 0 3 2 1 3 1 4 
4 2 1 0
0 0 1000 0 1000 1000 8000 1000 1000 8000 0 1000 0 0 0 1000 8000 1000 8000 0 3 2 1 3 1 4 
4 2 1 0
0 1000 0 8000 1000 0 8000 1000 1000 0 1000 1000 0 0 0 8000 1000 8000 1000 0 3 2 1 3 1 4 
4 2 1 0
0 0 0 0 1000 0 8000 1000 0 8000 0 0 0 0 0 1000 8000 1000 8000 0 3 2 1 3 1 4 
4 2 1 0
8000 0 0 8000 0 1000 8000 1000 1000 8000 1000 0 0 0 1000 0 1000 -1000 0 -1000 2 4 3 2 1 4 

TShapes 34
Ve
1e-07
0 0 1000
0 0

0101101
*
Ve
1e-07
0 0 0
0 0

0101101
*
Ed
 1e-07 1 1 0
1  1 0 0 1000
2  1 1 0 0 1000
2  2 2 0 0 1000
6  1 1 0
6  2 2 0
0

0101000
-34 2 +33 2 *
Ve
1e-07
0 1000 1000
0 0

0101101
*
Ed
 1e-07 1 1 0
1  2 0 0 1000
2  3 1 0 0 1000
2  4 3 0 0 1000
6  3 1 0
6  4 3 0
0

0101000
-31 2 +34 2 *
Ve
1e-07
0 1000 0
0 0

0101101
*
Ed
 1e-07 1 1 0
1  3 0 0 1000
2  5 1 0 0 1000
2  6 4 0 0 1000
6  5 1 0
6  6 4 0
0

0101000
-31 2 +29 2 *
Ed
 1e-07 1 1 0
1  4 0 0 1000
2  7 1 0 0 1000
2  8 5 0 0 1000
6  7 1 0
6  8 5 0
0

0101000
-29 2 +33 2 *
Wi

0101000
-32 0 -30 0 +28 0 +27 0 *
Fa
0  1e-07 1 0
2  1
0101000
+26 0 *
Ve
1e-07
8000 0 1000
0 0

0101101
*
Ve
1e-07
8000 0 0
0 0

0101101
*
Ed
 1e-07 1 1 0
1  5 0 0 1000
2  9 6 0 0 1000
2  10 2 0 0 1000
6  9 6 0
6  10 2 0
0

0101000
-24 2 +23 2 *
Ve
1e-07
8000 1000 1000
0 0

0101101
*
Ed
 1e-07 1 1 0
1  6 0 0 1000
2  11 6 0 0 1000
2  12 3 0 0 1000
6  11 6 0
6  12 3 0
0

0101000
-21 2 +24 2 *
Ve
1e-07
8000 1000 0
0 0

0101101
*
Ed
 1e-07 1 1 0
1  7 0 0 1000
2  13 6 0 0 1000
2  14 4 0 0 1000
6  13 6 0
6  14 4 0
0

0101000
-21 2 +19 2 *
Ed
 1e-07 1 1 0
1  8 0 0 1000
2  15 6 0 0 1000
2  16 5 0 0 1000
6  15 6 0
6  16 5 0
0

0101000
-19 2 +23 2 *
Wi

0101000
-22 0 -20 0 +18 0 +17 0 *
Fa
0  1e-07 6 0
2  6
0101000
+16 0 *
Ed
 1e-07 1 1 0
1  9 0 0 8000
2  17 2 0 0 8000
2  18 5 0 0 8000
6  17 2 0
6  18 5 0
0

0101000
-23 2 +33 2 *
Ed
 1e-07 1 1 0
1  10 0 0 8000
2  19 2 0 0 8000
2  20 3 0 0 8000
6  19 2 0
6  20 3 0
0

0101000
-24 2 +34 2 *
Wi

0101000
-14 0 -22 0 +13 0 +32 0 *
Fa
0  1e-07 2 0
2  2
0101000
+12 0 *
Ed
 1e-07 1 1 0
1  11 0 0 8000
2  21 4 0 0 8000
2  22 5 0 0 8000
6  21 4 0
6  22 5 0
0

0101000
-19 2 +29 2 *
Ed
 1e-07 1 1 0
1  12 0 0 8000
2  23 4 0 0 8000
2  24 3 0 0 8000
6  23 4 0
6  24 3 0
0

0101000
-21 2 +31 2 *
Wi

0101000
-10 0 -18 0 +9 0 +28 0 *
Fa
0  1e-07 4 0
2  4
0101000
+8 0 *
Wi

0101000
-27 0 -10 0 +17 0 +14 0 *
Fa
0  1e-07 5 0
2  5
0101000
+6 0 *
Wi

0101000
-30 0 -9 0 +20 0 +13 0 *
Fa
0  1e-07 3 0
2  3
0101000
+4 0 *
Sh

0101100
-25 0 +15 0 -11 0 +7 0 -5 0 +3 0 *
So

1100000
+2 0 *

+1 1

 

 

 



CC-BY-NC 4.0 licensed free for non-commercial usage
Author: Qingfeng XIA
copyright (C) 2011-2020
http://www.iesensor.com
please keep the original link in your reference.
http://www.iesensor.com/blog/2017/06/16/boundarylayer-setup-for-gmsh-3d-meshing/
This entry was posted in Uncategorized. Bookmark the permalink.