-- FreeFem++ v4.6 (Thu Apr 2 15:47:38 CEST 2020 - git v4.6) Load: lg_fem lg_mesh lg_mesh3 eigenvalue 1 : // Discussion: 2 : // 3 : // Let an ellipse have semimajor axis 2 and semiminor axis 1: 4 : // (x/2)^2 + (y/1)^2 = 1. 5 : // Let Gamma1 be the ellipse boundary from 0 to 4pi/3, and 6 : // Gamm2 the boundary from 4pi/3 to 2pi. 7 : // 8 : // Solve: 9 : // -uxx - uyy = f in Gamma1 + Gamma2, 10 : // u = x on Gamma1. 11 : // du/dn = 0, natural boundary condition on Gamma2. 12 : // 13 : // Location: 14 : // 15 : // http://people.sc.fsu.edu/~jburkardt/freefem_src/membrane/membrane.edp 16 : // 17 : // Licensing: 18 : // 19 : // This code is distributed under the GNU LGPL license. 20 : // 21 : // Modified: 22 : // 23 : // 18 June 2015 24 : // 25 : // Reference: 26 : // 27 : // Frederic Hecht, 28 : // Freefem++, 29 : // Third Edition, version 3.22 30 : // 31 : cout << "\n"; 32 : cout << "membrane:\n"; 33 : cout << " Solve the Poisson equation on an ellipse.\n"; 34 : // 35 : // Define Gamma1 and Gamma2, the boundaries. 36 : // A and B are the lengths of the semimajor and semiminor axes: 37 : // THETA specifies the angle at which we switch from GAMMA1 to GAMMA2. 38 : // 39 : real a = 2.0; 40 : real b = 1.0; 41 : real theta = 4.0 * pi / 3.0; 42 : border Gamma1 ( t = 0, theta ) { x = a * cos(t); y = b*sin(t); } 43 : border Gamma2 ( t = theta, 2*pi ) { x = a * cos(t); y = b*sin(t); } 44 : // 45 : // Th: the triangulation of the "left" side of the boundaries. 46 : // 47 : mesh Th = buildmesh ( Gamma1(100) + Gamma2(50) ); 48 : // 49 : // Plot the mesh. 50 : // 51 : plot ( Th, wait = true, ps = "membrane_mesh.ps", cmm = "membrane mesh" ); 52 : // 53 : // Define Vh, the finite element space defined over Th, using P2 basis functions. 54 : // 55 : fespace Vh ( Th, P2 ); 56 : // 57 : // Define U, V, and F, piecewise P2 continuous functions over Th. 58 : // F is a constant function. 59 : // 60 : Vh u; 61 : Vh v; 62 : Vh f = 1.0; 63 : // 64 : // Define G, a function for the Dirichlet boundary conditions. 65 : // 66 : func g = x; 67 : // 68 : // Define the weak form of the PDE. 69 : // 70 : problem poisson ( u, v ) 71 : = int2d ( Th ) ( dx(u)*dx(v) + dy(u)*dy(v) ) 72 : - int2d ( Th ) ( f * v ) 73 : + on ( Gamma1, u = g ); 74 : // 75 : // Solve the PDE. 76 : // 77 : poisson; 78 : // 79 : // Plot the solution. 80 : // 81 : plot ( u, fill = true, wait = true, ps = "membrane_u.ps", cmm = "membrane solution" ); 82 : // 83 : // Save the mesh file. 84 : // 85 : savemesh ( Th, "membrane.msh" ); 86 : // 87 : // Terminate. 88 : // 89 : cout << "\n"; 90 : cout << "MEMBRANE:\n"; 91 : cout << " Normal end of execution.\n"; 92 : 93 : sizestack + 1024 =1896 ( 872 ) membrane: Solve the Poisson equation on an ellipse. -- mesh: Nb of Triangles = 2568, Nb of Vertices 1360 -- Solve : min -2 max 2 number of required edges : 0 MEMBRANE: Normal end of execution. times: compile 0.004188s, execution 1.06127s, mpirank:0 CodeAlloc : nb ptr 3576, size :475752 mpirank: 0 Ok: Normal End