7 #ifndef NIHU_LISTS_HPP_INCLUDED
8 #define NIHU_LISTS_HPP_INCLUDED
37 typedef std::vector<std::vector<size_t> > list_t;
40 static size_t const num_lists = 9;
41 list_t lists[num_lists];
42 static const bool p2l_allowed =
false;
49 template <
class ClusterDerived>
52 for (
size_t i = 0; i < num_lists; ++i)
54 this->fill_lists(0, tree);
63 return this->lists[idx];
75 template <
class ClusterDerived>
78 if (tree[from].is_leaf())
80 if (tree[to].is_receiver() && tree[from].is_source())
81 this->lists[P2P][to].push_back(from);
82 if (tree[from].get_level() > tree[to].get_level())
83 if (tree[from].is_receiver() && tree[to].is_source())
84 this->lists[P2P][from].push_back(to);
88 for (
auto pc : tree[from].get_children())
90 if (!interaction_lists::p2l_allowed
91 || tree[to].get_bounding_box().is_adjacent(tree[pc].get_bounding_box()))
92 add_adjacent_leaves(to, pc, tree);
95 if (tree[to].is_receiver() && tree[pc].is_source())
96 this->lists[M2P][to].push_back(pc);
97 if (tree[pc].is_receiver() && tree[to].is_source())
98 this->lists[P2L][pc].push_back(to);
109 template <
class ClusterDerived>
110 void fill_lists(
size_t root, cluster_tree<ClusterDerived>
const &tree)
114 this->lists[Near][root].push_back(root);
118 for (
auto ppn : this->lists[Near][tree[root].get_parent_idx()])
121 for (
auto p : tree[ppn].get_children())
124 if (tree[root].get_bounding_box().is_adjacent(tree[p].get_bounding_box()))
125 this->lists[Near][root].push_back(p);
127 if (tree[root].is_receiver() && tree[p].is_source())
128 this->lists[M2L][root].push_back(p);
133 if (tree[root].is_leaf())
134 for (
auto pc : this->lists[Near][root])
135 add_adjacent_leaves(root, pc, tree);
138 for (
auto pc : tree[root].get_children())
140 if (tree[root].get_level() >= 2)
142 if (tree[root].is_source())
143 this->lists[M2M][root].push_back(pc);
144 if (tree[root].is_receiver())
145 this->lists[L2L][pc].push_back(root);
148 fill_lists(pc, tree);
159 std::ostream_iterator<size_t> out_it(os,
", ");
161 for (
size_t c = 0; c < this->lists[0].size(); ++c)
163 std::cout << c << std::endl;
165 std::copy(this->lists[M2L][c].begin(), this->lists[M2L][c].end(), out_it);
169 std::copy(this->lists[M2P][c].begin(), this->lists[M2P][c].end(), out_it);
173 std::copy(this->lists[P2L][c].begin(), this->lists[P2L][c].end(), out_it);
177 std::copy(this->lists[P2P][c].begin(), this->lists[P2P][c].end(), out_it);