-- FreeFem++ v4.14 (mer. 06 mars 2024 16:59:04 CET - git v4.14-1-g2b2052ae) file : gnuplot_surface.edp 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 : // Licensing: 8 : // 9 : // This code is distributed under the MIT license. 10 : // 11 : // Modified: 12 : // 13 : // 20 August 2015 14 : // 15 : // Author: 16 : // 17 : // John Burkardt 18 : // 19 : cout << "\n"; 20 : cout << "gnuplot_surface():\n"; 21 : cout << " FreeFem++ version:\n"; 22 : cout << " After solving a problem on a 2D region, write t ... : he data U(X,Y)\n"; 23 : cout << " to files that GNUPLOT can use to create a surfa ... : ce plot.\n"; 24 : // 25 : // Define the region. 26 : // 27 : border domega ( t = 0.0, 2.0 * pi ) { x = cos(t); y = sin(t); } 28 : 29 : mesh Th = buildmesh ( domega ( 100 ) ); 30 : 31 : plot ( Th, wait = true, ps = "gnuplot_surface_mesh.ps" ); 32 : // 33 : // Define the finite element space. 34 : // 35 : fespace Vh ( Th, P1 ); 36 : Vh uh; 37 : Vh vh; 38 : 39 : func f = 1.0; 40 : real epsilon = 1.0E-02; 41 : 42 : solve poisson ( uh, vh, solver = LU ) = 43 : int2d ( Th ) ( dx ( uh ) * dx ( vh ) + dy ( uh ) * dy ( vh ) ) 44 : + int1d ( Th, domega ) ( epsilon * uh * vh ) 45 : - int2d ( Th ) ( f * vh ); 46 : // 47 : // Make a contour plot of UH. 48 : // 49 : plot ( uh, nbiso = 50, fill = false, value = 1.0, wait = true, 50 : ps = "gnuplot_surface_uh.ps" ); 51 : // 52 : // Write a data file for gnuplot. 53 : // 54 : { 55 : ofstream data ( "gnuplot_surface_data.txt" ); 56 : 57 : for ( int i = 0; i < Th.nt; i++ ) 58 : { 59 : for ( int j = 0; j <= 3; j++ ) 60 : { 61 : int j2 = ( j % 3 ); 62 : data << " " << Th[i][j2].x 63 : << " " << Th[i][j2].y 64 : << " " << uh[][Vh(i,j2)] << "\n"; 65 : } 66 : data << "\n"; 67 : data << "\n"; 68 : } 69 : cout << "\n"; 70 : cout << "Wrote gnuplot data file.\n"; 71 : } 72 : // 73 : // Write a command file for gnuplot. 74 : // 75 : { 76 : ofstream commands ( "gnuplot_surface_commands.txt" ); 77 : 78 : commands << "# gnuplot_surface_commands.txt\n"; 79 : commands << "#\n"; 80 : commands << "# Usage:\n"; 81 : commands << "# gnuplot gnuplot_surface_commands.txt\n"; 82 : commands << "#\n"; 83 : commands << "set term png\n"; 84 : commands << "set output 'gnuplot_surface.png'\n"; 85 : commands << "set xlabel '<--- X --->'\n"; 86 : commands << "set ylabel '<--- Y --->'\n"; 87 : commands << "set zlabel '<--- Uh(X,Y) -->'\n"; 88 : commands << "set title 'Surface plot created from FreeFem++ da ... : ta.'\n"; 89 : commands << "unset key\n"; 90 : commands << "set timestamp\n"; 91 : commands << "splot 'gnuplot_surface_data.txt' with lines\n"; 92 : commands << "quit\n"; 93 : 94 : cout << "Wrote gnuplot command file.\n"; 95 : } 96 : // 97 : // Terminate. 98 : // 99 : cout << "\n"; 100 : cout << "gnuplot_surface():\n"; 101 : cout << " Normal end of execution.\n"; 102 : 103 : exit ( 0 ); 104 : 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. current line = 103 exit(0) err code 0 , mpirank 0 CodeAlloc : nb ptr 4059, size :526392 mpirank: 0 Ok: Normal End