-- FreeFem++ v4.6 (Thu Apr 2 15:47:38 CEST 2020 - git v4.6) Load: lg_fem lg_mesh lg_mesh3 eigenvalue 1 : // Discussion: 2 : // 3 : // This FreeFem++ script generates meshes using polygonal borders. 4 : // 5 : // Location: 6 : // 7 : // http://people.sc.fsu.edu/~jburkardt/freefem++/polygonal_mesh/polygonal_mesh.edp 8 : // 9 : // Licensing: 10 : // 11 : // This code is distributed under the GNU LGPL license. 12 : // 13 : // Modified: 14 : // 15 : // 18 February 2015 16 : // 17 : // Author: 18 : // 19 : // John Burkardt 20 : // 21 : 22 : // 23 : // Mesh a square on [0,1]x[0,1] into 4 by 5 elements by specifying the sides. 24 : // 25 : border bottom ( t = 0.0, 1.0 ) { x = t; y = 0.0; } 26 : border right ( t = 0.0, 1.0 ) { x = 1.0; y = t; } 27 : border top ( t = 1.0, 0.0 ) { x = t; y = 1.0; } 28 : border left ( t = 1.0, 0.0 ) { x = 0.0; y = t; } 29 : mesh Th1 = buildmesh ( bottom ( 4 ) + right ( 5 ) + top ( 4 ) + left ( 5 ) ); 30 : plot ( Th1, wait = 1, ps = "polygonal1.ps" ); 31 : // 32 : // Make a square on [0,1]x[0,1], forcing an interior diagonal line. 33 : // 34 : border bottom2 ( t = 0.0, 1.0 ) { x = t; y = 0.0; } 35 : border right2 ( t = 0.0, 1.0 ) { x = 1.0; y = t; } 36 : border top2 ( t = 1.0, 0.0 ) { x = t; y = 1.0; } 37 : border left2 ( t = 1.0, 0.0 ) { x = 0.0; y = t; } 38 : border diag ( t = 0.0, 1.0 ) { x = t; y = t; } 39 : mesh Th2 = buildmesh ( bottom2 ( 10 ) + right2 ( 10 ) 40 : + top2 ( 10 ) + left2 ( 10 ) + diag ( 14 ) ); 41 : plot ( Th2, wait = 1, ps = "polygonal2.ps" ); 42 : // 43 : // Make a square on [0,4]x[0,4] with a CCW pentagonal hole. 44 : // 45 : border bottom3 ( t = 0.0, 1.0 ) { x = 4.0 * t; y = 0.0; } 46 : border right3 ( t = 0.0, 1.0 ) { x = 4.0; y = 4.0 * t; } 47 : border top3 ( t = 1.0, 0.0 ) { x = 4.0 * t; y = 4.0; } 48 : border left3 ( t = 1.0, 0.0 ) { x = 0.0; y = 4.0 * t; } 49 : border p1 ( t = 1.0, 2.0 ) { x = t; y = 1.0; } 50 : border p2 ( t = 1.0, 2.0 ) { x = 2.0; y = t;} 51 : border p3 ( t = 0.0, 0.5 ) { x = 2.0 - t; y = 2.0 + t; } 52 : border p4 ( t = 0.5, 0.0 ) { x = 1.0 + t; y = 2.0 + t; } 53 : border p5 ( t = 2.0, 1.0 ) { x = 1.0; y = t; } 54 : mesh Th3 = buildmesh ( bottom3 ( 16 ) + right3 ( 16 ) + top3 ( 16 ) + left3 ( 16 ) 55 : + p1 ( 4 ) + p2 ( 4 ) + p3 ( 3 ) + p4 ( 3 ) + p5 ( 4 ) ); 56 : plot ( Th3, wait = 1, ps = "polygonal3.ps" ); 57 : // 58 : // Make a square on [0,4]x[0,4] with a CW pentagonal hole. 59 : // 60 : border bottom4 ( t = 0.0, 1.0 ) { x = 4.0 * t; y = 0.0; } 61 : border right4 ( t = 0.0, 1.0 ) { x = 4.0; y = 4.0 * t; } 62 : border top4 ( t = 1.0, 0.0 ) { x = 4.0 * t; y = 4.0; } 63 : border left4 ( t = 1.0, 0.0 ) { x = 0.0; y = 4.0 * t; } 64 : border q1 ( t = 2.0, 1.0 ) { x = t; y = 1.0; } 65 : border q2 ( t = 2.0, 1.0 ) { x = 2.0; y = t;} 66 : border q3 ( t = 0.5, 0.0 ) { x = 2.0 - t; y = 2.0 + t; } 67 : border q4 ( t = 0.0, 0.5 ) { x = 1.0 + t; y = 2.0 + t; } 68 : border q5 ( t = 1.0, 2.0 ) { x = 1.0; y = t; } 69 : mesh Th4 = buildmesh ( bottom4 ( 16 ) + right4 ( 16 ) + top4 ( 16 ) + left4 ( 16 ) 70 : + q1 ( 4 ) + q2 ( 4 ) + q3 ( 3 ) + q4 ( 3 ) + q5 ( 4 ) ); 71 : plot ( Th4, wait = 1, ps = "polygonal4.ps" ); 72 : // 73 : // A circle with a circular hole. 74 : // 75 : border outside ( t = 0.0, 1.0 ) { x = 0.0 + 4.0 * cos ( 2.0 * pi * t ); y = 0.0 + 4.0 * sin ( 2.0 * pi * t ); } 76 : border inside ( t = 0.0, 1.0 ) { x = 2.0 + 1.0 * cos ( 2.0 * pi * t ); y = 1.0 + 2.0 * sin ( 2.0 * pi * t ); } *** Warning The identifier inside hide a Global identifier 77 : mesh Th5 = buildmesh ( outside ( 32 ) + inside ( -32 ) ); 78 : plot ( Th5, wait = 1, ps = "polygonal5.ps" ); 79 : sizestack + 1024 =2456 ( 1432 ) -- mesh: Nb of Triangles = 42, Nb of Vertices 31 -- mesh: Nb of Triangles = 226, Nb of Vertices 134 -- mesh: Nb of Triangles = 582, Nb of Vertices 324 -- mesh: Nb of Triangles = 536, Nb of Vertices 309 -- mesh: Nb of Triangles = 312, Nb of Vertices 188 times: compile 0.00507s, execution 0.013747s, mpirank:0 CodeAlloc : nb ptr 4125, size :502064 mpirank: 0 Ok: Normal End