-- FreeFem++ v4.6 (Thu Apr 2 15:47:38 CEST 2020 - git v4.6) Load: lg_fem lg_mesh lg_mesh3 eigenvalue 1 : // poisson_1d.edp 2 : // 3 : // Discussion: 4 : // 5 : // Solve the Poisson equation over a 1D interval. 6 : // 7 : // - uxx + u = x, 0 < x < 1 8 : // u(0) = u(1) = 0 9 : // 10 : // Exact solution is u(x) = x - sinh(x)/sinh(1) 11 : // 12 : // Location: 13 : // 14 : // http://people.sc.fsu.edu/~jburkardt/freefem_src/poisson_1d/poisson_1d.edp 15 : // 16 : // Licensing: 17 : // 18 : // This code is distributed under the GNU LGPL license. 19 : // 20 : // Modified: 21 : // 22 : // 25 July 2015 23 : // 24 : // Reference: 25 : // 26 : // Frederic Hecht, 27 : // Freefem++, 28 : // Third Edition, version 3.22 29 : // 30 : cout << "\n"; 31 : cout << "poisson_1d\n"; 32 : cout << " FreeFem++ version\n"; 33 : cout << " Trick FreeFem++ into solving a 1D Poisson probl ... : em.\n"; 34 : // 35 : // Define the 1D problem on a long rectangular strip. 36 : // Use 100 intervals in X, and 1 in Y. 37 : // The parameters X and Y run from 0 to 1. 38 : // The [ ] option allows us to rescale X or Y. 39 : // 40 : int n = 100; 41 : mesh Th = square ( n, 1, [ x, (-1+2*y) / 10 ] ); 42 : // 43 : // Plot the mesh. 44 : // 45 : plot ( Th, wait = 1, aspectratio = 1, ps = "poisson_1d_mesh.ps" ); 46 : // 47 : // Define Vh, the finite element space defined over Th, using P1 basis functions. 48 : // 49 : fespace Vh ( Th, P1 ); 50 : // 51 : // Define u and v, piecewise P1 continuous functions over Th. 52 : // 53 : Vh u, v; 54 : // 55 : // Define f, the right hand side function. 56 : // 57 : func f = x; 58 : // 59 : // Request a solution of the discrete weak system. 60 : // Note that the boundary condition is included, 61 : // defined on sides 2 and 4 of the square boundary. 62 : // 63 : solve Poisson ( u, v, solver = LU ) 64 : = int2d(Th) ( dx(u)*dx(v) + u*v ) 65 : - int2d(Th) ( f*v ) 66 : + on ( 2, 4, u = 0.0 ); 67 : // 68 : // Plot the solution. 69 : // 70 : plot ( u, wait = 1, dim = 3, fill = 1, ps = "poisson_1d_u.ps" ); 71 : // 72 : // Save the mesh file. 73 : // 74 : savemesh ( Th, "poisson_1d.msh" ); 75 : // 76 : // Terminate. 77 : // 78 : cout << "\n"; 79 : cout << "poisson_1d\n"; 80 : cout << " Normal end of execution.\n"; 81 : 82 : sizestack + 1024 =1744 ( 720 ) poisson_1d FreeFem++ version Trick FreeFem++ into solving a 1D Poisson problem. -- Square mesh : nb vertices =202 , nb triangles = 200 , nb boundary edges 202 SkyLineMatrix: size pL/pU: 202 10401 10401 moy=51.4901 -- Solve : min 1.48326e-32 max 0.0585228 number of required edges : 0 poisson_1d Normal end of execution. times: compile 0.004571s, execution 0.005494s, mpirank:0 CodeAlloc : nb ptr 3524, size :472912 mpirank: 0 Ok: Normal End