1/*
2 * vector_dist_util_unit_tests.hpp
3 *
4 * Created on: Feb 14, 2018
5 * Author: i-bird
6 */
7
8#ifndef SRC_VECTOR_TESTS_VECTOR_DIST_UTIL_UNIT_TESTS_HPP_
9#define SRC_VECTOR_TESTS_VECTOR_DIST_UTIL_UNIT_TESTS_HPP_
10
11
12/*! \brief Count local and non local
13 *
14 * \param vd distributed vector
15 * \param it iterator
16 * \param bc boundary conditions
17 * \param box domain box
18 * \param dom_ext domain + ghost box
19 * \param l_cnt local particles counter
20 * \param nl_cnt non local particles counter
21 * \param n_out out of domain + ghost particles counter
22 *
23 */
24template<unsigned int dim,typename vector_dist>
25inline void count_local_n_local(vector_dist & vd,
26 vector_dist_iterator & it,
27 size_t (& bc)[dim] ,
28 Box<dim,typename vector_dist::stype> & box,
29 Box<dim,typename vector_dist::stype> & dom_ext,
30 size_t & l_cnt,
31 size_t & nl_cnt,
32 size_t & n_out)
33{
34 auto & ct = vd.getDecomposition();
35
36 while (it.isNext())
37 {
38 auto key = it.get();
39 // Check if it is in the domain
40 if (box.isInsideNP(vd.getPos(key)) == true)
41 {
42 Point<dim,typename vector_dist::stype> xp = vd.getPos(key);
43
44 // Check if local
45 if (ct.isLocalBC(xp,bc) == true)
46 l_cnt++;
47 else
48 nl_cnt++;
49 }
50 else
51 {
52 nl_cnt++;
53 }
54
55 Point<dim,typename vector_dist::stype> xp = vd.getPos(key);
56
57 // Check that all particles are inside the Domain + Ghost part
58 if (dom_ext.isInside(xp) == false)
59 n_out++;
60
61 ++it;
62 }
63}
64
65
66
67#endif /* SRC_VECTOR_TESTS_VECTOR_DIST_UTIL_UNIT_TESTS_HPP_ */
68