-- FreeFem++ v4.6 (Thu Apr 2 15:47:38 CEST 2020 - git v4.6) Load: lg_fem lg_mesh lg_mesh3 eigenvalue 1 : // gnuplot_surface.edp 2 : // 3 : // Discussion: 4 : // 5 : // Write data to a file for processing by gnuplot. 6 : // 7 : // Location: 8 : // 9 : // http://people.sc.fsu.edu/~jburkardt/freefem++/gnuplot_surface/gnuplot_surface.edp 10 : // 11 : // Licensing: 12 : // 13 : // This code is distributed under the GNU LGPL license. 14 : // 15 : // Modified: 16 : // 17 : // 20 August 2015 18 : // 19 : // Author: 20 : // 21 : // John Burkardt 22 : // 23 : cout << "\n"; 24 : cout << "GNUPLOT_SURFACE:\n"; 25 : cout << " FreeFem++ version:\n"; 26 : cout << " After solving a problem on a 2D region, write t ... : he data U(X,Y)\n"; 27 : cout << " to files that GNUPLOT can use to create a surfa ... : ce plot.\n"; 28 : // 29 : // Define the region. 30 : // 31 : border domega ( t = 0.0, 2.0 * pi ) { x = cos(t); y = sin(t); } 32 : 33 : mesh Th = buildmesh ( domega ( 100 ) ); 34 : 35 : plot ( Th, wait = 1, ps = "gnuplot_surface_mesh.ps" ); 36 : // 37 : // Define the finite element space. 38 : // 39 : fespace Vh ( Th, P1 ); 40 : Vh uh; 41 : Vh vh; 42 : 43 : func f = 1.0; 44 : real epsilon = 1.0E-02; 45 : 46 : solve poisson ( uh, vh, solver = LU ) = 47 : int2d ( Th ) ( dx ( uh ) * dx ( vh ) + dy ( uh ) * dy ( vh ) ) 48 : + int1d ( Th, domega ) ( epsilon * uh * vh ) 49 : - int2d ( Th ) ( f * vh ); 50 : // 51 : // Make a contour plot of UH. 52 : // 53 : plot ( uh, nbiso = 50, fill = 0, value = 1.0, wait = 1, 54 : ps = "gnuplot_surface_uh.ps" ); 55 : // 56 : // Write a data file for gnuplot. 57 : // 58 : { 59 : ofstream data ( "gnuplot_surface_data.txt" ); 60 : 61 : for ( int i = 0; i < Th.nt; i++ ) 62 : { 63 : for ( int j = 0; j <= 3; j++ ) 64 : { 65 : int j2 = ( j % 3 ); 66 : data << " " << Th[i][j2].x 67 : << " " << Th[i][j2].y 68 : << " " << uh[][Vh(i,j2)] << "\n"; 69 : } 70 : data << "\n"; 71 : data << "\n"; 72 : } 73 : cout << "\n"; 74 : cout << "Wrote gnuplot data file.\n"; 75 : } 76 : // 77 : // Write a command file for gnuplot. 78 : // 79 : { 80 : ofstream commands ( "gnuplot_surface_commands.txt" ); 81 : 82 : commands << "# gnuplot_surface_commands.txt\n"; 83 : commands << "#\n"; 84 : commands << "# Usage:\n"; 85 : commands << "# gnuplot gnuplot_surface_commands.txt\n"; 86 : commands << "#\n"; 87 : commands << "set term png\n"; 88 : commands << "set output 'gnuplot_surface.png'\n"; 89 : commands << "set xlabel '<--- X --->'\n"; 90 : commands << "set ylabel '<--- Y --->'\n"; 91 : commands << "set zlabel '<--- Uh(X,Y) -->'\n"; 92 : commands << "set title 'Surface plot created from FreeFem++ da ... : ta.'\n"; 93 : commands << "unset key\n"; 94 : commands << "set timestamp\n"; 95 : commands << "splot 'gnuplot_surface_data.txt' with lines\n"; 96 : commands << "quit\n"; 97 : 98 : cout << "Wrote gnuplot command file.\n"; 99 : } 100 : // 101 : // Terminate. 102 : // 103 : cout << "\n"; 104 : cout << "GNUPLOT_SURFACE:\n"; 105 : cout << " Normal end of execution.\n"; 106 : 107 : sizestack + 1024 =2408 ( 1384 ) GNUPLOT_SURFACE: FreeFem++ version: After solving a problem on a 2D region, write the data U(X,Y) to files that GNUPLOT can use to create a surface plot. -- mesh: Nb of Triangles = 1750, Nb of Vertices 926 SkyLineMatrix: size pL/pU: 926 28862 28862 moy=31.1685 -- Solve : min 49.9751 max 50.2254 Wrote gnuplot data file. Wrote gnuplot command file. GNUPLOT_SURFACE: Normal end of execution. times: compile 0.005123s, execution 0.079785s, mpirank:0 CodeAlloc : nb ptr 3693, size :478368 mpirank: 0 Ok: Normal End