Tatooine
cylinder_flow.h
Go to the documentation of this file.
1#ifndef TATOOINE_ANALYTICAL_NUMERICAL_CYLINDER_FLOW_H
2#define TATOOINE_ANALYTICAL_NUMERICAL_CYLINDER_FLOW_H
3//==============================================================================
4#include <tatooine/field.h>
5//==============================================================================
7//==============================================================================
8template <typename Real>
9struct cylinder_flow : vectorfield<cylinder_flow<Real>, Real, 2> {
12 //============================================================================
13 using typename parent_type::real_type;
14 using typename parent_type::pos_type;
15 using typename parent_type::tensor_type;
16 //============================================================================
23 //============================================================================
24 [[no_discard]] auto evaluate(pos_type const& p, real_type t) const -> tensor_type {
25 real_type const eps = 1e-7;
26 auto const& x = p(0);
27 auto const& y = p(1);
28 auto const xn = x - eps;
29 auto const xp = x + eps;
30 auto const yn = y - eps;
31 auto const yp = y + eps;
32
33 auto const b_xn = std::sqrt(xn * xn + y * y) - 1;
34 auto const b_xp = std::sqrt(xp * xp + y * y) - 1;
35 auto const b_yn = std::sqrt(x * x + yn * yn) - 1;
36 auto const b_yp = std::sqrt(x * x + yp * yp) - 1;
37
38 auto const f_xn = 1 - std::exp(-a * b_xn * b_xn);
39 auto const f_xp = 1 - std::exp(-a * b_xp * b_xp);
40 auto const f_yn = 1 - std::exp(-a * b_yn * b_yn);
41 auto const f_yp = 1 - std::exp(-a * b_yp * b_yp);
42
43 auto const h1 = std::abs(std::sin(M_PI * t / Tc));
44 auto const h2 = std::abs(std::sin(M_PI * (t - Tc / 2) / Tc));
45
46 auto const x1 = 1 + L * ((t / Tc) % 1);
47 auto const x2 = 1 + L * (((t - Tc / 2) / Tc) % 1);
48 auto const g1 = std::exp(
49 -R0((p - x1) * (p - x1) + alpha * alpha * (y - y0) * (y - y0)));
50 auto const g2 = std::exp(
51 -R0((p - x2) * (p - x2) + alpha * alpha * (y + y0) * (y + y0)));
52
53 auto const s_xn =
54 1 - std::exp(-(xn - 1) * (xn - 1) / (alpha * alpha - y * y));
55 auto const s_xp =
56 1 - std::exp(-(xp - 1) * (xp - 1) / (alpha * alpha - y * y));
57 auto const s_yn =
58 1 - std::exp(-(x - 1) * (x - 1) / (alpha * alpha - yn * yn));
59 auto const s_yp =
60 1 - std::exp(-(x - 1) * (x - 1) / (alpha * alpha - yp * yp));
61
62 auto const g_xn = -w * h1 * g1 + w * h2 * h2 * g2 + u0 * y * s_xn;
63 auto const g_xp = -w * h1 * g1 + w * h2 * h2 * g2 + u0 * y * s_xp;
64 auto const g_yn = -w * h1 * g1 + w * h2 * h2 * g2 + u0 * yn * s_yn;
65 auto const g_yp = -w * h1 * g1 + w * h2 * h2 * g2 + u0 * yp * s_yp;
66 auto const psi_xn = f_xn * g_xn;
67 auto const psi_xp = f_xp * g_xp;
68 auto const psi_yn = f_yn * g_yn;
69 auto const psi_yp = f_yp * g_yp;
70
71 return tensor_type{ (psi_yp - psi_yn) / (2 * eps),
72 -(psi_xp - psi_xn) / (2 * eps)};
73 }
74 //----------------------------------------------------------------------------
75 [[no_discard]] auto in_domain(pos_type const& x, real_type t) const -> bool {
76 if (sqr_length(x) <= 1) { return false; }
77 return true;
78 }
79};
80//==============================================================================
81} // namespace tatooine::numerical
82//==============================================================================
83#endif
Definition: cylinder_flow.h:6
Definition: field.h:134
Real real_type
Definition: field.h:17
vec< real_type, NumDimensions > pos_type
Definition: field.h:20
Tensor tensor_type
Definition: field.h:18
Definition: cylinder_flow.h:9
real_type a
Definition: cylinder_flow.h:17
auto in_domain(pos_type const &x, real_type t) const -> bool
Definition: cylinder_flow.h:75
real_type R0
Definition: cylinder_flow.h:20
real_type L
Definition: cylinder_flow.h:19
auto evaluate(pos_type const &p, real_type t) const -> tensor_type
Definition: cylinder_flow.h:24
real_type alpha
Definition: cylinder_flow.h:22
real_type y0
Definition: cylinder_flow.h:21
real_type Tc
Definition: cylinder_flow.h:18
Definition: vec.h:12