# [Gmsh] Question about mesh refinement with stating of characteristic lengths

Christophe Geuzaine cgeuzaine at ulg.ac.be
Mon Jul 21 20:19:47 CEST 2008

```Moritz Nadler wrote:
> Hallo,
>
> I played a bit around the field commands which I still do not really understand
> (and the manual does not say much about them), but I am not satisfied with my
> results.
>
> How can I get soother changes in the element density where the fields are connected.
> I thought of something where you can state the length of a gradual change in the
> element density between the density of one entity and its neighbour.
>
> I fist thought the .DistMax statement is something like that but it seems to be
> ignored in general.
> .DistMin determines the size of a Field but DistMax does not do anything.
>

It does... The threshold field works like this:

LcMax -                         /------------------
/
/
/
LcMin -o----------------/
|                |       |
Attractor       DistMin   DistMax

At the moment the variation between LcMin and LcMax is always linear. It
might be nice to code other variations (power, log, ...): have a look at
Mesh/Field.cpp if you want to do that.

Here's an example:

// linear grading of charact lengths, from lc1 (near the attractor
// points) to lc2 (at a distance >= r away from the attractor points)

lc1 = 0.001;
lc2 = 0.1;
r = 0.5;

Point(1) = {0,0,0,lc2};
Point(2) = {1,0,0,lc2};
Point(3) = {1,1,0,lc2};
Point(4) = {0,1,0,lc2};
Line(1) = {3,2};
Line(2) = {2,1};
Line(3) = {1,4};
Line(4) = {4,3};
Line Loop(5) = {1,2,3,4};
Plane Surface(6) = {5};

Point(10) = {0.3,0.5,0};
Point(11) = {0.35,0.5,0};

Field = Attractor;
Field.NodesList = {10,11};

Field = Threshold;
Field.IField = 1;
Field.LcMin = lc1;
Field.LcMax = lc2;
Field.DistMin = lc1;
Field.DistMax = r;

Background Field = 2;

--
Prof. Christophe Geuzaine
University of Liege, Electrical Engineering and Computer Science
http://www.montefiore.ulg.ac.be/~geuzaine

```