Create a mesh from xy coordinates

Hello!

I have a .txt file with the xy coordinates of the border of my mesh. I tried the trinagulate() command, but I get the error “Assertion fail : (area > 0)”. I tried reducing the number of point and got another error “Sorry Error build delaunay triangle error = 20”. My code is only this, since I’m only trying to build the mesh:

mesh Th=triangulate(“Prueba.txt”);
plot(Th,wait=0);

And the file named Prueba.txt (I can’t upload it as a file):

5.54574920787 -4.49888641425
5.55523530867 -3.85300668151
5.59832307088 -3.63028953229
5.70689161584 -3.46325167038
5.86999917512 -3.32962138085
6.02233479385 -3.25167037862
6.10945650222 -3.24053452116
6.2183889641 -3.24053452116
6.34910791835 -3.24053452116
6.33804484427 -3.16258351893
6.29425350937 -3.06236080178
6.33772944961 -3.01781737194
6.58783741163 -2.81737193764
6.77273146329 -2.68374164811
7.0228394253 -2.48329621381
7.25123367833 -2.31625835189
7.30553008137 -2.23830734967
7.43581233533 -2.03786191537
7.54440514142 -1.88195991091
7.64210470132 -1.72605790646
7.72893527616 -1.58129175947
7.81579011213 -1.44766146993
7.87008651518 -1.36971046771
7.91346541091 -1.28062360802
7.96766476945 -1.15812917595
8.02188838911 -1.04677060134
8.08690821045 -0.890868596882
8.16277275572 -0.712694877506
8.22779257707 -0.556792873051
8.27114721167 -0.456570155902
8.28191915222 -0.400890868597
8.30329320543 -0.211581291759
8.31379827358 -0.0334075723831
8.33514806566 0.167037861915
8.34570165606 0.32293986637
8.35623098534 0.489977728285
8.36693014251 0.579064587973
8.30028482564 1.16926503341
8.23385785891 1.65924276169
8.08062457846 1.99331848552
7.86174068737 2.46102449889
7.37008894129 3.12917594655
5.74398687958 4.51002227171
4.97025100562 4.65478841871
4.29567035921 4.28730512249
4.03573664061 3.59688195991
4.03825979786 -2.56124721604
4.1145367823 -2.5723830735
4.20175553518 -2.60579064588
4.29994031763 -2.67260579065
4.37631434658 -2.72828507795
4.43097466653 -2.81737193764
4.47481452368 -2.93986636971
4.48585333663 -3.00668151448
4.5078096569 -3.0846325167
4.50797948479 -3.16258351893
4.46460058906 -3.25167037862
4.41044975278 -3.39643652561
4.37789131985 -3.45211581292
4.3671193793 -3.50779510022
4.34545419257 -3.56347438753
4.29118205065 -3.65256124722
4.25867213998 -3.73051224944
4.20439999806 -3.81959910913
4.18273481132 -3.87527839644
4.21548733327 -3.90868596882
4.28084681039 -3.90868596882
4.36799277989 -3.90868596882
4.44426976433 -3.91982182628
4.48784274908 -3.91982182628
4.54213915212 -3.84187082405
4.60735306248 -3.77505567929
4.67263975622 -3.7416481069
4.77063044966 -3.71937639198
4.90137366503 -3.73051224944
4.97765064947 -3.7416481069
5.05400041729 -3.78619153675
5.10853943161 -3.81959910913
5.19587949013 -3.90868596882
5.23962230277 -3.98663697105
5.26162714529 -4.0868596882
5.26182123431 -4.17594654788
5.27290856952 -4.26503340757
5.54574920787 -4.49888641425

Thanks!

I did not check the program, but the problem might be related to the fact that yo only specify meshpoints at the border of the boundary. triangulate I think only creates a mesh from the points it is given, it does not generate any other points.Try adding some point into the computational domain.

Yes. I think what you are looking for is in this post

Thank you both for the answers. I actually found a way to solve this issue. Just in case someone is facing the same problem, I post the solution:

real[int] xx = [5.545749208, 5.555235309, 5.598323071, 5.706891616, 5.869999175, 6.022334794, 6.109456502, 6.218388964, 6.349107918, 6.338044844, 6.294253509, 6.337729450, 6.587837412, 6.772731463, 7.022839425, 7.251233678, 7.305530081, 7.435812335, 7.544405141, 7.642104701, 7.728935276, 7.815790112, 7.870086515, 7.913465411, 7.967664769, 8.021888389, 8.086908210, 8.162772756, 8.227792577, 8.271147212, 8.281919152, 8.303293205, 8.313798274, 8.335148066, 8.345701656, 8.356230985, 8.366930143, 8.300284826, 8.233857859, 8.080624578, 7.861740687, 7.370088941, 5.743986880, 4.970251006, 4.295670359, 4.035736641, 4.038259798, 4.114536782, 4.201755535, 4.299940318, 4.376314347, 4.430974667, 4.474814524, 4.485853337, 4.507809657, 4.507979485, 4.464600589, 4.410449753, 4.377891320, 4.367119379, 4.345454193, 4.291182051, 4.258672140, 4.204399998, 4.182734811, 4.215487333, 4.280846810, 4.367992780, 4.444269764, 4.487842749, 4.542139152, 4.607353062, 4.672639756, 4.770630450, 4.901373665, 4.977650649, 5.054000417, 5.108539432, 5.195879490, 5.239622303, 5.261627145, 5.261821234, 5.272908570]; //Array of x values
real[int] yy = [-4.498886414, -3.853006682, -3.630289532, -3.463251670, -3.329621381, -3.251670379, -3.240534521, -3.240534521, -3.240534521, -3.162583519, -3.062360802, -3.017817372, -2.817371938, -2.683741648, -2.483296214, -2.316258352, -2.238307350, -2.037861915, -1.881959911, -1.726057906, -1.581291759, -1.447661470, -1.369710468, -1.280623608, -1.158129176, -1.046770601, -0.890868597, -0.712694878, -0.556792873, -0.456570156, -0.400890869, -0.211581292, -0.033407572, 0.1670378620, 0.3229398660, 0.489977728, 0.5790645880, 1.1692650330, 1.6592427620, 1.9933184860, 2.461024499, 3.129175947, 4.510022272, 4.6547884190, 4.2873051220, 3.5968819600, -2.561247216, -2.572383074, -2.605790646, -2.672605791, -2.728285078, -2.817371938, -2.93986637, -3.006681514, -3.084632517, -3.162583519, -3.251670379, -3.396436526, -3.452115813, -3.50779510, -3.563474388, -3.652561247, -3.730512249, -3.819599109, -3.875278396, -3.908685969, -3.908685969, -3.908685969, -3.919821826, -3.919821826, -3.841870824, -3.775055679, -3.741648107, -3.719376392, -3.730512249, -3.741648107, -3.786191537, -3.819599109, -3.908685969, -3.986636971, -4.086859688, -4.175946548, -4.265033408]; //Array of y values

border bb(t=0, 1; i)
{
// i is the index variable of the multi border loop
int ii = (i+1)%83; //83 is the number of points in xx and yy.
real t1 = 1-t;
x = xx[i]*t1 + xx[ii]*t;
y = yy[i]*t1 + yy[ii]*t;
}

int[int] nn = [7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 7, 10, 5, 5, 5, 30, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5]; //numer of partitions on each line joining two dots .
plot(bb(nn), wait=1);
mesh th = buildmesh(bb(nn));
plot(th, wait=1);

Hello,

I have a question related to this topic. If I have a set of points (over the whole domain, not only the boundary) and a set of triangles (each of them defined by 3 indexes of points ordered counter-clockwise), is there a way to create the asociated mesh in FreeFEM?

I supose that I can read all the data, rewrite it in a .msh in the FreeFEM format by hand and read it with readmesh, but I’m looking for something simplier and faster when i have the data already loaded as arrays in FreeFEM.

If there is not such a way to build a mesh, it will also be helpful to know that is something that you can not do.

Thank you,