# How to create a 2D boundary layer in gmsh?

 User Name Remember Me Password
 Register Blogs Members List Search Today's Posts Mark Forums Read

 November 8, 2021, 22:02 How to create a 2D boundary layer in gmsh? #1 Senior Member   Lee Strobel Join Date: Jun 2016 Posts: 133 Rep Power: 8 Hi, I am wondering if anyone can help? I am not very experienced with gmsh and I am trying to figure out how to use the 2D boundary layer function, but I am struggling. I have made a .geo file for a simple square geometry with a boundary layer on the lower face, as follows: Code: ```Point(1) = {0.0000, 0.0000, 0.0000}; Point(2) = {40.0000, 0.0000, 0.0000}; Point(3) = {40.0000, 40.0000, 0.0000}; Point(4) = {0.0000, 40.0000, 0.0000}; Line(5) = {1,2}; Line(6) = {2,3}; Line(7) = {3,4}; Line(8) = {4,1}; Curve Loop(1) = {5,6,7,8}; Plane Surface(1) = {1}; Field[1] = BoundaryLayer; Field[1].AnisoMax = 1000; Field[1].Quads = 1; Field[1].Thickness = 5; Field[1].CurvesList = {5}; Field[1].Thickness = 3; Field[1].NbLayers = 10; Field[1].PointsList = {1,2}; Field[1].Quads = 1; Field[1].Ratio = 1.1; Field[1].Size = 0.2; Field[1].SizeFar = 2; Background Field = 1;``` However, when I try to mesh the geometry, it is not creating the boundary mesh. The documentation doesn't seem to provide a lot of detail on how the boundary layer feature works and there isn't any error message indicating what is wrong. Does anyone have any idea why it is not working?

 November 9, 2021, 04:30 #2 Senior Member   Join Date: Oct 2011 Posts: 195 Rep Power: 13 Hello, Try to replace : Background Field = 1; by BoundaryLayer Field = 1; seems to work for me with v4.8.4, I followed this thread: http://onelab.info/pipermail/gmsh/2019/013093.html Good luck Time4Tea likes this.

November 9, 2021, 09:57
#3
Senior Member

Lee Strobel
Join Date: Jun 2016
Posts: 133
Rep Power: 8
Quote:
 Originally Posted by naffrancois Try to replace : Background Field = 1; by BoundaryLayer Field = 1;

Hi, thanks for your reply. I did as you suggested and replaced 'Background Field = 1' with 'BoundaryLayer Field = 1' and it is now making the boundary layer mesh. However, the results don't look great. Using the following .geo script:

Code:
```SetFactory("OpenCASCADE");

Point(1) = {0.0000, 0.0000, 0.0000,0.5};
Point(2) = {40.0000, 0.0000, 0.0000,0.5};
Point(3) = {40.0000, 40.0000, 0.0000,3};
Point(4) = {0.0000, 40.0000, 0.0000,3};

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

Line Loop(1) = {5,6,7,8};
Plane Surface(1) = {1};

//Boundary Layer
Field[1] = BoundaryLayer;
Field[1].Thickness = 2;
Field[1].EdgesList = {5};
Field[1].NbLayers = 6;
Field[1].NodesList = {1,2};
Field[1].Ratio = 1.2;
Field[1].hwall_n = 0.1;
Field[1].hfar = 1.5;
Field[1].IntersectMetrics = 1;

BoundaryLayer Field = 1;

Mesh.Algorithm = 6;
Recombine Surface {1};```
Results in the mesh shown in the following image:

i.e. there seems to be some strange behavior going on at the edges. However, in the example shown at the link you posted, that isn't happening. Do you have any idea what is wrong?

November 9, 2021, 10:05
#4
Senior Member

Join Date: Oct 2011
Posts: 195
Rep Power: 13
Weird, your script works as expected on my machine, see attachment

I am using linux binaries from version 4.8.4

By the way, I guess this geometry is just for testing purposes otherwise if you just need to quad-mesh a square with refinement on one boundary, tranfinite tools are a way simpler approach
Attached Images
 gmsh.png (43.1 KB, 24 views)

November 9, 2021, 10:34
#5
Senior Member

Lee Strobel
Join Date: Jun 2016
Posts: 133
Rep Power: 8
Quote:
 Originally Posted by naffrancois Weird, your script works as expected on my machine, see attachment I am using linux binaries from version 4.8.4 By the way, I guess this geometry is just for testing purposes otherwise if you just need to quad-mesh a square with refinement on one boundary, tranfinite tools are a way simpler approach

Hmm ... yes that is very strange. What you are getting there is pretty close to what I had hoped to achieve. The version I am using seems to be 4.8.4, which I downloaded and compiled directly from the git repository. I might submit this as a bug report and see if the developers have any idea what might be causing it.

Thanks again for your help!

P.S. yes, that simple geometry is just a test case to try to get the boundary layer feature working. The real cases I want to analyze are also 2D but a bit more complex - they are rectangular, with a curved boundary re-entrant in one corner (which is where I want to apply the boundary layer).

 November 9, 2021, 11:12 #6 Senior Member   Lee Strobel Join Date: Jun 2016 Posts: 133 Rep Power: 8 Unless it could be down to different default settings you are using (e.g. meshing algorithm)?

 November 9, 2021, 11:15 #7 Senior Member   Join Date: Oct 2011 Posts: 195 Rep Power: 13 I downloaded 4.8.4 specifically to run your script, so I did not modify any defaults and ran the script as is. Have you tried to use the precompiled binaries instead of compiling from source ?

November 9, 2021, 11:23
#8
Senior Member

Lee Strobel
Join Date: Jun 2016
Posts: 133
Rep Power: 8
Quote:
 Originally Posted by naffrancois I downloaded 4.8.4 specifically to run your script, so I did not modify any defaults and ran the script as is. Have you tried to use the precompiled binaries instead of compiling from source ?

Ok. No, I haven't tried the precompiled binaries, but thanks for the suggestion. I will download and give them a try

November 9, 2021, 11:31
#9
Senior Member

Lee Strobel
Join Date: Jun 2016
Posts: 133
Rep Power: 8
Quote:
 Originally Posted by naffrancois I downloaded 4.8.4 specifically to run your script, so I did not modify any defaults and ran the script as is. Have you tried to use the precompiled binaries instead of compiling from source ?

I just downloaded the 4.8.4 binary directly from gmsh.info and it seems to be doing exactly the same thing, giving the odd behavior at the edges.

Perhaps the issue is with one of the libraries that gmsh depends on (opencascade perhaps)?

 November 9, 2021, 11:37 #10 Senior Member   Join Date: Oct 2011 Posts: 195 Rep Power: 13 are you running on a linux system ? Sorry I do not have any idea what the reason may be

November 9, 2021, 12:02
#11
Senior Member

Lee Strobel
Join Date: Jun 2016
Posts: 133
Rep Power: 8
Quote:
 Originally Posted by naffrancois are you running on a linux system ? Sorry I do not have any idea what the reason may be

Yes, I'm running on Arch Linux. So, my libraries should be fairly recent.

 November 10, 2021, 09:36 #12 Senior Member   Lee Strobel Join Date: Jun 2016 Posts: 133 Rep Power: 8 So, I downloaded the MacOS version of gmsh and with that the boundary layer meshing seems to work fine. So, it must be some sort of bug with the Linux version. I also applied to join the gmsh gitlab group, so I could report the bug; however, I received an e-mail back saying the request had been denied. Has anyone else reported problems joining their gitlab?

 Tags gmsh, mesh

 Thread Tools Search this Thread Search this Thread: Advanced Search Display Modes Linear Mode

 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 OffTrackbacks are Off Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post [snappyHexMesh] layer not added Rasmusiwersen OpenFOAM Meshing & Mesh Conversion 1 January 2, 2020 10:43 Abo Anas CFX 27 May 11, 2018 02:44 bcorr OpenFOAM Meshing & Mesh Conversion 0 April 18, 2012 14:38 [snappyHexMesh] Boundary layer generation problems ivan_cozza OpenFOAM Meshing & Mesh Conversion 0 October 6, 2010 14:47 SSL FLUENT 2 January 26, 2008 12:55

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

 Contact Us - CFD Online - Privacy Statement - Top