Tatooine
doublegyre.h
Go to the documentation of this file.
1#ifndef TATOOINE_ANALYTICAL_NUMERICAL_DOUBLEGYRE_H
2#define TATOOINE_ANALYTICAL_NUMERICAL_DOUBLEGYRE_H
3//==============================================================================
4#include <tatooine/field.h>
5#include <numbers>
6#include <cmath>
7//==============================================================================
9//==============================================================================
11template <typename Real>
12struct doublegyre : vectorfield<doublegyre<Real>, Real, 2> {
15 using typename parent_type::pos_type;
16 using typename parent_type::real_type;
17 using typename parent_type::tensor_type;
18 //============================================================================
19 static constexpr auto pi = std::numbers::template pi_v<Real>;
20 //============================================================================
22 bool m_infinite_domain = false;
23 //============================================================================
24 explicit constexpr doublegyre(Real const epsilon = 0.25,
25 Real const omega = 2 * pi * 0.1,
26 Real const A = 0.1) noexcept
28 //------------------------------------------------------------------------------
29 constexpr doublegyre(doublegyre const&) = default;
30 constexpr doublegyre(doublegyre&&) noexcept = default;
31 //------------------------------------------------------------------------------
32 constexpr auto operator=(doublegyre const&) -> doublegyre& = default;
33 constexpr auto operator=(doublegyre&&) noexcept -> doublegyre& = default;
34 //------------------------------------------------------------------------------
35 ~doublegyre() override = default;
36 //----------------------------------------------------------------------------
37 [[nodiscard]] constexpr auto evaluate(
38 fixed_size_vec<2> auto const& x, Real const t) const
39 -> tensor_type {
40 if (!m_infinite_domain && (x(0) < 0 || x(0) > 2 || x(1) < 0 || x(1) > 1)) {
42 }
43 Real const a = m_epsilon * gcem::sin(m_omega * t);
44 Real const b = 1 - 2 * a;
45 Real const f = a * x(0) * x(0) + b * x(0);
46 Real const df = 2 * a * x(0) + b;
47
48 return {-pi * m_A * gcem::sin(pi * f) * gcem::cos(pi * x(1)),
49 pi * m_A * gcem::cos(pi * f) * gcem::sin(pi * x(1)) * df};
50 }
51 //----------------------------------------------------------------------------
52 constexpr auto set_infinite_domain(bool const v = true) {
54 }
55 //----------------------------------------------------------------------------
56 constexpr auto epsilon() const { return m_epsilon; }
57 constexpr auto epsilon() -> auto& { return m_epsilon; }
58 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
59 constexpr auto set_epsilon(Real const epsilon) { m_epsilon = epsilon; }
60 //----------------------------------------------------------------------------
61 constexpr auto omega() const { return m_omega; }
62 constexpr auto omega() -> auto& { return m_omega; }
63 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
64 constexpr auto set_omega(Real const omega) { m_omega = omega; }
65 //----------------------------------------------------------------------------
66 constexpr auto A() const { return m_A; }
67 constexpr auto A() -> auto& { return m_A; }
68 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
69 constexpr auto set_A(Real const A) { m_A = A; }
70};
71//==============================================================================
72doublegyre()->doublegyre<real_number>;
73//==============================================================================
74} // namespace tatooine::analytical::numerical
75//==============================================================================
76#endif
Definition: tensor_concepts.h:33
Definition: abcflow.h:7
Double Gyre dataset.
Definition: doublegyre.h:12
constexpr auto set_omega(Real const omega)
Definition: doublegyre.h:64
constexpr auto set_A(Real const A)
Definition: doublegyre.h:69
constexpr auto omega() -> auto &
Definition: doublegyre.h:62
static constexpr auto pi
Definition: doublegyre.h:19
constexpr auto evaluate(fixed_size_vec< 2 > auto const &x, Real const t) const -> tensor_type
Definition: doublegyre.h:37
constexpr doublegyre(doublegyre &&) noexcept=default
bool m_infinite_domain
Definition: doublegyre.h:22
constexpr auto epsilon() const
Definition: doublegyre.h:56
constexpr auto set_epsilon(Real const epsilon)
Definition: doublegyre.h:59
constexpr auto set_infinite_domain(bool const v=true)
Definition: doublegyre.h:52
constexpr auto A() -> auto &
Definition: doublegyre.h:67
constexpr auto A() const
Definition: doublegyre.h:66
Real m_omega
Definition: doublegyre.h:21
Real m_epsilon
Definition: doublegyre.h:21
constexpr doublegyre(Real const epsilon=0.25, Real const omega=2 *pi *0.1, Real const A=0.1) noexcept
Definition: doublegyre.h:24
constexpr doublegyre(doublegyre const &)=default
constexpr auto omega() const
Definition: doublegyre.h:61
constexpr auto epsilon() -> auto &
Definition: doublegyre.h:57
Real m_A
Definition: doublegyre.h:21
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
static auto constexpr ood_tensor()
Definition: field.h:21