/
formulae_mpdata_dfl_1d.hpp
70 lines (64 loc) · 1.95 KB
/
formulae_mpdata_dfl_1d.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
/** @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>
namespace libmpdataxx
{
namespace formulae
{
namespace mpdata
{
//divergent flow correction see eq. (30) from @copybrief Smolarkiewicz_and_Margolin_1998)
template<opts_t opts, class arr_1d_t, class ix_t>
inline auto DFL(
const arr_1d_t &psi,
const arr_1d_t &GC,
const arr_1d_t &G,
const ix_t &i,
typename std::enable_if<!opts::isset(opts, opts::dfl)>::type* = 0
)
{
return 0;
}
template<opts_t opts, class arr_1d_t, class ix_t>
inline auto DFL(
const arr_1d_t &psi, //to have the same arguments as in iga option
const arr_1d_t &GC,
const arr_1d_t &G,
const ix_t &i,
typename std::enable_if<opts::isset(opts, opts::dfl) && !opts::isset(opts, opts::iga)>::type* = 0
)
{
return return_helper<ix_t>(
- fconst<arr_1d_t>(0.5) * GC(i+h)
/
(formulae::G<opts>(G, i+1) + formulae::G<opts>(G, i))
*
(GC((i+1)+h) - GC(i-h))
);
}
template<opts_t opts, class arr_1d_t, class ix_t>
inline auto DFL(
const arr_1d_t &psi,
const arr_1d_t &GC,
const arr_1d_t &G,
const ix_t &i,
typename std::enable_if<opts::isset(opts, opts::dfl) && opts::isset(opts, opts::iga)>::type* = 0
)
{
return return_helper<ix_t>(
- fconst<arr_1d_t>(0.5) * GC(i+h)
/
(formulae::G<opts>(G, i+1) + formulae::G<opts>(G, i))
*
(GC((i+1)+h) - GC(i-h))
*
fconst<arr_1d_t>(0.5) * (psi(i+1) + psi(i)) //to be compatible with iga formulation
);
}
} // namespace mpdata
} // namespace formulae
} // namespcae libmpdataxx