Loading [MathJax]/extensions/tex2jax.js
Tatooine
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages Concepts
Q_field.h
Go to the documentation of this file.
1#ifndef TATOOINE_Q_FIELD_H
2#define TATOOINE_Q_FIELD_H
3//==============================================================================
4#include <tatooine/field.h>
6//==============================================================================
7namespace tatooine {
8//==============================================================================
9template <typename V>
11 : public scalarfield<Q_field<V>, field_real_type<V>, field_num_dimensions<V>> {
12 //============================================================================
13 // typedefs
14 //============================================================================
15 public:
18 scalarfield<this_type, field_real_type<V>, field_num_dimensions<V>>;
19 using typename parent_type::real_type;
20 using typename parent_type::pos_type;
21 using typename parent_type::tensor_type;
22 //============================================================================
23 // fields
24 //============================================================================
25 private:
26 V m_v;
27
28 //============================================================================
29 // ctor
30 //============================================================================
31 public:
32 template <typename V_>
33 explicit Q_field(V_&& v) : m_v{std::forward<V_>(v)} {}
34
35 Q_field(Q_field const&) = default;
36 Q_field(Q_field&&) noexcept = default;
37 auto operator=(Q_field const&) -> Q_field& = default;
38 auto operator=(Q_field&&) noexcept -> Q_field& = default;
39 ~Q_field() = default;
40
41 //============================================================================
42 // methods
43 //============================================================================
44 constexpr auto evaluate(pos_type const& x, real_type const t) const -> tensor_type {
45 auto J = diff(m_v, 1e-7)(x, t);
46 auto S = (J + transposed(J)) / 2;
47 auto Omega = (J - transposed(J)) / 2;
48 return (sqr_norm(Omega, 2) - sqr_norm(S, 2)) / 2;
49 }
50 //----------------------------------------------------------------------------
51 constexpr auto in_domain(pos_type const& x, real_type const t) const -> bool {
52 return m_v.in_domain(x, t);
53 }
54};
55//==============================================================================
56template <typename V>
57auto Q(
58 V&& v) requires is_vectorfield<std::decay_t<std::remove_pointer_t<V>>> {
59 return Q_field<std::decay_t<V>>{std::forward<V>(v)};
60}
61//------------------------------------------------------------------------------
62template <typename V>
63auto Q(V const& v) requires is_vectorfield<
64 std::decay_t<std::remove_pointer_t<V>>> {
65 return Q_field<V const&>{v};
66}
67//==============================================================================
68} // namespace tatooine
69//==============================================================================
70#endif
Definition: Q_field.h:11
constexpr auto evaluate(pos_type const &x, real_type const t) const -> tensor_type
Definition: Q_field.h:44
Q_field(Q_field &&) noexcept=default
Q_field(V_ &&v)
Definition: Q_field.h:33
V m_v
Definition: Q_field.h:26
Q_field(Q_field const &)=default
Real real_type
Definition: field.h:17
constexpr auto in_domain(pos_type const &x, real_type const t) const -> bool
Definition: Q_field.h:51
Definition: algorithm.h:6
auto transposed(dynamic_tensor auto &&t)
Definition: transposed_tensor.h:170
static constexpr bool is_vectorfield
Definition: field.h:249
constexpr auto diff(polynomial< Real, Degree > const &f)
Definition: polynomial.h:179
static constexpr forward_tag forward
Definition: tags.h:9
auto Q(V &&v)
Definition: Q_field.h:57
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
constexpr auto in_domain(const pos_type &, double) const
Definition: symbolic_field.h:50
Definition: vec.h:12