-- FreeFem++ v 3.320001 (date Ven 7 nov 2014 14:28:55 CET) Load: lg_fem lg_mesh lg_mesh3 eigenvalue 1 : // Discussion: 2 : // 3 : // - uxx - uyy = f on the unit square. 4 : // u = g on the boundary. 5 : // 6 : // f = - gxx - gyy 7 : // g = atan ( alpha * (sqrt((x-xc)^2+(y-yc)^2)-r0) ) 8 : // 9 : // Suggested parameter values: 10 : // * alpha = 20, xc = -0.05, yc = -0.05, r0 = 0.7 11 : // * alpha = 1000, xc = -0.05, yc = -0.05, r0 = 0.7 12 : // * alpha = 1000, xc = 1.5, yc = 0.25, r0 = 0.92 13 : // * alpha = 50, xc = 0.5, yc = 0.5, r0 = 0.25 14 : // 15 : // Location: 16 : // 17 : // http://people.sc.fsu.edu/~jburkardt/examples/mitchell_freefem++/test09d.edp 18 : // 19 : // Licensing: 20 : // 21 : // This code is distributed under the GNU LGPL license. 22 : // 23 : // Modified: 24 : // 25 : // 22 December 2014 26 : // 27 : // Author: 28 : // 29 : // John Burkardt 30 : // 31 : // Reference: 32 : // 33 : // Frederic Hecht, 34 : // Freefem++, 35 : // Third Edition, version 3.22 36 : // 37 : // William Mitchell, 38 : // A collection of 2D elliptic problems for testing adaptive 39 : // grid refinement algorithms, 40 : // Applied Mathematics and Computation, 41 : // Volume 220, 1 September 2013, pages 350-364. 42 : // 43 : border bottom ( t = 0.0, 1.0 ) { x = t; y = 0.0; label = 1; } 44 : border right ( t = 0.0, 1.0 ) { x = 1.0; y = t; label = 1; } 45 : border top ( t = 1.0, 0.0 ) { x = t; y = 1.0; label = 1; } 46 : border left ( t = 1.0, 0.0 ) { x = 0.0; y = t; label = 1; } 47 : // 48 : // Define Th, the triangulation of the "left" side of the boundaries. 49 : // 50 : int n = 10; 51 : mesh Th = buildmesh ( bottom ( n ) + right ( n ) + top ( n ) + left ( n ) ); 52 : // 53 : // Define Vh, the finite element space defined over Th, using P1 basis functions. 54 : // 55 : fespace Vh ( Th, P1 ); 56 : // 57 : // Define U, V, and F, piecewise continuous functions over Th. 58 : // 59 : Vh u; 60 : Vh v; 61 : // 62 : // Define problem parameters. 63 : // 64 : real alpha = 50.0; 65 : real xc = 0.5; 66 : real yc = 0.5; 67 : real r0 = 0.25; 68 : // 69 : // Define the right hand side function F. 70 : // 71 : func f = 72 : ( 73 : - alpha + pow ( alpha, 3 ) 74 : * ( - r0 * r0 + pow ( x - xc, 2 ) + pow ( y - yc, 2 ) ) 75 : ) 76 : / 77 : ( 78 : sqrt ( pow ( x - xc, 2 ) + pow ( y - yc, 2 ) ) 79 : * pow ( 80 : -1.0 + alpha * alpha * 81 : ( 82 : - r0 * r0 - pow ( x - xc, 2 ) - pow ( y - yc, 2 ) 83 : + sqrt ( pow ( x - xc, 2 ) + pow ( y - yc, 2 ) ) 84 : ) 85 : , 2 ) 86 : ); 87 : // 88 : // Define the boundary function G. 89 : // 90 : func g = atan ( alpha * ( sqrt ( pow ( x - xc, 2 ) + pow ( y - yc, 2 ) ) - r0 ) ); 91 : // 92 : // Solve the variational problem. 93 : // 94 : solve Laplace ( u, v ) 95 : = int2d ( Th ) ( dx(u)*dx(v) + dy(u)*dy(v) ) 96 : - int2d ( Th ) ( f * v ) 97 : + on ( 1, u = g ); 98 : // 99 : // Plot the solution. 100 : // 101 : plot ( u, wait = 1, fill = true, ps = "test09d_u.eps" ); 102 : // 103 : // Plot the mesh. 104 : // 105 : plot ( Th, wait = 1, ps = "test09d_mesh.eps" ); 106 : // 107 : // Save the mesh file. 108 : // 109 : savemesh ( Th, "test09d.msh" ); 110 : 111 : sizestack + 1024 =5360 ( 4336 ) -- mesh: Nb of Triangles = 240, Nb of Vertices 141 -- Solve : min -56.3334 max 1.52707 number of required edges : 0 times: compile 0s, execution 0.01s, mpirank:0 CodeAlloc : nb ptr 2759, size :345264 mpirank: 0 Ok: Normal End