# [Gmsh] Variable characteristic length over a surface

Karl Kästner kastner.karl at gmail.com
Thu May 26 21:50:08 CEST 2016

```Hello,

I want to vary the element size over a surface. More specifically I
want to geometrically increase the element size with increasing
distance from the boundary. I tried to use the boundary layer option
but this did not work, as the surface shape is nontrivial and the
edge length has also to vary along the boundary.

Therefore I first generate an initial mesh, then compute the local
element size at the interior points of the initial mesh, add the
interior points of the initial mesh to the geometry file and finally
generate a second mesh.

Unfortunately the points of the first mesh are also vertices of the
second mesh, thus the element size of the second mesh cannot be
lower than that of the first mesh. I tried to add the points to an
attractor field, but gmsh displayed following warning and crashes:

Error   : Wrong mesh element size lc = 0 (lcmin = 0, lcmax = 1e+22)

Attached a trivial example reproducing the behaviour. Any help is
appreciated.

Kind regards,

--
Karl Kästner
------------
Phd Student at Wageningen University & Research centre
Hydrology and Quantitative Water Management Group
Droevendaalsesteeg 3, Lumen building, 6708 PB Wageningen, The
Netherlands
Phone: +31617876970 (Netherlands) +491627351075 (Germany)
Mail: kastner.karl at gmail.com
-------------- next part --------------
Point(1) = {0.000000,1.000000,0.000000,0.200000};
Point(2) = {0.194568,0.978886,0.000000,0.200000};
Point(3) = {0.382083,0.923285,0.000000,0.200000};
Point(4) = {0.554231,0.830233,0.000000,0.200000};
Point(5) = {0.705692,0.706589,0.000000,0.200000};
Point(6) = {0.829917,0.555399,0.000000,0.200000};
Point(7) = {0.921898,0.382867,0.000000,0.200000};
Point(8) = {0.979793,0.195941,0.000000,0.200000};
Point(9) = {0.998038,0.001214,0.000000,0.200000};
Point(10) = {0.981014,-0.193754,0.000000,0.200000};
Point(11) = {0.922632,-0.380547,0.000000,0.200000};
Point(12) = {0.831778,-0.553754,0.000000,0.200000};
Point(13) = {0.707104,-0.704585,0.000000,0.200000};
Point(14) = {0.556476,-0.829244,0.000000,0.200000};
Point(15) = {0.384062,-0.921785,0.000000,0.200000};
Point(16) = {0.196988,-0.978623,0.000000,0.200000};
Point(17) = {0.002383,-0.999163,0.000000,0.200000};
Point(18) = {-0.192189,-0.979364,0.000000,0.200000};
Point(19) = {-0.380151,-0.924848,0.000000,0.200000};
Point(20) = {-0.552102,-0.831410,0.000000,0.200000};
Point(21) = {-0.704445,-0.708740,0.000000,0.200000};
Point(22) = {-0.828230,-0.557178,0.000000,0.200000};
Point(23) = {-0.921370,-0.385264,0.000000,0.200000};
Point(24) = {-0.978713,-0.198176,0.000000,0.200000};
Point(25) = {-0.998258,-0.003638,0.000000,0.200000};
Point(26) = {-0.980663,0.191254,0.000000,0.200000};
Point(27) = {-0.923571,0.378309,0.000000,0.200000};
Point(28) = {-0.833633,0.552126,0.000000,0.200000};
Point(29) = {-0.708678,0.702730,0.000000,0.200000};
Point(30) = {-0.558832,0.828444,0.000000,0.200000};
Point(31) = {-0.386138,0.920483,0.000000,0.200000};
Point(32) = {-0.199443,0.978578,0.000000,0.200000};
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 5};
Line(5) = {5, 6};
Line(6) = {6, 7};
Line(7) = {7, 8};
Line(8) = {8, 9};
Line(9) = {9, 10};
Line(10) = {10, 11};
Line(11) = {11, 12};
Line(12) = {12, 13};
Line(13) = {13, 14};
Line(14) = {14, 15};
Line(15) = {15, 16};
Line(16) = {16, 17};
Line(17) = {17, 18};
Line(18) = {18, 19};
Line(19) = {19, 20};
Line(20) = {20, 21};
Line(21) = {21, 22};
Line(22) = {22, 23};
Line(23) = {23, 24};
Line(24) = {24, 25};
Line(25) = {25, 26};
Line(26) = {26, 27};
Line(27) = {27, 28};
Line(28) = {28, 29};
Line(29) = {29, 30};
Line(30) = {30, 31};
Line(31) = {31, 32};
Line(32) = {32, 1};
Line Loop(1) = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32};
Mesh.Remove4Triangles = 1;
Mesh.CharacteristicLengthFromPoints = 0;
Plane Surface(1) = {1};
Mesh.CharacteristicLengthFromPoints = 1;
Point(35) = {0.000000,1.000000,0.000000,0.209847};
Point(36) = {0.194568,0.978886,0.000000,0.200000};
Point(37) = {0.382083,0.923285,0.000000,0.200000};
Point(38) = {0.554231,0.830233,0.000000,0.200000};
Point(39) = {0.705692,0.706589,0.000000,0.200000};
Point(40) = {0.829917,0.555399,0.000000,0.200000};
Point(41) = {0.921898,0.382867,0.000000,0.200000};
Point(42) = {0.979793,0.195941,0.000000,0.200000};
Point(43) = {0.998038,0.001214,0.000000,0.200000};
Point(44) = {0.981014,-0.193754,0.000000,0.200000};
Point(45) = {0.922632,-0.380547,0.000000,0.200000};
Point(46) = {0.831778,-0.553754,0.000000,0.200000};
Point(47) = {0.707104,-0.704585,0.000000,0.200000};
Point(48) = {0.556476,-0.829244,0.000000,0.200000};
Point(49) = {0.384062,-0.921785,0.000000,0.200000};
Point(50) = {0.196988,-0.978623,0.000000,0.200000};
Point(51) = {0.002383,-0.999163,0.000000,0.200000};
Point(52) = {-0.192189,-0.979364,0.000000,0.200000};
Point(53) = {-0.380151,-0.924848,0.000000,0.200000};
Point(54) = {-0.552102,-0.831410,0.000000,0.200000};
Point(55) = {-0.704445,-0.708740,0.000000,0.200000};
Point(56) = {-0.828230,-0.557178,0.000000,0.200000};
Point(57) = {-0.921370,-0.385264,0.000000,0.200000};
Point(58) = {-0.978713,-0.198176,0.000000,0.200000};
Point(59) = {-0.998258,-0.003638,0.000000,0.200000};
Point(60) = {-0.980663,0.191254,0.000000,0.200000};
Point(61) = {-0.923571,0.378309,0.000000,0.200000};
Point(62) = {-0.833633,0.552126,0.000000,0.200000};
Point(63) = {-0.708678,0.702730,0.000000,0.200000};
Point(64) = {-0.558832,0.828444,0.000000,0.200000};
Point(65) = {-0.386138,0.920483,0.000000,0.200000};
Point(66) = {-0.199443,0.978578,0.000000,0.200000};
Point(67) = {0.007676,0.008831,0.000000,0.537079};
Point(68) = {-0.057039,0.503503,0.000000,0.329550};
Point(69) = {-0.407589,-0.311682,0.000000,0.325603};
Point(70) = {0.238101,-0.433857,0.000000,0.332359};
Point(71) = {0.451464,0.120145,0.000000,0.341402};
Point(72) = {-0.439754,0.228663,0.000000,0.332303};
Point(73) = {0.344860,0.508997,0.000000,0.294227};
Point(74) = {-0.114422,-0.602312,0.000000,0.293954};
Point(75) = {0.564229,-0.234213,0.000000,0.294625};
Point(76) = {-0.645596,-0.085210,0.000000,0.284400};
Point(77) = {-0.395911,0.522997,0.000000,0.283408};
Point(78) = {-0.046948,-0.284025,0.000000,0.407159};
Point(79) = {0.273539,-0.137783,0.000000,0.400229};
Point(80) = {0.150229,0.256174,0.000000,0.404346};
Point(81) = {-0.292987,-0.040390,0.000000,0.404588};
Point(82) = {-0.165832,0.236584,0.000000,0.407754};
Point(83) = {0.604383,0.425951,0.000000,0.259654};
Point(84) = {0.139018,0.704635,0.000000,0.265962};
Point(85) = {0.119912,-0.741185,0.000000,0.256717};
Point(86) = {0.516175,-0.521434,0.000000,0.260588};
Point(87) = {0.742600,0.024743,0.000000,0.258543};
Point(88) = {-0.401185,-0.611209,0.000000,0.261208};
Point(89) = {-0.626128,-0.358160,0.000000,0.265617};
Point(90) = {-0.693980,0.129845,0.000000,0.268252};
Point(91) = {-0.192615,0.669524,0.000000,0.273688};
Point(92) = {-0.579151,0.434925,0.000000,0.264977};
Point(93) = {0.764571,0.210664,0.000000,0.248218};
Point(94) = {0.399709,-0.694444,0.000000,0.245938};
Point(95) = {0.272997,0.081574,0.000000,0.409521};
Point(96) = {0.379545,0.712825,0.000000,0.247631};
Point(97) = {-0.254552,-0.748127,0.000000,0.248423};
Point(98) = {0.774339,-0.231678,0.000000,0.246777};
Point(99) = {0.345401,0.297705,0.000000,0.345519};
Point(100) = {-0.207549,-0.416624,0.000000,0.342184};
Point(101) = {0.455153,-0.082598,0.000000,0.342546};
Point(102) = {0.531632,0.589911,0.000000,0.246999};
Point(103) = {-0.041422,-0.795576,0.000000,0.246305};
Point(104) = {0.682185,-0.406960,0.000000,0.246641};
Point(105) = {-0.618550,-0.542474,0.000000,0.241162};
Point(106) = {0.148235,0.486394,0.000000,0.329036};
Point(107) = {0.042067,-0.462181,0.000000,0.342762};
Point(108) = {0.374194,-0.299677,0.000000,0.337670};
Point(109) = {-0.243794,-0.216808,0.000000,0.392622};
Point(110) = {-0.309233,0.340424,0.000000,0.343649};
Point(111) = {-0.454901,-0.141129,0.000000,0.338772};
Point(112) = {-0.057877,0.815925,0.000000,0.244445};
Point(113) = {-0.763972,-0.237300,0.000000,0.248240};
Point(114) = {-0.392296,0.730161,0.000000,0.242694};
Point(115) = {-0.843745,0.002926,0.000000,0.233464};
Point(116) = {0.151894,-0.290659,0.000000,0.392013};
Point(117) = {-0.555851,0.616564,0.000000,0.238669};
Point(118) = {-0.489134,0.069638,0.000000,0.332120};
Point(119) = {-0.001835,0.173906,0.000000,0.457674};
Point(120) = {-0.218149,0.484797,0.000000,0.319982};
Point(121) = {-0.306646,0.143071,0.000000,0.387583};
Point(122) = {-0.737451,0.359859,0.000000,0.241224};
Point(123) = {0.002781,0.341857,0.000000,0.387201};
Point(124) = {-0.146492,0.070633,0.000000,0.461936};
Point(125) = {0.857526,0.086267,0.000000,0.235713};
Point(126) = {0.548471,-0.666238,0.000000,0.235455};
Point(127) = {0.847935,-0.079759,0.000000,0.237199};
Point(128) = {0.252584,-0.825326,0.000000,0.235423};
Point(129) = {-0.418002,-0.760796,0.000000,0.232729};
Point(130) = {0.054268,-0.148409,0.000000,0.463999};
Point(131) = {0.247107,0.808512,0.000000,0.240095};
Point(132) = {0.761210,0.407985,0.000000,0.235380};
Point(133) = {0.150008,-0.020527,0.000000,0.467642};
Point(134) = {-0.004074,0.645590,0.000000,0.286445};
Point(135) = {-0.430638,-0.463792,0.000000,0.288830};
Point(136) = {-0.111380,-0.101695,0.000000,0.467725};
Point(137) = {0.205993,-0.612862,0.000000,0.285711};
Point(138) = {0.574638,0.263812,0.000000,0.288978};
Point(139) = {-0.595730,0.264419,0.000000,0.283226};
Point(140) = {0.657489,-0.564953,0.000000,0.231945};
Point(141) = {0.106089,-0.867975,0.000000,0.230792};
Point(142) = {0.683610,0.536256,0.000000,0.231906};
Point(143) = {-0.463956,0.358286,0.000000,0.304078};
Point(144) = {-0.538857,-0.690926,0.000000,0.230310};
Point(145) = {-0.585163,-0.221151,0.000000,0.290817};
Point(146) = {0.462386,0.412318,0.000000,0.293486};
Point(147) = {0.609423,0.066846,0.000000,0.296217};
Point(148) = {-0.268914,-0.561785,0.000000,0.292410};
Point(149) = {-0.245674,0.822934,0.000000,0.236623};
Point(150) = {-0.759991,-0.417287,0.000000,0.233683};
Point(151) = {0.119489,0.103359,0.000000,0.464478};
Point(152) = {0.367517,-0.502326,0.000000,0.291795};
Point(153) = {-0.682953,0.533241,0.000000,0.232915};
Point(154) = {0.264712,0.627192,0.000000,0.276040};
Point(155) = {0.666327,-0.102656,0.000000,0.277600};
Point(156) = {0.104563,0.861591,0.000000,0.233906};
Point(157) = {0.033527,-0.634414,0.000000,0.288440};
Point(158) = {0.505687,-0.375417,0.000000,0.290081};
Point(159) = {-0.135367,0.375457,0.000000,0.365340};
Point(160) = {-0.835882,0.212438,0.000000,0.231537};
Field[1] = Attractor;
Field[1].NodesList = { 34,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160};
Background Field = 1;
```