Tatooine
center.h
Go to the documentation of this file.
1#ifndef TATOOINE_ANALYTICAL_NUMERICAL_CENTER_FIELD_H
2#define TATOOINE_ANALYTICAL_NUMERICAL_CENTER_FIELD_H
3//==============================================================================
4#include <tatooine/field.h>
6//==============================================================================
8//==============================================================================
9template <floating_point Real>
10struct center : vectorfield<center<Real>, Real, 2> {
13 using typename parent_type::pos_type;
14 using typename parent_type::tensor_type;
15 //============================================================================
16 constexpr center() noexcept {}
17 constexpr center(center const&) = default;
18 constexpr center(center&&) noexcept = default;
19 constexpr auto operator=(center const&) -> center& = default;
20 constexpr auto operator=(center&&) noexcept -> center& = default;
21 //----------------------------------------------------------------------------
22 ~center() override = default;
23 //----------------------------------------------------------------------------
24 [[nodiscard]] constexpr auto evaluate(pos_type const& x,
25 Real const /*t*/) const -> tensor_type {
26 return {x(1), -x(0)};
27 }
28};
29//============================================================================
30center()->center<double>;
31//============================================================================
32template <floating_point Real>
34 using real_type = Real;
36 using pos_type = vec_t;
37 static constexpr auto num_dimensions() -> std::size_t { return 2; }
38 //============================================================================
39 constexpr auto evaluate(pos_type const& x, Real const /*t*/,
40 Real const tau) const -> pos_type {
41 return {gcem::cos(tau) * x(0) + gcem::sin(tau) * x(1),
42 -gcem::sin(tau) * x(0) + gcem::cos(tau) * x(1)};
43 }
44 //----------------------------------------------------------------------------
45 constexpr auto operator()(pos_type const& x, Real const t,
46 Real const tau) const -> pos_type {
47 return evaluate(x, t, tau);
48 }
49};
50//------------------------------------------------------------------------------
51template <template <typename, size_t>
52 typename ODESolver = ode::boost::rungekuttafehlberg78,
53 template <typename>
54 typename InterpolationKernel = interpolation::cubic,
55 floating_point Real>
56constexpr auto flowmap(
58 tag::numerical_t /*tag*/) {
60 InterpolationKernel>{v};
61}
62// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
63template <floating_point Real>
64constexpr auto flowmap(
66 tag::analytical_t /*tag*/) {
68}
69// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
70template <floating_point Real>
71constexpr auto flowmap(
73 return flowmap(v, tag::analytical);
74}
75//==============================================================================
76} // namespace tatooine::analytical::numerical
77//==============================================================================
79//==============================================================================
80namespace tatooine {
81//==============================================================================
82template <floating_point Real>
83struct differentiated_field<analytical::numerical::center<Real>>
84 : matrixfield<analytical::numerical::center<Real>, Real, 2> {
87 using typename parent_type::pos_type;
88 using typename parent_type::tensor_type;
89
90 //============================================================================
91 private:
93
94 //============================================================================
95 public:
98 //----------------------------------------------------------------------------
99 constexpr auto evaluate(pos_type const& /*x*/, Real const /*t*/) const
100 -> tensor_type {
101 return {{0, 1}, {-1, 0}};
102 }
103 //----------------------------------------------------------------------------
104 constexpr auto internal_field() -> auto& { return m_internal_field; }
105 constexpr auto internal_field() const -> auto const& {
106 return m_internal_field;
107 }
108};
109//==============================================================================
110template <floating_point Real>
113}
114// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
115template <floating_point Real>
116constexpr auto diff(
119}
120//==============================================================================
121template <floating_point Real>
122struct differentiated_flowmap<analytical::numerical::center<Real>> {
123 using real_type = Real;
128 static constexpr auto num_dimensions() -> std::size_t { return 2; }
129 //----------------------------------------------------------------------------
130 constexpr auto evaluate(pos_type const& /*x*/, Real const /*t*/,
131 Real const tau) const -> gradient_t {
132 auto const ctau = gcem::cos(tau);
133 auto const stau = gcem::sin(tau);
134 return {{ctau, stau}, {-stau, ctau}};
135 }
136 //----------------------------------------------------------------------------
137 constexpr auto operator()(pos_type const& x, Real const t,
138 Real const tau) const {
139 return evaluate(x, t, tau);
140 }
141};
142//==============================================================================
143} // namespace tatooine
144//==============================================================================
145#endif
Definition: concepts.h:30
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
static constexpr analytical_t analytical
Definition: tags.h:91
Definition: algorithm.h:6
constexpr auto diff(polynomial< Real, Degree > const &f)
Definition: polynomial.h:179
static constexpr auto num_dimensions() -> std::size_t
Definition: center.h:37
vec< Real, 2 > vec_t
Definition: center.h:35
constexpr auto evaluate(pos_type const &x, Real const, Real const tau) const -> pos_type
Definition: center.h:39
constexpr auto operator()(pos_type const &x, Real const t, Real const tau) const -> pos_type
Definition: center.h:45
center< Real > this_type
Definition: center.h:11
constexpr auto evaluate(pos_type const &x, Real const) const -> tensor_type
Definition: center.h:24
constexpr center(center const &)=default
constexpr center(center &&) noexcept=default
constexpr center() noexcept
Definition: center.h:16
vec_type pos_type
Definition: axis_aligned_bounding_box.h:109
constexpr auto internal_field() -> auto &
Definition: center.h:104
constexpr auto internal_field() const -> auto const &
Definition: center.h:105
constexpr auto evaluate(pos_type const &, Real const) const -> tensor_type
Definition: center.h:99
differentiated_field(analytical::numerical::center< Real > const &f)
Definition: center.h:96
analytical::numerical::center< Real > m_internal_field
Definition: center.h:92
Definition: differentiated_field.h:173
constexpr auto operator()(pos_type const &x, Real const t, Real const tau) const
Definition: center.h:137
constexpr auto evaluate(pos_type const &, Real const, Real const tau) const -> gradient_t
Definition: center.h:130
static constexpr auto num_dimensions() -> std::size_t
Definition: center.h:128
Definition: differentiated_flowmap.h:141
Definition: field.h:134
vec< real_type, NumDimensions > pos_type
Definition: field.h:20
Tensor tensor_type
Definition: field.h:18
Definition: interpolation.h:216
interpolation_tensor_type< tensor< Real, Dims... > > tensor_type
Definition: interpolation.h:135
Definition: mat.h:14
Definition: numerical_flowmap.h:17
InternalField m_internal_field
Definition: differentiated_field.h:38
auto evaluate(pos_type const &y0, real_type const t0, real_type const tau) const
Definition: differentiated_flowmap.h:43
Definition: rungekuttafehlberg78.h:28
Definition: tags.h:90
Definition: tags.h:92
Definition: vec.h:12