-- FreeFem++ v4.6 (Thu Apr 2 15:47:38 CEST 2020 - git v4.6) Load: lg_fem lg_mesh lg_mesh3 eigenvalue 1 : // cloud.edp 2 : // 3 : // Discussion: 4 : // 5 : // The file "cloud_points.txt" lists points that define the boundary. 6 : // 7 : // Create the corresponding region and mesh it. 8 : // 9 : // Licensing: 10 : // 11 : // This code is distributed under the GNU LGPL license. 12 : // 13 : // Modified: 14 : // 15 : // 02 August 2015 16 : // 17 : // Author: 18 : // 19 : // John Burkardt 20 : // 21 : // Reference: 22 : // 23 : // Alessandra Agostini, Chiara Piazzola, 24 : // Mesh Generation with FreeFem++ and Triangle, 25 : // Master's degree presentation, 26 : // University of Verona, 2014. 27 : // 28 : cout << "\n"; 29 : cout << "CLOUD:\n"; 30 : cout << " FreeFem++ version.\n"; 31 : cout << " Read a file of point coordinates that outline a ... : region.\n"; 32 : cout << " Create the region and mesh it.\n"; 33 : // 34 : // Attach the file as input. 35 : // 36 : string filename = "cloud_points.txt"; 37 : 38 : ifstream file ( filename ); 39 : cout << "\n"; 40 : cout << "Reading data from '" << filename << "'\n"; 41 : // 42 : // Read the number of points. 43 : // 44 : int nn = 0; 45 : file >> nn; 46 : cout << " Number of nodes = "<< nn << endl; 47 : // 48 : // Read the X and Y coordinates. 49 : // 50 : real[int] Gxx(nn); 51 : real[int] Gyy(nn); 52 : for ( int i = 0; i < nn; i++ ) 53 : { 54 : file >> Gxx[i] >> Gyy[i]; 55 : } 56 : // 57 : // List the nodes. 58 : // 59 : cout << "\n"; 60 : cout << " Boundary nodes:\n"; 61 : cout << "\n"; 62 : for ( int i = 0; i < nn; i++ ) 63 : { 64 : cout << " " << i 65 : << " " << Gxx[i] 66 : << " " << Gyy[i] << endl; 67 : } 68 : // 69 : // Create the corresponding border. 70 : // All points get label 1. 71 : // 72 : border Gsup ( t = 0, nn - 1 ) 73 : { 74 : int i = min ( int ( t ), Gxx.n - 2 ); 75 : real t1 = t - i; 76 : x = Gxx[i] * ( 1.0 - ( t - i ) ) + Gxx[i+1] * ( t - i ); 77 : y = Gyy[i] * ( 1.0 - ( t - i ) ) + Gyy[i+1] * ( t - i ); 78 : label = 1; 79 : } 80 : plot ( Gsup ( nn * 1 ), wait = 1, ps = "cloud_border.ps" ); 81 : // 82 : // Create the mesh. 83 : // 84 : mesh Th = buildmesh ( Gsup ( nn * 1 ) ); 85 : plot ( Th, wait = 1, ps = "cloud_mesh.ps" ); 86 : // 87 : // Solve a problem on this mesh. 88 : // 89 : // Define the finite element space. 90 : // 91 : fespace Vh ( Th, P1 ); 92 : // 93 : // Define test and trial functions. 94 : // 95 : Vh u; 96 : Vh v; 97 : // 98 : // Define and solve the problem. 99 : // 100 : solve Problem1 ( u, v ) = 101 : int2d ( Th )( dx(u) * dx(v) + dy(u) * dy(v) ) 102 : + int2d ( Th ) ( -v ) 103 : + on ( 1, u = 0.0 ); 104 : 105 : plot ( u, wait = 1, ps = "cloud_uh.ps" ); 106 : // 107 : // Terminate. 108 : // 109 : cout << "\n"; 110 : cout << "CLOUD:\n"; 111 : cout << " Normal end of execution.\n"; 112 : 113 : sizestack + 1024 =2008 ( 984 ) CLOUD: FreeFem++ version. Read a file of point coordinates that outline a region. Create the region and mesh it. Reading data from 'cloud_points.txt' Number of nodes = 43 Boundary nodes: 0 255 9 1 280 17 2 294 57 3 291 97 4 278 137 5 248 173 6 275 197 7 281 237 8 264 277 9 244 295 10 274 329 11 286 369 12 286 409 13 261 446 14 221 447 15 220 485 16 221 525 17 207 565 18 167 585 19 127 581 20 99 547 21 99 507 22 110 469 23 70 482 24 30 461 25 15 421 26 12 381 27 19 341 28 43 301 29 76 283 30 36 257 31 11 217 32 17 177 33 55 155 34 79 155 35 69 115 36 78 75 37 114 43 38 154 53 39 173 93 40 187 74 41 215 34 42 255 9 -- mesh: Nb of Triangles = 207, Nb of Vertices 126 -- Solve : min 2.16675e-28 max 5323.03 CLOUD: Normal end of execution. times: compile 0.004439s, execution 0.007062s, mpirank:0 CodeAlloc : nb ptr 3683, size :477736 mpirank: 0 Ok: Normal End