libMesh
Public Member Functions | List of all members
PackedRangeTest Class Reference
Inheritance diagram for PackedRangeTest:
[legend]

Public Member Functions

 LIBMESH_CPPUNIT_TEST_SUITE (PackedRangeTest)
 
 CPPUNIT_TEST (testNullAllGather)
 
 CPPUNIT_TEST (testNullSendReceive)
 
 CPPUNIT_TEST (testContainerSendReceive)
 
 CPPUNIT_TEST_SUITE_END ()
 
void setUp ()
 
void tearDown ()
 
void testNullAllGather ()
 
void testNullSendReceive ()
 
void testContainerSendReceive ()
 

Detailed Description

Definition at line 11 of file packed_range_test.C.

Member Function Documentation

◆ CPPUNIT_TEST() [1/3]

PackedRangeTest::CPPUNIT_TEST ( testNullAllGather  )

◆ CPPUNIT_TEST() [2/3]

PackedRangeTest::CPPUNIT_TEST ( testNullSendReceive  )

◆ CPPUNIT_TEST() [3/3]

PackedRangeTest::CPPUNIT_TEST ( testContainerSendReceive  )

◆ CPPUNIT_TEST_SUITE_END()

PackedRangeTest::CPPUNIT_TEST_SUITE_END ( )

◆ LIBMESH_CPPUNIT_TEST_SUITE()

PackedRangeTest::LIBMESH_CPPUNIT_TEST_SUITE ( PackedRangeTest  )

◆ setUp()

void PackedRangeTest::setUp ( )
inline

Definition at line 26 of file packed_range_test.C.

27  {}

◆ tearDown()

void PackedRangeTest::tearDown ( )
inline

Definition at line 29 of file packed_range_test.C.

30  {}

◆ testContainerSendReceive()

void PackedRangeTest::testContainerSendReceive ( )
inline

Definition at line 79 of file packed_range_test.C.

References TIMPI::Communicator::rank(), TIMPI::Communicator::send_receive_packed_range(), TIMPI::Communicator::size(), and TestCommWorld.

80  {
81  LOG_UNIT_TEST;
82 
83  std::vector<processor_id_type> vals;
84 
85  std::vector<std::string> send(1), recv;
86 
87  const unsigned int my_rank = TestCommWorld->rank();
88  const unsigned int dest_rank =
89  (my_rank + 1) % TestCommWorld->size();
90  const unsigned int source_rank =
91  (my_rank + TestCommWorld->size() - 1) % TestCommWorld->size();
92 
93  {
94  std::ostringstream os;
95  os << my_rank;
96  send[0] = os.str();
97  }
98 
100  (dest_rank, (void *)(NULL), send.begin(), send.end(),
101  source_rank, (void *)(NULL),
102  std::back_inserter(recv),
103  (std::string*)NULL);
104 
105  CPPUNIT_ASSERT_EQUAL(recv.size(), std::size_t(1));
106 
107  std::string check;
108  {
109  std::ostringstream os;
110  os << source_rank;
111  check = os.str();
112  }
113 
114  CPPUNIT_ASSERT_EQUAL(recv[0], check);
115  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
processor_id_type rank() const
processor_id_type size() const
void send_receive_packed_range(const unsigned int dest_processor_id, const Context1 *context1, RangeIter send_begin, const RangeIter send_end, const unsigned int source_processor_id, Context2 *context2, OutputIter out, const T *output_type, const MessageTag &send_tag=no_tag, const MessageTag &recv_tag=any_tag, std::size_t approx_buffer_size=1000000) const

◆ testNullAllGather()

void PackedRangeTest::testNullAllGather ( )
inline

Definition at line 34 of file packed_range_test.C.

References TIMPI::Communicator::allgather_packed_range(), TIMPI::Communicator::rank(), and TestCommWorld.

35  {
36  LOG_UNIT_TEST;
37 
38  std::vector<processor_id_type> vals;
39 
40  std::vector<std::string> send(1);
41  if (TestCommWorld->rank() == 0)
42  send[0].assign("Hello");
43  else
44  send[0].assign("Goodbye");
45 
47  ((void *)(NULL), send.begin(), send.end(),
49  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
processor_id_type rank() const
void allgather_packed_range(Context *context, Iter range_begin, const Iter range_end, OutputIter out, std::size_t approx_buffer_size=1000000) const
A do-nothing class for templated methods that expect output iterator arguments.

◆ testNullSendReceive()

void PackedRangeTest::testNullSendReceive ( )
inline

Definition at line 52 of file packed_range_test.C.

References TIMPI::Communicator::rank(), TIMPI::Communicator::send_receive_packed_range(), TIMPI::Communicator::size(), and TestCommWorld.

53  {
54  LOG_UNIT_TEST;
55 
56  std::vector<processor_id_type> vals;
57 
58  std::vector<std::string> send(1);
59  const unsigned int my_rank = TestCommWorld->rank();
60  const unsigned int dest_rank =
61  (my_rank + 1) % TestCommWorld->size();
62  const unsigned int source_rank =
63  (my_rank + TestCommWorld->size() - 1) % TestCommWorld->size();
64 
65  {
66  std::ostringstream os;
67  os << my_rank;
68  send[0] = os.str();
69  }
70 
72  (dest_rank, (void *)(NULL), send.begin(), send.end(),
73  source_rank, (void *)(NULL),
75  (std::string*)NULL);
76  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
processor_id_type rank() const
processor_id_type size() const
A do-nothing class for templated methods that expect output iterator arguments.
void send_receive_packed_range(const unsigned int dest_processor_id, const Context1 *context1, RangeIter send_begin, const RangeIter send_end, const unsigned int source_processor_id, Context2 *context2, OutputIter out, const T *output_type, const MessageTag &send_tag=no_tag, const MessageTag &recv_tag=any_tag, std::size_t approx_buffer_size=1000000) const

The documentation for this class was generated from the following file: