10 #include <Eigen/Dense>
11 #include <Eigen/Eigenvalues>
21 template <
typename T,
unsigned Dim = 2>
29 Field<T, Dim, 1>(std::get<0>(ff.CurrentPosition().
GetAll().Size()),
30 std::get<1>(ff.CurrentPosition().
GetAll().Size())),
32 initial_time_(ff.InitialPosition().
GetTime())
42 inline T
Get(
const unsigned i,
const unsigned j)
const
44 return this->
data_(i,j);
52 auto initial_pos_data = flow_field_.InitialPosition().GetAll();
53 auto current_pos_data = flow_field_.CurrentPosition().GetAll();
54 auto dt = this->
time_ - initial_time_;
56 switch(flow_field_.GetDirection())
59 std::cout <<
"Forward FTLE calculation begins" << std::endl;
62 std::cout <<
"Backward FTLE calculation begins" << std::endl;
67 #pragma omp parallel for
68 for (
unsigned i = 0; i < this->
nx_; ++i)
73 Eigen::Matrix<T, 2, 2> deformation, cauchy_green;
75 for (
unsigned j = 0; j < this->
ny_; ++j)
77 std::tie(x0_pre, x0_next, y0_pre, y0_next) = initial_pos_data.GetNearby(i,j);
78 std::tie(x_pre, x_next, y_pre, y_next) = current_pos_data.GetNearby(i,j);
81 deformation(0,0) = (x_next.
x-x_pre.
x) / (x0_next.
x-x0_pre.
x);
82 deformation(0,1) = (y_next.
x-y_pre.
x) / (y0_next.
y-y0_pre.
y);
83 deformation(1,0) = (x_next.
y-x_pre.
y) / (x0_next.
x-x0_pre.
x);
84 deformation(1,1) = (y_next.
y-y_pre.
y) / (y0_next.
y-y0_pre.
y);
86 cauchy_green = deformation.transpose() * deformation;
88 auto eivals = cauchy_green.template selfadjointView<Eigen::Lower>().eigenvalues();
89 this->
data_(i,j).value = .5 * std::log(eivals.maxCoeff()) / dt;
94 switch(flow_field_.GetDirection())
97 std::cout <<
"Forward FTLE calculation ends";
100 std::cout <<
"Backward FTLE calculation ends";
104 std::cout <<
" (Execution time: " <<
Class for flow field.
Definition: flow.hpp:15
void End()
Definition: basic.hpp:374
T y
Definition: basic.hpp:104
const unsigned nx_
Definition: field.hpp:95
T x
Definition: basic.hpp:103
T Get(const unsigned i, const unsigned j) const
Definition: ftle.hpp:42
Class for finite-time Lyapunov exponent (FTLE) fields.
Definition: ftle.hpp:22
auto & GetAll() const
Definition: field.hpp:47
Class for time recording.
Definition: basic.hpp:354
const unsigned ny_
Definition: field.hpp:96
Class for general physical fields.
Definition: field.hpp:35
FTLE(FlowField< T, Dim > &ff)
Definition: ftle.hpp:28
void Calculate()
Definition: ftle.hpp:48
auto GetTime()
Definition: flow.hpp:79
void UpdateTime(const T time)
Definition: field.hpp:79
Tensor< Vector< T, Size >, Dim > data_
Definition: field.hpp:97
Struct for vectors.
Definition: basic.hpp:92
auto GetTime() const
Definition: field.hpp:55
double GetTotalElapsedTime() const
Definition: basic.hpp:400
void Begin()
Definition: basic.hpp:363
T time_
Definition: field.hpp:98