-- FreeFem++ v4.6 (Thu Apr 2 15:47:38 CEST 2020 - git v4.6) Load: lg_fem lg_mesh lg_mesh3 eigenvalue 1 : // mesh_points.edp 2 : // 3 : // Discussion: 4 : // 5 : // The file "mesh_points_input.txt" lists points that define the boundary. 6 : // 7 : // Create the corresponding region and mesh it. 8 : // 9 : // Location: 10 : // 11 : // http://people.sc.fsu.edu/~jburkardt/freefem_src/mesh_points/mesh_points.edp 12 : // 13 : // Modified: 14 : // 15 : // 01 August 2015 16 : // 17 : cout << "\n"; 18 : cout << "MESH_POINTS:\n"; 19 : cout << " FreeFem++ version.\n"; 20 : cout << " Read a file of point coordinates that outline a ... : region.\n"; 21 : cout << " Create the region and mesh it.\n"; 22 : // 23 : // Attach the file as input. 24 : // 25 : string filename = "mesh_points_input.txt"; 26 : 27 : ifstream file ( filename ); 28 : cout << "\n"; 29 : cout << "Reading data from '" << filename << "'\n"; 30 : // 31 : // Read the number of points. 32 : // 33 : int nn = 0; 34 : file >> nn; 35 : cout << " Number of nodes = "<< nn << endl; 36 : // 37 : // Read the X and Y coordinates. 38 : // 39 : real[int] Gxx(nn); 40 : real[int] Gyy(nn); 41 : for ( int i = 0; i < nn; i++ ) 42 : { 43 : file >> Gxx[i] >> Gyy[i]; 44 : } 45 : // 46 : // List the nodes. 47 : // 48 : cout << "\n"; 49 : cout << " Boundary nodes:\n"; 50 : cout << "\n"; 51 : for ( int i = 0; i < nn; i++ ) 52 : { 53 : cout << " " << i 54 : << " " << Gxx[i] 55 : << " " << Gyy[i] << endl; 56 : } 57 : // 58 : // Create the corresponding border. 59 : // 60 : border Gsup ( t = 0, nn - 1 ) 61 : { 62 : int i = min ( int ( t ), Gxx.n - 2 ); 63 : real t1 = t - i; 64 : x = Gxx[i] * ( 1.0 - ( t - i ) ) + Gxx[i+1] * ( t - i ); 65 : y = Gyy[i] * ( 1.0 - ( t - i ) ) + Gyy[i+1] * ( t - i ); 66 : label = i + 1; 67 : } 68 : plot ( Gsup ( nn * 20 ), wait = 1, ps = "mesh_points_border.ps", 69 : cmm = "mesh_points boundary" ); 70 : // 71 : // Create the mesh. 72 : // 73 : mesh Th = buildmesh ( Gsup ( nn * 20 ) ); 74 : plot ( Th, wait = 1, ps = "mesh_points_mesh.ps", cmm = "mesh_points mesh" ); 75 : // 76 : // Solve a problem on this mesh. 77 : // 78 : // Define the finite element space. 79 : // 80 : fespace Vh ( Th, P1 ); 81 : // 82 : // Define test and trial functions. 83 : // 84 : Vh u; 85 : Vh v; 86 : // 87 : // Define and solve the problem. 88 : // 89 : solve Problem1 ( u, v ) = 90 : int2d ( Th )( dx(u) * dx(v) + dy(u) * dy(v) ) 91 : + int2d ( Th ) ( -v ) 92 : + on ( 1, u = 0 ) 93 : + on ( 2, u = 1 ) 94 : + on ( 3, u = 0 ) 95 : + on ( 4, u = 0 ); 96 : 97 : plot ( u, wait = 1, fill = 1, ps = "mesh_points_uh.ps", cmm = "mesh points solution" ); 98 : // 99 : // Terminate. 100 : // 101 : cout << "\n"; 102 : cout << "mesh_points:\n"; 103 : cout << " Normal end of execution.\n"; 104 : 105 : sizestack + 1024 =2008 ( 984 ) MESH_POINTS: FreeFem++ version. Read a file of point coordinates that outline a region. Create the region and mesh it. Reading data from 'mesh_points_input.txt' Number of nodes = 7 Boundary nodes: 0 0 0 1 1 0 2 1 0.5 3 0.5 0.5 4 0.5 1 5 0 1 6 0 0 -- mesh: Nb of Triangles = 1972, Nb of Vertices 1057 -- Solve : min 7.63821e-33 max 1 mesh_points: Normal end of execution. times: compile 0.005083s, execution 0.712747s, mpirank:0 CodeAlloc : nb ptr 3712, size :478760 mpirank: 0 Ok: Normal End