-- FreeFem++ v4.14 (mer. 06 mars 2024 16:59:04 CET - git v4.14-1-g2b2052ae) file : polygonal_mesh.edp Load: lg_fem lg_mesh lg_mesh3 eigenvalue 1 : // polygonal_mesh.edp 2 : // 3 : // Discussion: 4 : // 5 : // This FreeFem++ script generates meshes using polygonal borders. 6 : // 7 : // Licensing: 8 : // 9 : // This code is distributed under the MIT license. 10 : // 11 : // Modified: 12 : // 13 : // 18 February 2015 14 : // 15 : // Author: 16 : // 17 : // John Burkardt 18 : // 19 : cout << "\n"; 20 : cout << "polygonal_mesh():\n"; 21 : cout << " FreeFem++ version\n"; 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 = true, 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 = true, 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 = true, 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 = true, 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 = true, ps = "polygonal5.ps" ); 79 : // 80 : // Terminate. 81 : // 82 : cout << "\n"; 83 : cout << "polygonal_mesh:\n"; 84 : cout << " Normal end of execution.\n"; 85 : 86 : exit ( 0 ); 87 : sizestack + 1024 =2456 ( 1432 ) polygonal_mesh(): FreeFem++ version -- 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 polygonal_mesh: Normal end of execution. current line = 86 exit(0) err code 0 , mpirank 0 CodeAlloc : nb ptr 4505, size :550288 mpirank: 0 Ok: Normal End