function [ u, dudx, dudy ] = exact_u ( node_num, node_xy, time ) %% EXACT_U calculates the exact solution. % % Discussion: % % It is assumed that the user knows the exact solution and its % derivatives. This, of course, is NOT true for a real computation. % But for this code, we are interested in studying the convergence % behavior of the approximations, and so we really need to assume % we know the correct solution. % % As a convenience, this single routine is used for several purposes: % % * it supplies the initial value function H(X,Y,T); % * it supplies the boundary value function G(X,Y,T); % * it is used by the COMPARE routine to make a node-wise comparison % of the exact and approximate solutions. % * it is used by the ERRORS routine to estimate the integrals of % the L2 and H1 errors of approximation. % % DUDX and DUDY are only needed for the ERRORS calculation. % % Licensing: % % This code is distributed under the GNU LGPL license. % % Modified: % % 09 April 2004 % % Author: % % John Burkardt % % Parameters: % % Input, integer NODE_NUM, the number of nodes at which % a value is desired. % % Input, real NODE_XY(2,NODE_NUM), the coordinates of % the points where a value is desired. % % Input, real TIME, the current time. % % Output, real U(NODE_NUM), the exact solution. % % Output, real DUDX(NODE_NUM), DUDY(NODE_NUM), % the X and Y derivatives of the exact solution. % u(1:node_num) = sin ( pi * node_xy(1,1:node_num)' ) ... .* sin ( pi * node_xy(2,1:node_num)' ) ... * exp ( -time ); dudx(1:node_num) = pi * cos ( pi * node_xy(1,1:node_num)' ) ... .* sin ( pi * node_xy(2,1:node_num)' ) ... * exp ( -time ); dudy(1:node_num) = pi * sin ( pi * node_xy(1,1:node_num)' ) ... .* cos ( pi * node_xy(2,1:node_num)' ) ... * exp ( -time ); return end