From 506701622c31acadbce5e594348023582bf7aabd Mon Sep 17 00:00:00 2001 From: Pietro Incardona <incardon@mpi-cbg.de> Date: Wed, 14 Feb 2018 21:19:52 +0100 Subject: [PATCH] Adding missing file --- .../tests/vector_dist_util_unit_tests.hpp | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/Vector/tests/vector_dist_util_unit_tests.hpp diff --git a/src/Vector/tests/vector_dist_util_unit_tests.hpp b/src/Vector/tests/vector_dist_util_unit_tests.hpp new file mode 100644 index 000000000..f830e13fc --- /dev/null +++ b/src/Vector/tests/vector_dist_util_unit_tests.hpp @@ -0,0 +1,57 @@ +/* + * vector_dist_util_unit_tests.hpp + * + * Created on: Feb 14, 2018 + * Author: i-bird + */ + +#ifndef SRC_VECTOR_TESTS_VECTOR_DIST_UTIL_UNIT_TESTS_HPP_ +#define SRC_VECTOR_TESTS_VECTOR_DIST_UTIL_UNIT_TESTS_HPP_ + + +/*! \brief Count local and non local + * + * \param vd distributed vector + * \param it iterator + * \param bc boundary conditions + * \param box domain box + * \param dom_ext domain + ghost box + * \param l_cnt local particles counter + * \param nl_cnt non local particles counter + * \param n_out out of domain + ghost particles counter + * + */ +template<unsigned int dim,typename vector_dist> inline void count_local_n_local(vector_dist & vd, vector_dist_iterator & it, size_t (& bc)[dim] , Box<dim,float> & box, Box<dim,float> & dom_ext, size_t & l_cnt, size_t & nl_cnt, size_t & n_out) +{ + const CartDecomposition<dim,float> & ct = vd.getDecomposition(); + + while (it.isNext()) + { + auto key = it.get(); + // Check if it is in the domain + if (box.isInsideNP(vd.getPos(key)) == true) + { + // Check if local + if (ct.isLocalBC(vd.getPos(key),bc) == true) + l_cnt++; + else + nl_cnt++; + } + else + { + nl_cnt++; + } + + Point<dim,float> xp = vd.getPos(key); + + // Check that all particles are inside the Domain + Ghost part + if (dom_ext.isInside(xp) == false) + n_out++; + + ++it; + } +} + + + +#endif /* SRC_VECTOR_TESTS_VECTOR_DIST_UTIL_UNIT_TESTS_HPP_ */ -- GitLab