# [Gmsh] Size functions in gmsh

Ruth V. Sabariego r.sabariego at ulg.ac.be
Thu Nov 20 09:06:32 CET 2008

```I guess you are using an old version of GetDP. The treatment of
attractors has changed.
Try e.g. the nightly-build.
Ruth

Lei Zhang wrote:
> Hello,
>
> When I saved your example in a cube.geo file, and tried gmsh cube.geo,
> I got the following error,
> Error   : 'cube.geo', line 25 : parse error (Field)
> Error   : 'cube.geo', line 26 : parse error (Field)
> Error   : 'cube.geo', line 27 : parse error (Field)
> Error   : 'cube.geo', line 30 : parse error (Field)
> Error   : 'cube.geo', line 31 : parse error (Field)
> Error   : 'cube.geo', line 35 : parse error (Field)
>
> What's wrong?
>
> Thanks,
> Lei
>
>
> On Thu, Nov 20, 2008 at 3:03 PM, Christophe Geuzaine
> <cgeuzaine at ulg.ac.be> wrote:
>
>> Srinath Madhavan wrote:
>>
>>> Hi all,
>>>
>>> Is it possible to define a virtual line/curve in the center of a unit cube and get gmsh to refine the mesh all around the line/curve and coarsen the mesh as it moves away from the line toward the walls?
>>>
>>> In gambit, I would simply create a virtual line/curve and apply a size function to it. How would I do this in gmsh?
>>>
>> Here's an example:
>>
>> // a cube
>> lc = 0.3;
>> Point(1) = {0, 0, 0, lc};
>> Point(2) = {1, 0,  0, lc} ;
>> Point(3) = {1, 1, 0, lc} ;
>> Point(4) = {0, 1, 0, lc} ;
>> Line(1) = {1,2} ;
>> Line(2) = {3,2} ;
>> Line(3) = {3,4} ;
>> Line(4) = {4,1} ;
>> Line Loop(5) = {4,1,-2,3} ;
>> Plane Surface(6) = {5} ;
>> Extrude {0,0,1} { Surface{6}; }
>>
>> // the "virtual" curve
>> Point(15) = {0.1, 0.3, 0.5};
>> Point(16) = {0.2, 0.3, 0.3};
>> Point(17) = {0.3, 0.2, 0.3};
>> Point(18) = {0.4, 0.1, 0.4};
>> Point(19) = {0.5, 0.2, 0.4};
>> Spline(29) = {15, 16, 17, 18, 19};
>>
>> // Attractor field returns the distance to the curve (actually, the
>> // distance to 100 equidistant points on the curve)
>> Field[1] = Attractor;
>> Field[1].NNodesByEdge = 100;
>> Field[1].EdgesList = {29};
>>
>> // Matheval field returns "distance squared + lc/20"
>> Field[2] = MathEval;
>> Field[2].F = Sprintf("F1^2 + %g", lc / 20);
>>
>> // Use the minimum of "distance squared + lc/20" and the char lengths
>> // defined at geometrical points as the new char length
>> Background Field = 2;
>>
>>
>>
>>
>>
>>> Thanks & Best Regards,
>>>
>>> Free as in Freedom. May the source be with you!
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> gmsh mailing list
>>> gmsh at geuz.org
>>> http://www.geuz.org/mailman/listinfo/gmsh
>>>
>>>
>>>
>> --
>> Prof. Christophe Geuzaine
>> University of Liege, Electrical Engineering and Computer Science
>> http://www.montefiore.ulg.ac.be/~geuzaine
>>
>> _______________________________________________
>> gmsh mailing list
>> gmsh at geuz.org
>> http://www.geuz.org/mailman/listinfo/gmsh
>>
>>
>
> _______________________________________________
> gmsh mailing list
> gmsh at geuz.org
> http://www.geuz.org/mailman/listinfo/gmsh
>

--
Dr. Ir. Ruth V. Sabariego
University of Liege, Institut Montefiore,
Dept. of Electrical Engineering & Computer Science,
Applied & Computational Electromagnetics (ACE),
Sart Tilman Campus, Grande Traverse, 10 (B28), B-4000 LIEGE, Belgium
phone: +32-4-3663737 -- fax: +32-4-3662910 -- http://elap.montefiore.ulg.ac.be/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geuz.org/pipermail/gmsh/attachments/20081120/e27a5f8f/attachment.htm
```