// cloud.edp // // Discussion: // // The file "cloud_points.txt" lists points that define the boundary. // // Create the corresponding region and mesh it. // // Modified: // // 02 August 2015 // cout << "\n"; cout << "CLOUD:\n"; cout << " FreeFem++ version.\n"; cout << " Read a file of point coordinates that outline a region.\n"; cout << " Create the region and mesh it.\n"; // // Attach the file as input. // string filename = "cloud_points.txt"; ifstream file ( filename ); cout << "\n"; cout << "Reading data from '" << filename << "'\n"; // // Read the number of points. // int nn = 0; file >> nn; cout << " Number of nodes = "<< nn << endl; // // Read the X and Y coordinates. // real[int] Gxx(nn); real[int] Gyy(nn); for ( int i = 0; i < nn; i++ ) { file >> Gxx[i] >> Gyy[i]; } // // List the nodes. // cout << "\n"; cout << " Boundary nodes:\n"; cout << "\n"; for ( int i = 0; i < nn; i++ ) { cout << " " << i << " " << Gxx[i] << " " << Gyy[i] << endl; } // // Create the corresponding border. // All points get label 1. // border Gsup ( t = 0, nn - 1 ) { int i = min ( int ( t ), Gxx.n - 2 ); real t1 = t - i; x = Gxx[i] * ( 1.0 - ( t - i ) ) + Gxx[i+1] * ( t - i ); y = Gyy[i] * ( 1.0 - ( t - i ) ) + Gyy[i+1] * ( t - i ); label = 1; } plot ( Gsup ( nn * 1 ), wait = 1, ps = "cloud_border.ps" ); // // Create the mesh. // mesh Th = buildmesh ( Gsup ( nn * 1 ) ); plot ( Th, wait = 1, ps = "cloud_mesh.ps" ); // // Solve a problem on this mesh. // // Define the finite element space. // fespace Vh ( Th, P1 ); // // Define test and trial functions. // Vh u; Vh v; // // Define and solve the problem. // solve Problem1 ( u, v ) = int2d ( Th )( dx(u) * dx(v) + dy(u) * dy(v) ) + int2d ( Th ) ( -v ) + on ( 1, u = 0.0 ); plot ( u, wait = 1, ps = "cloud_uh.ps" ); // // Terminate. // cout << "\n"; cout << "CLOUD:\n"; cout << " Normal end of execution.\n";