3
$\begingroup$

I have a simple question today. I am new to GMSH and I am currently learning how to use the software program. I am using GMSH 3.0.4.

What I am looking to do is to set a different mesh size for different faces in my 2D geometry. As a test, I am creating 2 squares next to each other. The square on the left will have a mesh size set by the element size factor in the options dialog.

I have been doing some research on this matter and came across this for posting:

http://onelab.info/pipermail/gmsh/2009/004647.html

I also read section 6.3.1 in the user manual. In this section, it is stated that:

A MathEval field specifies the size of the mesh using an explicit mathematical function. 

So, I went to Mesh->Define->Size Fields and then New->MathEval and then typed in 0.001 in the box. I also set a restrict field by going to New->restrict. I typed my edge list and the face list that I want to restrict the field. Since this I want to restrict my first Mesh field, I typed in 1 in the IFields box.

I also ensured that the 2D mesh algorithm is set to Delauney.

However, I am still having difficulty in setting up a custom mesh size. I am attempting to bound a face to specific mesh size. I am posting my .geo file here so that others may take a look.

My question is this: What is the best method that I can do on the GUI in order to bound different faces to different mesh sizes?

Please note that currently the Element size factor is set to 1. Also note that I am generating a mesh of only quads.

My .geo file:

//+
SetFactory("Built-in");
//+
Point(1) = {0, 0, 0, 1.0};
//+
Point(2) = {1, 0, 0, 1.0};
//+
Point(3) = {1, 1, 0, 1.0};
//+
Point(4) = {0, 1, 0, 1.0};
//+
Line(1) = {1, 4};
//+
Line(2) = {4, 3};
//+
Line(3) = {3, 2};
//+
Line(4) = {2, 1};
//+
Line Loop(1) = {2, 3, 4, 1};
//+
Plane Surface(1) = {1};

Recombine Surface{1};
//+
Point(5) = {2, 1.2, 0, 1.0};
//+
Point(6) = {2, 0, 0, 1.0};
//+
Line(5) = {3, 5};
//+
Line(6) = {5, 6};
//+
Line(7) = {6, 2};
//+
Line Loop(2) = {5, 6, 7, -3};
//+
Plane Surface(2) = {2};
//+
Field[2] = Restrict;
//+
Field[2].EdgesList = {5, 6, 7, 3};
//+
Field[2].FacesList = {2};
//+
Field[1] = MathEval;
//+
Field[1].F = "1.0";


//+
//Background Field = 1;

//+

//+
Field[1].F = "0.01";
//+
Background Field = 1;
//+
Background Field = -1;
//+
Field[1].F = "0.001";
$\endgroup$
0

1 Answer 1

2
$\begingroup$

There are a couple of different ways to specify element mesh sizes in GMSH, I will explain the simplest one using the points here but for the others I suggest you check the manual: http://gmsh.info/doc/texinfo/gmsh.html#Specifying-mesh-element-sizes

As you have in your example you can define a GMSH point as: Point(point #) = {x, y, z, lc}; where x, y, z are the coordinate values and lc is the element mesh size. So if you want an element mesh size of 0.1 you write

Point(1) = {0,0,0,0.1};
Point(2) = {0,1,0,0.1};
Line(1)={1,2};

the line will be split into elements of 0.1 length. If you specify different lc's for different points GMSH will interpolate between them.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.