/
formulae_mpdata_dfl_2d.hpp
99 lines (94 loc) · 2.84 KB
/
formulae_mpdata_dfl_2d.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/** @file
* @copyright University of Warsaw
* @section LICENSE
* GPLv3+ (see the COPYING file or http://www.gnu.org/licenses/)
*/
#pragma once
#include <libmpdata++/formulae/mpdata/formulae_mpdata_common.hpp>
#include <libmpdata++/formulae/mpdata/formulae_mpdata_g_2d.hpp>
#include <libmpdata++/formulae/mpdata/formulae_mpdata_psi_2d.hpp>
namespace libmpdataxx
{
namespace formulae
{
namespace mpdata
{
// divergent flow correction - no correction
template<opts_t opts, int dim, class arr_2d_t, class ix_t>
inline auto DFL(
const arr_2d_t &psi,
const arrvec_t<arr_2d_t> &GC,
const arr_2d_t &G,
const ix_t &i,
const ix_t &j,
typename std::enable_if<!opts::isset(opts, opts::dfl)>::type* = 0
)
{
return 0;
}
// divergent flow correction - general case
template<opts_t opts, int dim, class arr_2d_t, class ix_t>
inline auto DFL(
const arr_2d_t &psi, //to have the same arguments as in iga option
const arrvec_t<arr_2d_t> &GC,
const arr_2d_t &G,
const ix_t &i,
const ix_t &j,
typename std::enable_if<opts::isset(opts, opts::dfl) && !opts::isset(opts, opts::iga)>::type* = 0
)
{
return return_helper<ix_t>(
- fconst<arr_2d_t>(0.25) * GC[dim](pi<dim>(i+h, j))
/
G_bar_x<opts, dim>(G, i, j)
*
(
(
GC[dim](pi<dim>((i+1)+h, j)) -
GC[dim](pi<dim>(i-h , j))
)
+
(
GC[dim-1](pi<dim>(i+1, j+h)) +
GC[dim-1](pi<dim>(i, j+h)) -
GC[dim-1](pi<dim>(i+1, j-h)) -
GC[dim-1](pi<dim>(i, j-h))
)
)
);
}
// divergent flow correction - infinite gauge version
template<opts_t opts, int dim, class arr_2d_t, class ix_t>
inline auto DFL(
const arr_2d_t &psi,
const arrvec_t<arr_2d_t> &GC,
const arr_2d_t &G,
const ix_t &i,
const ix_t &j,
typename std::enable_if<opts::isset(opts, opts::dfl) && opts::isset(opts, opts::iga)>::type* = 0
)
{
return return_helper<ix_t>(
- fconst<arr_2d_t>(0.25) * GC[dim](pi<dim>(i+h, j))
/
G_bar_x<opts, dim>(G, i, j)
*
(
(
GC[dim](pi<dim>((i+1)+h, j)) -
GC[dim](pi<dim>(i-h , j))
)
+
(
GC[dim-1](pi<dim>(i+1, j+h)) +
GC[dim-1](pi<dim>(i, j+h)) -
GC[dim-1](pi<dim>(i+1, j-h)) -
GC[dim-1](pi<dim>(i, j-h))
)
)
* psi_bar_x<opts, dim>(psi, i, j)
);
}
} // namespace mpdata
} // namespace formulae
} // namespace libmpdataxx