/
formulae_mpdata_hot_1d.hpp
63 lines (58 loc) · 1.64 KB
/
formulae_mpdata_hot_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
/** @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_psi_1d.hpp>
#include <libmpdata++/formulae/mpdata/formulae_mpdata_g_1d.hpp>
namespace libmpdataxx
{
namespace formulae
{
namespace mpdata
{
template<opts_t opts, class arr_1d_t, class ix_t>
forceinline_macro auto ndxx_psi_coeff(
const arr_1d_t &GC,
const arr_1d_t &G,
const ix_t &i
)
{
return return_helper<ix_t>(
(
3 * GC(i+h) * abs(GC(i+h)) / G_bar_x<opts>(G, i)
- 2 * pow3(GC(i+h)) / pow2(G_bar_x<opts>(G, i))
- GC(i+h)
) / 6
);
}
// third order terms
template<opts_t opts, class arr_1d_t, class ix_t>
forceinline_macro auto TOT(
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::tot)>::type* = 0
)
{
return return_helper<ix_t>(
ndxx_psi<opts>(psi, i) * ndxx_psi_coeff<opts>(GC, G, i)
);
}
template<opts_t opts, class arr_1d_t, class ix_t>
forceinline_macro auto TOT(
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::tot)>::type* = 0
)
{
return 0;
}
} // namespace mpdata
} // namespace formulae
} // namespcae libmpdataxx