// Discussion: // // This FreeFem++ script generates meshes using polygonal borders. // // Location: // // http://people.sc.fsu.edu/~jburkardt/freefem++/polygonal_mesh/polygonal_mesh.edp // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 18 February 2015 // // Author: // // John Burkardt // // // Mesh a square on [0,1]x[0,1] into 4 by 5 elements by specifying the sides. // border bottom ( t = 0.0, 1.0 ) { x = t; y = 0.0; } border right ( t = 0.0, 1.0 ) { x = 1.0; y = t; } border top ( t = 1.0, 0.0 ) { x = t; y = 1.0; } border left ( t = 1.0, 0.0 ) { x = 0.0; y = t; } mesh Th1 = buildmesh ( bottom ( 4 ) + right ( 5 ) + top ( 4 ) + left ( 5 ) ); plot ( Th1, wait = true, ps = "polygonal1.ps" ); // // Make a square on [0,1]x[0,1], forcing an interior diagonal line. // border bottom2 ( t = 0.0, 1.0 ) { x = t; y = 0.0; } border right2 ( t = 0.0, 1.0 ) { x = 1.0; y = t; } border top2 ( t = 1.0, 0.0 ) { x = t; y = 1.0; } border left2 ( t = 1.0, 0.0 ) { x = 0.0; y = t; } border diag ( t = 0.0, 1.0 ) { x = t; y = t; } mesh Th2 = buildmesh ( bottom2 ( 10 ) + right2 ( 10 ) + top2 ( 10 ) + left2 ( 10 ) + diag ( 14 ) ); plot ( Th2, wait = true, ps = "polygonal2.ps" ); // // Make a square on [0,4]x[0,4] with a CCW pentagonal hole. // border bottom3 ( t = 0.0, 1.0 ) { x = 4.0 * t; y = 0.0; } border right3 ( t = 0.0, 1.0 ) { x = 4.0; y = 4.0 * t; } border top3 ( t = 1.0, 0.0 ) { x = 4.0 * t; y = 4.0; } border left3 ( t = 1.0, 0.0 ) { x = 0.0; y = 4.0 * t; } border p1 ( t = 1.0, 2.0 ) { x = t; y = 1.0; } border p2 ( t = 1.0, 2.0 ) { x = 2.0; y = t;} border p3 ( t = 0.0, 0.5 ) { x = 2.0 - t; y = 2.0 + t; } border p4 ( t = 0.5, 0.0 ) { x = 1.0 + t; y = 2.0 + t; } border p5 ( t = 2.0, 1.0 ) { x = 1.0; y = t; } mesh Th3 = buildmesh ( bottom3 ( 16 ) + right3 ( 16 ) + top3 ( 16 ) + left3 ( 16 ) + p1 ( 4 ) + p2 ( 4 ) + p3 ( 3 ) + p4 ( 3 ) + p5 ( 4 ) ); plot ( Th3, wait = true, ps = "polygonal3.ps" ); // // Make a square on [0,4]x[0,4] with a CW pentagonal hole. // border bottom4 ( t = 0.0, 1.0 ) { x = 4.0 * t; y = 0.0; } border right4 ( t = 0.0, 1.0 ) { x = 4.0; y = 4.0 * t; } border top4 ( t = 1.0, 0.0 ) { x = 4.0 * t; y = 4.0; } border left4 ( t = 1.0, 0.0 ) { x = 0.0; y = 4.0 * t; } border q1 ( t = 2.0, 1.0 ) { x = t; y = 1.0; } border q2 ( t = 2.0, 1.0 ) { x = 2.0; y = t;} border q3 ( t = 0.5, 0.0 ) { x = 2.0 - t; y = 2.0 + t; } border q4 ( t = 0.0, 0.5 ) { x = 1.0 + t; y = 2.0 + t; } border q5 ( t = 1.0, 2.0 ) { x = 1.0; y = t; } mesh Th4 = buildmesh ( bottom4 ( 16 ) + right4 ( 16 ) + top4 ( 16 ) + left4 ( 16 ) + q1 ( 4 ) + q2 ( 4 ) + q3 ( 3 ) + q4 ( 3 ) + q5 ( 4 ) ); plot ( Th4, wait = true, ps = "polygonal4.ps" ); // // A circle with a circular hole. // 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 ); } 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 ); } mesh Th5 = buildmesh ( outside ( 32 ) + inside ( -32 ) ); plot ( Th5, wait = true, ps = "polygonal5.ps" ); // // Terminate. // cout << "\n"; cout << "polygonal_mesh:\n"; cout << " Normal end of execution.\n"; exit ( 0 );