Advertisement
codisinmyvines

a(x,t)

May 29th, 2021
1,452
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. amax = sin(t / 4.5 - x[0] / 2);
  2.     for (i = 1; i < Nx + 1; i++)
  3.     {  
  4.         a = sin(t / 4.5 - x[i] / 2);
  5.         if (abs(a) > amax)
  6.             amax = abs(a);
  7.     }
  8.     if (amax != 0)
  9.         Ht = Hx / amax;
  10.     else
  11.         Ht = Hx;
  12.     Uj1[0] = Mu(t);
  13.     for (i = 0; i < Nx + 1; i++)
  14.     {
  15.         a = sin(t / 4.5 - x[i] / 2);
  16.         aaa << a << "\n";
  17.         gm = a * Ht / Hx;
  18.         nn = 1;
  19.         if (i == 0)
  20.             nn = 0;
  21.         if (i == Nx + 1)
  22.             nn = 2;
  23.         switch (nn)
  24.         {
  25.         case 0:
  26.             if (gm < 0)
  27.                 Uj1[i] = (1 + gm) * Uj[i] - gm * Uj[i + 1];
  28.             break;
  29.         case 1:
  30.             if (gm >= 0)
  31.                 Uj1[i] = (1 - gm) * Uj[i] + gm * Uj[i - 1];
  32.             else
  33.                 Uj1[i] = (1 + gm) * Uj[i] - gm * Uj[i + 1];
  34.             break;
  35.         case 2:
  36.             if (gm > 0)
  37.                 Uj1[i] = (1 - gm) * Uj[i] + gm * Uj[i - 1];
  38.             else
  39.                 Uj1[i] = Uj[i];
  40.             break;
  41.         }
  42.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement