1 #include <libmesh/parallel_sort.h> 2 #include <libmesh/parallel.h> 16 CPPUNIT_TEST( testSort );
18 CPPUNIT_TEST_SUITE_END();
33 const int n_vals = size - rank;
34 std::vector<int> vals(n_vals);
38 int val = rank+1, stride = size;
39 for (
int i=0; i != n_vals; ++i)
41 vals[n_vals-i-1] = val;
50 const std::vector<int> & my_bin = sorter.
bin();
57 int total_size = cast_int<int>(my_bin.size());
60 CPPUNIT_ASSERT_EQUAL(total_size, size*(size+1)/2);
65 for (
int i=1; i <= total_size; ++i)
67 int count_i = std::count(my_bin.begin(), my_bin.end(), i);
68 CPPUNIT_ASSERT(count_i < 2);
72 CPPUNIT_ASSERT(rank_with_i <= rank);
78 CPPUNIT_ASSERT_EQUAL(count_i, 1);
const std::vector< KeyType > & bin()
Return a constant reference to _my_bin.
libMesh::Parallel::Communicator * TestCommWorld
void sort()
This is the only method which needs to be called by the user.
processor_id_type rank() const
The libMesh namespace provides an interface to certain functionality in the library.
processor_id_type size() const
bool is_sorted(const std::vector< KeyType > &v)
The parallel sorting method is templated on the type of data which is to be sorted.
void max(const T &r, T &o, Request &req) const
CPPUNIT_TEST_SUITE_REGISTRATION(ParallelSortTest)