src/test/stokes.h

    Third-order Stokes wave

    These functions return the shape of a third-order Stokes wave with the wavenumber and steepness given by the parameters ak and k_.

    double wave (double x, double y)
    {
      double a_ = ak/k_;
      double eta1 = a_*cos(k_*x);
      double alpa = 1./tanh(k_*h_);
      double eta2 = 1./4.*alpa*(3.*sq(alpa) - 1.)*sq(a_)*k_*cos(2.*k_*x);
      double eta3 = -3./8.*(cube(alpa)*alpa - 
    			3.*sq(alpa) + 3.)*cube(a_)*sq(k_)*cos(k_*x) + 
        3./64.*(8.*cube(alpa)*cube(alpa) + 
    	    (sq(alpa) - 1.)*(sq(alpa) - 1.))*cube(a_)*sq(k_)*cos(3.*k_*x);
      return eta1 + ak*eta2 + sq(ak)*eta3 - y;
    }
    
    double u_x (double x, double y)
    {
      double alpa = 1./tanh(k_*h_);
      double a_ = ak/k_;
      double sgma = sqrt(g_*k_*tanh(k_*h_)*
    		     (1. + k_*k_*a_*a_*(9./8.*(sq(alpa) - 1.)*
    					(sq(alpa) - 1.) + sq(alpa))));
      double A_ = a_*g_/sgma;
      return A_*cosh(k_*(y + h_))/cosh(k_*h_)*k_*cos(k_*x) +
        ak*3.*ak*A_/(8.*alpa)*(sq(alpa) - 1.)*(sq(alpa) - 1.)*
        cosh(2.0*k_*(y + h_))*2.*k_*cos(2.0*k_*x)/cosh(2.0*k_*h_) +
        ak*ak*1./64.*(sq(alpa) - 1.)*(sq(alpa) + 3.)*
        (9.*sq(alpa) - 13.)*
        cosh(3.*k_*(y + h_))/cosh(3.*k_*h_)*a_*a_*k_*k_*A_*3.*k_*cos(3.*k_*x);
    }
    
    double u_y (double x, double y)
    {
      double alpa = 1./tanh(k_*h_);
      double a_ = ak/k_;
      double sgma = sqrt(g_*k_*tanh(k_*h_)*
    		     (1. + k_*k_*a_*a_*(9./8.*(sq(alpa) - 1.)*
    					(sq(alpa) - 1.) + sq(alpa))));
      double A_ = a_*g_/sgma;
      return A_*k_*sinh(k_*(y + h_))/cosh(k_*h_)*sin(k_*x) +
        ak*3.*ak*A_/(8.*alpa)*(sq(alpa) - 1.)*(sq(alpa) - 1.)*
        2.*k_*sinh(2.0*k_*(y + h_))*sin(2.0*k_*x)/cosh(2.0*k_*h_) +
        ak*ak*1./64.*(sq(alpa) - 1.)*(sq(alpa) + 3.)*
        (9.*sq(alpa) - 13.)*
        3.*k_*sinh(3.*k_*(y + h_))/cosh(3.*k_*h_)*a_*a_*k_*k_*A_*sin(3.*k_*x);
    }