velocity_function.hpp
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include <cmath>
10 #include <tuple>
11 #include <cassert>
12 
13 namespace LCS {
20 namespace VelocityFunction {
21 
45 template <typename T>
46 struct BowerModel
47 {
49  BowerModel(): sc_(50), a_(50), l_(400), cx_(10), lambda_(40) {}
50 
54  BowerModel(std::vector<T>& p)
55  {
56  assert(p.size() == 5);
57  sc_ = p[0]; a_ = p[1]; l_ = p[2]; cx_ = p[3]; lambda_ = p[4];
58  }
59 
65  inline auto operator() (const T x, const T y, const T t = 0) const
66  {
67 
68  T phi0 = sc_ * lambda_; // scale factor
69  T k = 8 * std::atan(1) / l_; // wave number (2*pi/L)
70 
71  T yc = a_ * std::sin(k * x);
72  T dyc = a_ * k * std::cos(k * x);
73  T alpha0 = lambda_ * std::sqrt(dyc*dyc + 1);
74 
75  T u = -cx_ + phi0 / std::pow(std::cosh((y-yc)/alpha0), 2) / alpha0;
76  T v = -phi0 * ((yc*dyc*k*k*(y-yc)) / (lambda_*std::pow(dyc*dyc+1,1.5)) - dyc/alpha0)
77  / std::pow(std::cosh((y-yc)/alpha0), 2);
78 
79  return std::make_tuple(u, v);
80  }
81 
82  T sc_;
83  T a_;
84  T l_;
85  T cx_;
86  T lambda_;
87 };
88 
89 
106 template <typename T>
108 {
110  DoubleGyreModel(): epsilon_(0.1), a_(0.1), omega_(4*std::atan(1)/5) {}
111 
115  DoubleGyreModel(std::vector<T>& p)
116  {
117  assert(p.size() == 3);
118  epsilon_ = p[0]; a_ = p[1]; omega_ = p[2];
119  }
120 
126  inline auto operator() (const T x, const T y, const T t) const
127  {
128  T at = epsilon_ * std::sin(omega_ * t);
129  T bt = 1 - 2 * epsilon_ * std::sin(omega_ * t);
130  T f = at*x*x + bt*x;
131  T dfdx = 2*at*x + bt;
132 
133  T pi = 4 * std::atan(1);
134  T u = -pi * a_ * std::sin(pi*f) * std::cos(pi*y);
135  T v = pi * a_ * std::cos(pi*f) * std::sin(pi*y) * dfdx;
136 
137  return std::make_tuple(u, v);
138  }
139 
141  T a_;
142  T omega_;
144 };
145 
146 
147 }
148 }
Bower model for meandering jet.
Definition: velocity_function.hpp:46
T omega_
Definition: velocity_function.hpp:142
T lambda_
Definition: velocity_function.hpp:86
DoubleGyreModel(std::vector< T > &p)
Definition: velocity_function.hpp:115
auto operator()(const T x, const T y, const T t=0) const
Definition: velocity_function.hpp:65
auto operator()(const T x, const T y, const T t) const
Definition: velocity_function.hpp:126
T sc_
Definition: velocity_function.hpp:82
DoubleGyreModel()
Definition: velocity_function.hpp:110
Double-gyre model.
Definition: velocity_function.hpp:107
T a_
Definition: velocity_function.hpp:83
T epsilon_
Definition: velocity_function.hpp:140
BowerModel(std::vector< T > &p)
Definition: velocity_function.hpp:54
T l_
Definition: velocity_function.hpp:84
T cx_
Definition: velocity_function.hpp:85
BowerModel()
Definition: velocity_function.hpp:49
T a_
Definition: velocity_function.hpp:141