Tatooine
curvature_field.h
Go to the documentation of this file.
1#ifndef TATOOINE_CURVATURE_FIELD_H
2#define TATOOINE_CURVATURE_FIELD_H
3
4#include "field.h"
5#include "diff.h"
6
7//==============================================================================
8namespace tatooine {
9//==============================================================================
10
11template <typename V, size_t N>
13//==============================================================================
14template <typename V>
15class curvature_field<V, 2>
16 : public field<curvature_field<V>, typename V::real_type, 2> {
17 //============================================================================
18 // typedefs
19 //============================================================================
20 public:
22 using real_type = typename V::real_type;
24 using typename parent_type::tensor_type;
25 using typename parent_type::pos_type;
26
27 //============================================================================
28 // fields
29 //============================================================================
30 private:
32
33 //============================================================================
34 // ctor
35 //============================================================================
36 public:
37 template <typename Real>
38 curvature_field(const field<V, Real, 2, 2>& v) : m_vf{v.as_derived()} {}
39
40 //============================================================================
41 // methods
42 //============================================================================
43 public:
44 constexpr tensor_type evaluate(const pos_type& x, real_type t) const {
45 const auto Jf = diff(m_vf);
46 const auto J = Jf(x, t);
47 const auto v = m_vf(x, t);
48 const auto a = J * v;
49 const auto lv = length(v);
50 return (v(0) * a(1) - v(1) * a(0)) / (lv * lv * lv);
51 }
52 //----------------------------------------------------------------------------
53 constexpr bool in_domain(const pos_type& x, real_type t) const {
54 return m_vf.in_domain(x, t);
55 }
56};
57//==============================================================================
58template <typename V>
59class curvature_field<V, 3>
60 : public field<curvature_field<V>, typename V::real_type, 3> {
61 //============================================================================
62 // typedefs
63 //============================================================================
64 public:
66 using real_type = typename V::real_type;
68 using typename parent_type::tensor_type;
69 using typename parent_type::pos_type;
70
71 //============================================================================
72 // fields
73 //============================================================================
74 private:
76
77 //============================================================================
78 // ctor
79 //============================================================================
80 public:
81 template <typename Real>
82 curvature_field(const field<V, Real, 3, 3>& v) : m_vf{v.as_derived()} {}
83
84 //============================================================================
85 // methods
86 //============================================================================
87 public:
88 constexpr tensor_type evaluate(const pos_type& x, real_type t) const {
89 const auto Jf = diff(m_vf);
90 const auto J = Jf(x, t);
91 const auto v = m_vf(x, t);
92 const auto a = J * v;
93 const auto lv = length(v);
94 return cross(v,a) / (lv * lv * lv);
95 }
96 //----------------------------------------------------------------------------
97 constexpr bool in_domain(const pos_type& x, real_type t) const {
98 return m_vf.in_domain(x, t);
99 }
100};
101//==============================================================================
102template <typename V, typename Real>
105}
106//==============================================================================
107template <typename V, typename Real>
110}
111//==============================================================================
112} // namespace tatooine
113//==============================================================================
114
115#endif
curvature_field(const field< V, Real, 2, 2 > &v)
Definition: curvature_field.h:38
typename V::real_type real_type
Definition: curvature_field.h:22
constexpr bool in_domain(const pos_type &x, real_type t) const
Definition: curvature_field.h:53
constexpr tensor_type evaluate(const pos_type &x, real_type t) const
Definition: curvature_field.h:44
V m_vf
Definition: curvature_field.h:31
V m_vf
Definition: curvature_field.h:75
constexpr bool in_domain(const pos_type &x, real_type t) const
Definition: curvature_field.h:97
constexpr tensor_type evaluate(const pos_type &x, real_type t) const
Definition: curvature_field.h:88
curvature_field(const field< V, Real, 3, 3 > &v)
Definition: curvature_field.h:82
typename V::real_type real_type
Definition: curvature_field.h:66
Definition: curvature_field.h:12
Definition: algorithm.h:6
auto curvature(const field< V, Real, 2, 2 > &vf)
Definition: curvature_field.h:103
constexpr auto diff(polynomial< Real, Degree > const &f)
Definition: polynomial.h:179
constexpr auto cross(base_tensor< Tensor0, T0, 3 > const &lhs, base_tensor< Tensor1, T1, 3 > const &rhs)
Definition: cross.h:9
Definition: field.h:134
auto as_derived() -> auto &
Definition: field.h:161
Definition: vec.h:12