/
cyclic_1d.hpp
76 lines (64 loc) · 2.18 KB
/
cyclic_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
71
72
73
74
75
76
// 1D cyclic boundary conditions for libmpdata++
//
// licensing: GPU GPL v3
// copyright: University of Warsaw
#pragma once
#include <libmpdata++/bcond/detail/bcond_common.hpp>
namespace libmpdataxx
{
namespace bcond
{
template <typename real_t, int halo, bcond_e knd, drctn_e dir, int n_dims, int dim>
class bcond< real_t, halo, knd, dir, n_dims, dim,
typename std::enable_if<
knd == cyclic &&
dir == left &&
n_dims == 1
>::type
> : public detail::bcond_common<real_t, halo, n_dims>
{
using parent_t = detail::bcond_common<real_t, halo, n_dims>;
using arr_t = blitz::Array<real_t, 1>;
using parent_t::parent_t; // inheriting ctor
public:
void fill_halos_sclr(arr_t &a, const bool deriv = false)
{
a(this->left_halo_sclr) = a(this->rght_intr_sclr);
}
void fill_halos_vctr_alng(arrvec_t<arr_t> &av, const bool ad = false)
{
av[0](this->left_halo_vctr) = av[0](this->rght_intr_vctr);
}
void fill_halos_vctr_alng_cyclic(arrvec_t<arr_t> &av, const bool ad = false)
{
fill_halos_vctr_alng(av, ad);
}
};
template <typename real_t, int halo, bcond_e knd, drctn_e dir, int n_dims, int dim>
class bcond< real_t, halo, knd, dir, n_dims, dim,
typename std::enable_if<
knd == cyclic &&
dir == rght &&
n_dims == 1
>::type
> : public detail::bcond_common<real_t, halo, n_dims>
{
using parent_t = detail::bcond_common<real_t, halo, n_dims>;
using arr_t = blitz::Array<real_t, 1>;
using parent_t::parent_t; // inheriting ctor
public:
void fill_halos_sclr(arr_t &a, const bool deriv = false)
{
a(this->rght_halo_sclr) = a(this->left_intr_sclr);
}
void fill_halos_vctr_alng(arrvec_t<arr_t> &av, const bool ad = false)
{
av[0](this->rght_halo_vctr) = av[0](this->left_intr_vctr);
}
void fill_halos_vctr_alng_cyclic(arrvec_t<arr_t> &av, const bool ad = false)
{
fill_halos_vctr_alng(av, ad);
}
};
} // namespace bcond
} // namespace libmpdataxx