function [ ur, vr, wr, pr ] = resid_burgers ( nu, n, x, y, z, t )

%*****************************************************************************80
%
%% RESID_BURGERS: Burgers Navier Stokes residual.
%
%  Location:
%
%    http://people.sc.fsu.edu/~jburkardt/m_src/navier_stokes_3d_exact/resid_burgers.m
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    29 July 2015
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Martin Bazant, Henry Moffatt,
%    Exact solutions of the Navier-Stokes equations having steady vortex structures,
%    Journal of Fluid Mechanics,
%    Volume 541, pages 55-64, 2005.
%
%    Johannes Burgers,
%    A mathematical model illustrating the theory of turbulence,
%    Advances in Applied Mechanics,
%    Volume 1, pages 171-199, 1948.
%
%  Parameters:
%
%    Input, real NU, the viscosity.
%
%    Input, integer N, the number of points at which the solution is to
%    be evaluated.
%
%    Input, real X(N), Y(N), Z(N), the coordinates of the points.
%
%    Input, real T(N), the time coordinates.
%
%    Output, real UR(N), VR(N), WR(N), PR(N), the residuals.
%

%
%  Form the functions and derivatives.
%
  u =   2.0 * x;
  ux =  2.0;
  uxx = 0.0;
  uy =  0.0;
  uyy = 0.0;
  uz =  0.0;
  uzz = 0.0;
  ut =  0.0;

  v =   - 2.0 * y;
  vx =  0.0;
  vxx = 0.0;
  vy =  - 2.0;
  vyy = 0.0;
  vz =  0.0;
  vzz = 0.0;
  vt =  0.0;

  w =   erf ( y / sqrt ( nu ) );
  wx =  0.0;
  wxx = 0.0;
  wy =    2.0 * sqrt ( 1.0 / nu / pi )      * exp ( - y .^ 2 / nu );
  wyy = - 4.0 * sqrt ( 1.0 / nu / pi ) * y .* exp ( - y .^ 2 / nu ) / nu;
  wz =  0.0;
  wzz = 0.0;
  wt =  0.0;

  p = - 2.0 * ( x .^ 2 + y .^ 2 );
  px = - 4.0 * x;
  py = - 4.0 * y;
  pz = 0.0;
%
%  Evaluate the residuals.
%
  ur = ut + u .* ux + v .* uy + w .* uz + px - nu * ( uxx + uyy + uzz );
  vr = vt + u .* vx + v .* vy + w .* vz + py - nu * ( vxx + vyy + vzz );
  wr = wt + u .* wx + v .* wy + w .* wz + pz - nu * ( wxx + wyy + wzz );
  pr = ux + vy + wz;

  return
end

