subroutine poisson_2d_exact ( n, x, y, u, ux, uy, uxx, uxy, uyy ) !*****************************************************************************80 ! !! poisson_2d_exact() evaluates an exact solution of the Poisson equation. ! ! Discussion: ! ! The equation is: ! - Uxx - Uyy = 0 ! ! The domain is the unit square: ! Omega = 0 <= x, y <= 1 ! ! The solution is: ! U(X,Y) = 2 * ( 1 + Y ) / ( ( 3 + X )^2 + ( 1 + Y )^2 ) ! ! The boundary conditions are determined by evaluating the exact ! solution U(X,Y). ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 05 June 2025 ! ! Author: ! ! John Burkardt ! ! Input: ! ! integer n: the number of points. ! ! real X, Y: the coordinates of the points. ! ! Output: ! ! real U, Ux, Uy, Uxx, Uxy, Uyy: the solution and first and second ! partial derivatives evaluated at the points (X,Y). ! implicit none integer, parameter :: rk8 = kind ( 1.0D+00 ) integer n real ( kind = rk8 ) u(n) real ( kind = rk8 ) ux(n) real ( kind = rk8 ) uy(n) real ( kind = rk8 ) uxx(n) real ( kind = rk8 ) uxy(n) real ( kind = rk8 ) uyy(n) real ( kind = rk8 ) x(n) real ( kind = rk8 ) y(n) u = 2.0 * ( 1.0 + y ) / ( ( 3.0 + x )**2 + ( 1.0 + y )**2 ) ux = ( - 2 * x - 6 ) * ( 2 * y + 2 ) / ( ( x + 3 )**2 + ( y + 1 )**2 )**2 uy = ( - 2 * y - 2 ) * ( 2 * y + 2 ) & / ( ( x + 3 )**2 + ( y + 1 )**2 )**2 + 2 / ( ( x + 3 )**2 + ( y + 1 )**2 ) uxx = 4 * ( y + 1 ) * ( 4 * ( x + 3 )**2 & / ( ( x + 3 )**2 + ( y + 1 )**2 ) - 1 ) & / ( ( x + 3 )**2 + ( y + 1 )**2 )**2 uxy = 4 * ( x + 3 )* ( 4 * ( y + 1 )**2 & / ( ( x + 3 )**2 + ( y + 1 )**2 ) - 1 ) & / ( ( x + 3 )**2 + ( y + 1 )**2 )**2 uyy = 4 * ( y + 1 ) * ( 4 * ( y + 1 ) **2 & / ( ( x + 3 )**2 + ( y + 1 )**2 ) - 3 ) & / ( ( x + 3 )**2 + ( y + 1 )**2 )**2 return end