Tatooine
modified_doublegyre.h
Go to the documentation of this file.
1#ifndef TATOOINE_ANALYTICAL_NUMERICAL_MODIFIED_DOUBLEGYRE_H
2#define TATOOINE_ANALYTICAL_NUMERICAL_MODIFIED_DOUBLEGYRE_H
3//==============================================================================
6#include <tatooine/field.h>
7#include <tatooine/line.h>
8#include <tatooine/linspace.h>
10
11#include <algorithm>
12//==============================================================================
14//==============================================================================
15template <typename Real>
16struct modified_doublegyre : vectorfield<modified_doublegyre<Real>, Real, 2> {
19 using typename parent_type::pos_type;
20 using typename parent_type::tensor_type;
21 //============================================================================
22 static constexpr Real pi = M_PI;
23 static constexpr Real epsilon = 0.25;
24 static constexpr Real omega = 2 * pi * 0.1;
25 static constexpr Real A = 0.1;
26 static constexpr Real c = -0.2040811331;
27 static constexpr Real cc = c * c;
28 static constexpr Real d = 9.964223388;
29 //============================================================================
30 constexpr auto evaluate(pos_type const& x, Real const t) const
31 -> tensor_type {
32 Real const a = epsilon * gcem::sin(omega * (t + timeoffset(t)));
33 Real const b = 1 - 2 * a;
34 Real const f = a * x(0) * x(0) + b * x(0);
35 Real const df = 2 * a * x(0) + b;
36
37 return tensor_type{-pi * A * gcem::sin(pi * f) * gcem::cos(pi * x(1)),
38 pi * A * gcem::cos(pi * f) * gcem::sin(pi * x(1)) * df};
39 }
40 //----------------------------------------------------------------------------
41 constexpr static auto timeoffset(Real const t) {
42 Real const r = pi / 5 * t + d;
43
44 auto const q =
45 std::clamp<Real>((4 * pi * c * sin(r) - 4 * gcem::asin(2 * c * cos(r))) /
46 (pi * (1 - cc * sin(r) * sin(r))),
47 -1, 1);
48
49 Real const p = 5 / pi * gcem::asin(q) - t;
50 return p;
51 }
52 //----------------------------------------------------------------------------
54 auto at(Real const t) const {
55 return vec<Real, 2>{c * gcem::sin(pi / 5 * t + d) + 1, 0};
56 }
57 auto operator()(Real const t) const { return at(t); }
58 };
59 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
60 constexpr auto hyperbolic_trajectory() const {
62 }
63 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
64 constexpr auto hyperbolic_trajectory(Real t) const {
66 }
67 //----------------------------------------------------------------------------
69 auto at(Real const t) const {
70 return vec<Real, 3>{c * gcem::sin(pi / 5 * t + d) + 1, 0, t};
71 }
72 auto operator()(Real const t) const { return at(t); }
73 };
74 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
75 constexpr auto hyperbolic_trajectory_spacetime() const {
77 }
78 //============================================================================
79 template <template <typename, std::size_t> typename ODESolver>
81 Real m_t0;
82 Real m_eps;
83 this_type const& m_v;
85 //--------------------------------------------------------------------------
87 Real const eps)
88 : m_t0{t0}, m_eps{eps}, m_v{v}, m_flowmap{flowmap(v)} {}
89 //--------------------------------------------------------------------------
90 auto at(Real const t) const {
91 return m_flowmap(m_v.hyperbolic_trajectory(t) + Vec2<Real>{0, m_eps}, t,
92 m_t0 - t);
93 //return m_flowmap(m_v.hyperbolic_trajectory(t) + Vec2<Real>{0, 1-m_eps}, t-m_t0,
94 // t);
95 }
96 auto operator()(Real const t) const { return at(t); }
97 };
98 //----------------------------------------------------------------------------
99 template <template <typename, std::size_t>
100 typename ODESolver = ode::boost::rungekuttafehlberg78>
102 Real const eps = 1e-10) const {
104 }
105};
106//==============================================================================
107modified_doublegyre()->modified_doublegyre<real_number>;
108//==============================================================================
109} // namespace tatooine::analytical::numerical
110//==============================================================================
111#endif
Definition: abcflow.h:7
constexpr auto flowmap(vectorfield< autonomous_particles_test< Real >, Real, 2 > const &v, tag::numerical_t)
Definition: autonomous_particles_test.h:75
constexpr auto cos(arithmetic auto const x)
Definition: math.h:28
constexpr auto sin(arithmetic auto const x)
Definition: math.h:27
auto operator()(Real const t) const
Definition: modified_doublegyre.h:72
auto at(Real const t) const
Definition: modified_doublegyre.h:69
auto at(Real const t) const
Definition: modified_doublegyre.h:54
auto operator()(Real const t) const
Definition: modified_doublegyre.h:57
auto operator()(Real const t) const
Definition: modified_doublegyre.h:96
numerical_flowmap< this_type const &, ODESolver > m_flowmap
Definition: modified_doublegyre.h:84
auto at(Real const t) const
Definition: modified_doublegyre.h:90
lagrangian_coherent_structure_type(this_type const &v, Real const t0, Real const eps)
Definition: modified_doublegyre.h:86
Definition: modified_doublegyre.h:16
static constexpr Real A
Definition: modified_doublegyre.h:25
constexpr auto hyperbolic_trajectory(Real t) const
Definition: modified_doublegyre.h:64
static constexpr auto timeoffset(Real const t)
Definition: modified_doublegyre.h:41
constexpr auto hyperbolic_trajectory_spacetime() const
Definition: modified_doublegyre.h:75
constexpr auto hyperbolic_trajectory() const
Definition: modified_doublegyre.h:60
static constexpr Real cc
Definition: modified_doublegyre.h:27
static constexpr Real c
Definition: modified_doublegyre.h:26
auto lagrangian_coherent_structure(Real const t, Real const eps=1e-10) const
Definition: modified_doublegyre.h:101
static constexpr Real omega
Definition: modified_doublegyre.h:24
static constexpr Real d
Definition: modified_doublegyre.h:28
static constexpr Real epsilon
Definition: modified_doublegyre.h:23
static constexpr Real pi
Definition: modified_doublegyre.h:22
constexpr auto evaluate(pos_type const &x, Real const t) const -> tensor_type
Definition: modified_doublegyre.h:30
Definition: field.h:134
vec< real_type, NumDimensions > pos_type
Definition: field.h:20
Tensor tensor_type
Definition: field.h:18
Definition: numerical_flowmap.h:17
Definition: rungekuttafehlberg78.h:28
Definition: vec.h:12