// Discussion: // // -uxx - uyy -u/(alpha+r)^4 = f on the unit square. // u = g on the boundary. // // r = sqrt ( x^2 + y^2 ) // f = -gxx - gyy - g/(alpha+r)^4 // g = sin(1/(alpha+r)) // // The parameter alpha affects the number of oscillations in the solution. // // Suggested parameter values: // * alpha = 1/(10*pi) is relatively easy. // * alpha = 1/(50*pi) is harder. // // Location: // // http://people.sc.fsu.edu/~jburkardt/examples/mitchell_freefem++/test08a.edp // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 20 December 2014 // // Author: // // John Burkardt // // Reference: // // Frederic Hecht, // Freefem++, // Third Edition, version 3.22 // // William Mitchell, // A collection of 2D elliptic problems for testing adaptive // grid refinement algorithms, // Applied Mathematics and Computation, // Volume 220, 1 September 2013, pages 350-364. // border bottom ( t = 0.0, 1.0 ) { x = t; y = 0.0; label = 1; } border right ( t = 0.0, 1.0 ) { x = 1.0; y = t; label = 1; } border top ( t = 1.0, 0.0 ) { x = t; y = 1.0; label = 1; } border left ( t = 1.0, 0.0 ) { x = 0.0; y = t; label = 1; } // // Define Th, the triangulation of the "left" side of the boundaries. // int n = 10; mesh Th = buildmesh ( bottom ( n ) + right ( n ) + top ( n ) + left ( n ) ); // // Define Vh, the finite element space defined over Th, using P1 basis functions. // fespace Vh ( Th, P1 ); // // Define U, V, and F, piecewise continuous functions over Th. // Vh u; Vh v; // // Define problem parameters. // real alpha = 1.0 / 10.0 / pi; // // Define the right hand side function F. // func f = ( ( - alpha * alpha + x * x + y * y ) * cos ( 1.0 / ( alpha + sqrt ( x * x + y * y ) ) ) - ( x * x + y * y ) * sin ( 1.0 / ( alpha + sqrt ( x * x + y * y ) ) ) ) / sqrt ( x * x + y * y ) / pow ( alpha + sqrt ( x * x + y * y ), 4 ); // // Define the boundary function G. // func g = sin ( 1.0 / alpha + sqrt ( x * x + y * y ) ); // // Solve the variational problem. // solve Laplace ( u, v ) = int2d ( Th ) ( dx(u)*dx(v) + dy(u)*dy(v) ) - int2d ( Th ) ( u * v / pow ( alpha + sqrt ( x * x + y * y ), 4 ) ) - int2d ( Th ) ( f * v ) + on ( 1, u = g ); // // Plot the solution. // plot ( u, wait = 1, fill = true, ps = "test08a_u.eps" ); // // Plot the mesh. // plot ( Th, wait = 1, ps = "test08a_mesh.eps" ); // // Save the mesh file. // savemesh ( Th, "test08a.msh" );