34 const amrex::Real tol,
38 const amrex::Real omega = 2.0_rt * std::numbers::pi_v<amrex::Real> / T;
39 const amrex::Real depsdk = H / 2.0_rt;
44 amrex::Real k = (omega * omega) / g;
46 amrex::Real f = tol + 1.0_rt;
47 while (std::abs(f) > tol && iter < iter_max) {
51 const amrex::Real S = 2.0_rt * std::exp(2.0_rt * k * d) /
52 (std::exp(4.0_rt * k * d) + 1.0_rt);
53 const amrex::Real C = 1.0_rt - S;
54 const amrex::Real eps = k * H / 2.0_rt;
55 const amrex::Real C0 = std::sqrt(std::tanh(k * d));
56 const amrex::Real C2 =
57 C0 * (2.0_rt + 7.0_rt * S * S) / (4.0_rt * C * C);
58 const amrex::Real numterm_C4 =
59 (4.0_rt + (32.0_rt * S) - (116.0_rt *
utils::powi(S, 2)) -
62 const amrex::Real C4 = C0 * numterm_C4 / (32.0_rt *
utils::powi(C, 5));
64 const amrex::Real dSdk = -2.0_rt * d * std::sinh(2.0_rt * k * d) /
66 const amrex::Real dCdk = -dSdk;
67 const amrex::Real dC0dk =
68 d / (2.0_rt * C0 *
utils::powi(std::cosh(k * d), 2));
70 const amrex::Real dC2dk =
73 C0 * 14.0_rt * S * dSdk) -
74 C0 * (2.0_rt + 7.0_rt *
utils::powi(S, 2)) * 8.0_rt * C * dCdk) /
76 const amrex::Real dC4dk =
79 C0 * (32.0_rt * dSdk - 232.0_rt * S * dSdk -
83 C0 * numterm_C4 * 160.0_rt *
utils::powi(C, 4) * dCdk) /
88 (g *
utils::powi(C0, 2)) + (g * k * 2.0_rt * C0 * dC0dk);
97 (2.0_rt * eps * depsdk * C2 +
109 2.0_rt *
utils::powi(eps, 4) * (C0 * dC4dk + C4 * dC0dk) +
111 2.0_rt *
utils::powi(eps, 6) * (C2 * dC4dk + C4 * dC2dk) +
142 if (iter == iter_max) {
146 return 2.0_rt * std::numbers::pi_v<amrex::Real> / k;
151 amrex::Real wavenumber,
152 amrex::Real water_depth,
173 amrex::Real kd = wavenumber * water_depth;
174 kd = amrex::min<amrex::Real>(kd, 50.0_rt * std::numbers::pi_v<amrex::Real>);
178 2.0_rt * std::exp(2.0_rt * kd) / (std::exp(4.0_rt * kd) + 1.0_rt);
179 amrex::Real C = 1.0_rt - S;
180 amrex::Real Sh = std::sinh(kd);
181 amrex::Real Th = std::tanh(kd);
184 (1.0_rt + std::exp(-2.0_rt * kd)) / (1.0_rt - std::exp(-2 * kd));
187 a11 = 1.0_rt / std::sinh(kd);
190 b22 = CTh * (1.0_rt + 2.0_rt * S) / (2.0_rt * C);
191 c2 = std::sqrt(Th) * (2.0_rt + 7.0_rt *
utils::powi(S, 2)) /
193 if (stokes_order == 2) {
198 a31 = (-4.0_rt - 20.0_rt * S + 10.0_rt *
utils::powi(S, 2) -
204 (1.0_rt + 3.0_rt * S + 3.0_rt *
utils::powi(S, 2) +
207 if (stokes_order == 3) {
218 (48.0_rt * (3.0_rt + 2.0_rt * S) *
utils::powi(C, 5));
220 (6.0_rt - 26.0_rt * S - 182.0_rt *
utils::powi(S, 2) -
223 (6.0_rt * (3.0_rt + 2.0_rt * S) *
utils::powi(C, 4));
225 (24.0_rt + 92.0_rt * S + 122.0_rt *
utils::powi(S, 2) +
228 (24.0_rt * (3.0_rt + 2.0_rt * S) *
utils::powi(C, 4));
230 (4.0_rt + 32.0_rt * S - 116.0_rt *
utils::powi(S, 2) -
234 if (stokes_order == 4) {
239 a51 = (-1184.0_rt + 32.0_rt * S + 13232.0_rt *
utils::powi(S, 2) +
243 (64.0_rt * Sh * (3.0_rt + 2.0_rt * S) * (4.0_rt + S) *
249 (32.0_rt * Sh * (3.0_rt + 2.0_rt * S) *
utils::powi(C, 6));
253 (64.0_rt * Sh * (3.0_rt + 2.0_rt * S) * (4.0_rt + S) *
256 (132.0_rt + 17.0_rt * S - 2216.0_rt *
utils::powi(S, 2) -
260 (128.0_rt * (3.0_rt + 2.0_rt * S) * (4.0_rt + S) *
utils::powi(C, 6));
262 (300.0_rt + 1579.0_rt * S + 3176.0_rt *
utils::powi(S, 2) +
266 (384.0_rt * (3.0_rt + 2.0_rt * S) * (4.0_rt + S) *
utils::powi(C, 6));
267 if (stokes_order == 5) {
271 if (stokes_order > 5 || stokes_order < 2) {
273 "invalid stokes order specified. It should be between 2,3,4 or 5 ");
280 amrex::Real wavelength,
281 amrex::Real water_depth,
282 amrex::Real wave_height,
288 amrex::Real phase_offset,
294 const amrex::Real wavenumber =
295 2.0_rt * std::numbers::pi_v<amrex::Real> / wavelength;
298 amrex::Real c0{0.0_rt};
299 amrex::Real a11{0.0_rt}, a22{0.0_rt}, b22{0.0_rt}, c2{0.0_rt};
300 amrex::Real a31{0.0_rt}, a33{0.0_rt}, b31{0.0_rt}, a42{0.0_rt}, a44{0.0_rt};
301 amrex::Real b42{0.0_rt}, b44{0.0_rt}, c4{0.0_rt};
302 amrex::Real a51{0.0_rt}, a53{0.0_rt}, a55{0.0_rt}, b53{0.0_rt}, b55{0.0_rt};
305 stokes_order, wavenumber, water_depth, c0, a11, a22, b22, c2, a31, a33,
306 b31, a42, a44, b42, b44, c4, a51, a53, a55, b53, b55);
308 const amrex::Real eps = wavenumber * wave_height / 2.0_rt;
309 const amrex::Real c =
311 std::sqrt(g / wavenumber);
313 const amrex::Real omega = c * wavenumber;
314 const amrex::Real phase = (wavenumber * x) - (omega * time) - phase_offset;
316 eta = ((eps * std::cos(phase)
318 std::cos(2.0_rt * phase)
320 (std::cos(phase) - std::cos(3.0_rt * phase)) +
321 utils::powi(eps, 4) * (b42 * std::cos(2.0_rt * phase) +
322 b44 * std::cos(4.0_rt * phase)) +
323 utils::powi(eps, 5) * (-(b53 + b55) * std::cos(phase) +
324 b53 * std::cos(3.0_rt * phase) +
325 b55 * std::cos(5.0_rt * phase))) /
333 const int MAX_ORDER = 5;
334 amrex::GpuArray<amrex::Real, MAX_ORDER> a;
335 if (stokes_order == 2) {
339 if (stokes_order == 3) {
340 a[0] = a11 + ((eps * eps) * a31);
344 if (stokes_order == 4) {
345 a[0] = a11 + ((eps * eps) * a31);
346 a[1] = a22 + ((eps * eps) * a42);
350 if (stokes_order == 5) {
351 a[0] = a11 + ((eps * eps) * a31) + (
utils::powi(eps, 4) * a51);
352 a[1] = a22 + ((eps * eps) * a42);
353 a[2] = a33 + ((eps * eps) * a53);
361 for (
int n = 1; n <= stokes_order; ++n) {
364 amrex::Real nkdz = n * wavenumber * (water_depth + (z - zsl));
365 nkdz = amrex::min<amrex::Real>(
366 nkdz, 50.0_rt * std::numbers::pi_v<amrex::Real>);
367 u_w +=
utils::powi(eps, n) *
static_cast<amrex::Real
>(n) * a[n - 1] *
368 std::cosh(nkdz) * std::cos(
static_cast<amrex::Real
>(n) * phase);
369 w_w +=
utils::powi(eps, n) *
static_cast<amrex::Real
>(n) * a[n - 1] *
370 std::sinh(nkdz) * std::sin(
static_cast<amrex::Real
>(n) * phase);
372 u_w *= (c0 * std::sqrt(g / wavenumber));
373 w_w *= (c0 * std::sqrt(g / wavenumber));
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void stokes_coefficients(int stokes_order, amrex::Real wavenumber, amrex::Real water_depth, amrex::Real &c0, amrex::Real &a11, amrex::Real &a22, amrex::Real &b22, amrex::Real &c2, amrex::Real &a31, amrex::Real &a33, amrex::Real &b31, amrex::Real &a42, amrex::Real &a44, amrex::Real &b42, amrex::Real &b44, amrex::Real &c4, amrex::Real &a51, amrex::Real &a53, amrex::Real &a55, amrex::Real &b53, amrex::Real &b55)
Definition stokes_waves_K.H:149
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void stokes_waves(int stokes_order, amrex::Real wavelength, amrex::Real water_depth, amrex::Real wave_height, amrex::Real zsl, amrex::Real g, amrex::Real x, amrex::Real z, amrex::Real time, amrex::Real phase_offset, amrex::Real &eta, amrex::Real &u_w, amrex::Real &v_w, amrex::Real &w_w)
Definition stokes_waves_K.H:278
AMREX_FORCE_INLINE amrex::Real stokes_wave_length(const amrex::Real T, const amrex::Real d, const amrex::Real H, const int order, const amrex::Real g, const amrex::Real tol, const int iter_max)
Definition stokes_waves_K.H:28