Tatooine
frankes_test.h
Go to the documentation of this file.
1#ifndef TATOOINE_ANALYTICAL_NUMERICAL_FRANKES_TEST_H
2#define TATOOINE_ANALYTICAL_NUMERICAL_FRANKES_TEST_H
3//==============================================================================
4#include <tatooine/field.h>
5
6#include <cmath>
7//==============================================================================
9//==============================================================================
12template <floating_point Real>
13struct frankes_test : scalarfield<frankes_test<Real>, Real, 2> {
16 using typename parent_type::pos_type;
17 using typename parent_type::real_type;
18 using typename parent_type::tensor_type;
19 //============================================================================
20 explicit constexpr frankes_test() noexcept = default;
21 //------------------------------------------------------------------------------
22 constexpr frankes_test(frankes_test const&) = default;
23 constexpr frankes_test(frankes_test&&) noexcept = default;
24 //------------------------------------------------------------------------------
25 auto constexpr operator=(frankes_test const&) -> frankes_test& = default;
26 auto constexpr operator=(frankes_test&&) noexcept -> frankes_test& = default;
27 //------------------------------------------------------------------------------
28 ~frankes_test() override = default;
29 //----------------------------------------------------------------------------
30 [[nodiscard]] auto constexpr evaluate(fixed_size_vec<2> auto const& q,
31 Real const t) const -> tensor_type {
32 auto const a = 9 * q(0) - 2;
33 auto const b = 9 * q(1) - 2;
34 auto const c = 9 * q(0) + 1;
35 auto const d = 9 * q(1) + 1;
36 auto const e = 9 * q(0) - 7;
37 auto const f = 9 * q(1) - 3;
38 auto const g = 9 * q(0) - 4;
39 auto const h = 9 * q(1) - 7;
40 auto const term1 = 0.75 * std::exp(-a * a / 4 - b * b / 4);
41 auto const term2 = 0.75 * std::exp(-c * c / 49 - d / 10);
42 auto const term3 = 0.5 * std::exp(-e * e / 4 - f * f / 4);
43 auto const term4 = -0.2 * std::exp(-g * g - h * h);
44
45 return term1 + term2 + term3 + term4;
46 }
47};
48//==============================================================================
49frankes_test()->frankes_test<real_number>;
50//==============================================================================
51} // namespace tatooine::analytical::numerical
52//==============================================================================
54//==============================================================================
55namespace tatooine {
56//==============================================================================
57template <floating_point Real>
58struct differentiated_field<analytical::numerical::frankes_test<Real>>
59 : vectorfield<differentiated_field<
60 analytical::numerical::frankes_test<Real>>,
61 Real, 2> {
66 Real, 2>;
67 using typename parent_type::pos_type;
68 using typename parent_type::real_type;
69 using typename parent_type::tensor_type;
70 //============================================================================
71 explicit constexpr differentiated_field() noexcept = default;
72 //------------------------------------------------------------------------------
73 constexpr differentiated_field(differentiated_field const&) = default;
74 constexpr differentiated_field(differentiated_field&&) noexcept = default;
75 //------------------------------------------------------------------------------
76 auto constexpr operator =(differentiated_field const&)
77 -> differentiated_field& = default;
78 auto constexpr operator =(differentiated_field&&) noexcept
79 -> differentiated_field& = default;
80 //------------------------------------------------------------------------------
81 ~differentiated_field() override = default;
82 //----------------------------------------------------------------------------
83 [[nodiscard]] auto constexpr evaluate(fixed_size_vec<2> auto const& q,
84 Real const t) const -> tensor_type {
85 auto constexpr exp51 = gcem::exp(Real(51));
86 auto constexpr exp63 = gcem::exp(Real(63));
87 auto constexpr exp65 = gcem::exp(Real(65));
88 auto x = q.x();
89 auto y = q.y();
90 auto xx = x * x;
91 auto yy = y * y;
92 auto a = gcem::exp(-(Real(405) * yy) / Real(4) - (Real(9) * y) / Real(10) -
93 (Real(20169) * xx) / Real(196) -
94 (Real(18) * x) / Real(49) - Real(66));
95 auto constexpr b = gcem::exp(Real(431) / Real(490));
96 auto constexpr c = gcem::exp(Real(59) / Real(490));
97 auto d = gcem::exp((Real(4050) * xx) / Real(49) +
98 (Real(459) * x) / Real(49) + Real(63));
99 auto e =
100 gcem::exp((Real(4293) * xx) / Real(196) + (Real(3546) * x) / Real(49));
101 auto f = gcem::exp((Real(4050) * xx) / Real(49) +
102 (Real(3123) * x) / Real(98) + Real(51));
103
104 return {
105 -(a *
106 (b * ((Real(4860) * exp65 * x + Real(540) * exp65) *
107 gcem::exp((Real(405) * yy) / Real(4) +
108 (Real(405) * xx) / Real(4)) +
109 c * ((Real(59535) * exp63 * x - Real(13230) * exp63) *
110 gcem::exp(Real(81) * yy + (Real(99) * y) / Real(10) +
111 (Real(4050) * xx) / Real(49) +
112 (Real(459) * x) / Real(49)) +
113 (Real(28224) - Real(63504) * x) *
114 gcem::exp((Real(81) * yy) / Real(4) +
115 (Real(1269) * y) / Real(10) +
116 (Real(4293) * xx) / Real(196) +
117 (Real(3546) * x) / Real(49)))) +
118 (Real(39690) * exp51 * x - Real(30870) * exp51) *
119 gcem::exp(Real(81) * yy + (Real(72) * y) / Real(5) +
120 (Real(4050) * xx) / Real(49) +
121 (Real(3123) * x) / Real(98) + Real(1) / Real(2)))) /
122 Real(1960),
123 -(a *
124 (b * (Real(27) * gcem::exp((Real(405) * yy) / Real(4) +
125 (Real(405) * xx) / Real(4) + Real(65)) +
126 c * ((Real(1215) * d * y - Real(270) * d) *
127 gcem::exp(Real(81) * yy + (Real(99) * y) / Real(10)) +
128 (Real(1008) * e - Real(1296) * e * y) *
129 gcem::exp((Real(81) * yy) / Real(4) +
130 (Real(1269) * y) / Real(10)))) +
131 (Real(810) * f * y - Real(270) * f) *
132 gcem::exp(Real(81) * yy + (Real(72) * y) / Real(5) +
133 Real(1) / Real(2)))) /
134 Real(40)};
135 }
136};
137//------------------------------------------------------------------------------
138template <floating_point Real>
142}
143//==============================================================================
144} // namespace tatooine
145//==============================================================================
146#endif
Definition: tensor_concepts.h:33
Definition: abcflow.h:7
Definition: algorithm.h:6
constexpr auto diff(polynomial< Real, Degree > const &f)
Definition: polynomial.h:179
Franke's Test Function. See Here
Definition: frankes_test.h:13
constexpr frankes_test() noexcept=default
auto constexpr evaluate(fixed_size_vec< 2 > auto const &q, Real const t) const -> tensor_type
Definition: frankes_test.h:30
vec_type pos_type
Definition: axis_aligned_bounding_box.h:109
Definition: differentiated_field.h:173
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
Real real_type
Definition: interpolation.h:25
interpolation_tensor_type< tensor< Real, Dims... > > tensor_type
Definition: interpolation.h:135
constexpr auto evaluate(pos_type const &x, real_type const t) const -> tensor_type
Definition: differentiated_field.h:61