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

Public Member Functions

 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 86 of file packed_range_test.C.

Member Function Documentation

◆ CPPUNIT_TEST() [1/3]

PackedRangeTest::CPPUNIT_TEST ( testContainerSendReceive  )

◆ CPPUNIT_TEST() [2/3]

PackedRangeTest::CPPUNIT_TEST ( testNullAllGather  )

◆ CPPUNIT_TEST() [3/3]

PackedRangeTest::CPPUNIT_TEST ( testNullSendReceive  )

◆ CPPUNIT_TEST_SUITE()

PackedRangeTest::CPPUNIT_TEST_SUITE ( PackedRangeTest  )

◆ CPPUNIT_TEST_SUITE_END()

PackedRangeTest::CPPUNIT_TEST_SUITE_END ( )

◆ setUp()

void PackedRangeTest::setUp ( )
inline

Definition at line 101 of file packed_range_test.C.

102  {}

◆ tearDown()

void PackedRangeTest::tearDown ( )
inline

Definition at line 104 of file packed_range_test.C.

105  {}

◆ testContainerSendReceive()

void PackedRangeTest::testContainerSendReceive ( )
inline

Definition at line 150 of file packed_range_test.C.

151  {
152  std::vector<processor_id_type> vals;
153 
154  std::vector<std::string> send(1), recv;
155 
156  const unsigned int my_rank = TestCommWorld->rank();
157  const unsigned int dest_rank =
158  (my_rank + 1) % TestCommWorld->size();
159  const unsigned int source_rank =
160  (my_rank + TestCommWorld->size() - 1) % TestCommWorld->size();
161 
162  {
163  std::ostringstream os;
164  os << my_rank;
165  send[0] = os.str();
166  }
167 
168  TestCommWorld->send_receive_packed_range
169  (dest_rank, (void *)(NULL), send.begin(), send.end(),
170  source_rank, (void *)(NULL),
171  std::back_inserter(recv),
172  (std::string*)NULL);
173 
174  CPPUNIT_ASSERT_EQUAL(recv.size(), std::size_t(1));
175 
176  std::string check;
177  {
178  std::ostringstream os;
179  os << source_rank;
180  check = os.str();
181  }
182 
183  CPPUNIT_ASSERT_EQUAL(recv[0], check);
184  }

References TestCommWorld.

◆ testNullAllGather()

void PackedRangeTest::testNullAllGather ( )
inline

Definition at line 109 of file packed_range_test.C.

110  {
111  std::vector<processor_id_type> vals;
112 
113  std::vector<std::string> send(1);
114  if (TestCommWorld->rank() == 0)
115  send[0].assign("Hello");
116  else
117  send[0].assign("Goodbye");
118 
119  TestCommWorld->allgather_packed_range
120  ((void *)(NULL), send.begin(), send.end(),
122  }

References TestCommWorld.

◆ testNullSendReceive()

void PackedRangeTest::testNullSendReceive ( )
inline

Definition at line 125 of file packed_range_test.C.

126  {
127  std::vector<processor_id_type> vals;
128 
129  std::vector<std::string> send(1);
130  const unsigned int my_rank = TestCommWorld->rank();
131  const unsigned int dest_rank =
132  (my_rank + 1) % TestCommWorld->size();
133  const unsigned int source_rank =
134  (my_rank + TestCommWorld->size() - 1) % TestCommWorld->size();
135 
136  {
137  std::ostringstream os;
138  os << my_rank;
139  send[0] = os.str();
140  }
141 
142  TestCommWorld->send_receive_packed_range
143  (dest_rank, (void *)(NULL), send.begin(), send.end(),
144  source_rank, (void *)(NULL),
146  (std::string*)NULL);
147  }

References TestCommWorld.


The documentation for this class was generated from the following file:
TestCommWorld
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:111
libMesh::null_output_iterator
A do-nothing class for templated methods that expect output iterator arguments.
Definition: null_output_iterator.h:40