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

Member Function Documentation

PackedRangeTest::CPPUNIT_TEST ( testNullAllGather  )
PackedRangeTest::CPPUNIT_TEST ( testNullSendReceive  )
PackedRangeTest::CPPUNIT_TEST ( testContainerSendReceive  )
PackedRangeTest::CPPUNIT_TEST_SUITE ( PackedRangeTest  )
PackedRangeTest::CPPUNIT_TEST_SUITE_END ( )
void PackedRangeTest::setUp ( )

Definition at line 115 of file packed_range_test.C.

116  {}
void PackedRangeTest::tearDown ( )

Definition at line 118 of file packed_range_test.C.

119  {}
void PackedRangeTest::testContainerSendReceive ( )

Definition at line 164 of file packed_range_test.C.

References CPPUNIT_TEST_SUITE_REGISTRATION(), libMesh::Parallel::Communicator::rank(), libMesh::Parallel::send(), libMesh::Parallel::Communicator::send_receive_packed_range(), libMesh::Parallel::Communicator::size(), and TestCommWorld.

165  {
166  std::vector<processor_id_type> vals;
167 
168  std::vector<std::string> send(1), recv;
169 
170  const unsigned int my_rank = TestCommWorld->rank();
171  const unsigned int dest_rank =
172  (my_rank + 1) % TestCommWorld->size();
173  const unsigned int source_rank =
174  (my_rank + TestCommWorld->size() - 1) % TestCommWorld->size();
175 
176  {
177  std::ostringstream os;
178  os << my_rank;
179  send[0] = os.str();
180  }
181 
183  (dest_rank, (void *)(NULL), send.begin(), send.end(),
184  source_rank, (void *)(NULL),
185  std::back_inserter(recv),
186  (std::string*)NULL);
187 
188  CPPUNIT_ASSERT_EQUAL(recv.size(), std::size_t(1));
189 
190  std::string check;
191  {
192  std::ostringstream os;
193  os << source_rank;
194  check = os.str();
195  }
196 
197  CPPUNIT_ASSERT_EQUAL(recv[0], check);
198  }
void send(const unsigned int dest_processor_id, const T &data, const MessageTag &tag=no_tag, const Communicator &comm=Communicator_World)
unsigned int size() const
Definition: parallel.h:726
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:28
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) const
Send a range-of-pointers to one processor while simultaneously receiving another range from a (potent...
unsigned int rank() const
Definition: parallel.h:724
void PackedRangeTest::testNullAllGather ( )

Definition at line 123 of file packed_range_test.C.

References libMesh::Parallel::Communicator::allgather_packed_range(), libMesh::Parallel::Communicator::rank(), libMesh::Parallel::send(), and TestCommWorld.

124  {
125  std::vector<processor_id_type> vals;
126 
127  std::vector<std::string> send(1);
128  if (TestCommWorld->rank() == 0)
129  send[0].assign("Hello");
130  else
131  send[0].assign("Goodbye");
132 
134  ((void *)(NULL), send.begin(), send.end(),
136  }
void send(const unsigned int dest_processor_id, const T &data, const MessageTag &tag=no_tag, const Communicator &comm=Communicator_World)
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:28
A do-nothing class for templated methods that expect output iterator arguments.
unsigned int rank() const
Definition: parallel.h:724
void allgather_packed_range(Context *context, Iter range_begin, const Iter range_end, OutputIter out) const
Take a range of local variables, combine it with ranges from all processors, and write the output to ...
void PackedRangeTest::testNullSendReceive ( )

Definition at line 139 of file packed_range_test.C.

References libMesh::Parallel::Communicator::rank(), libMesh::Parallel::send(), libMesh::Parallel::Communicator::send_receive_packed_range(), libMesh::Parallel::Communicator::size(), and TestCommWorld.

140  {
141  std::vector<processor_id_type> vals;
142 
143  std::vector<std::string> send(1);
144  const unsigned int my_rank = TestCommWorld->rank();
145  const unsigned int dest_rank =
146  (my_rank + 1) % TestCommWorld->size();
147  const unsigned int source_rank =
148  (my_rank + TestCommWorld->size() - 1) % TestCommWorld->size();
149 
150  {
151  std::ostringstream os;
152  os << my_rank;
153  send[0] = os.str();
154  }
155 
157  (dest_rank, (void *)(NULL), send.begin(), send.end(),
158  source_rank, (void *)(NULL),
160  (std::string*)NULL);
161  }
void send(const unsigned int dest_processor_id, const T &data, const MessageTag &tag=no_tag, const Communicator &comm=Communicator_World)
unsigned int size() const
Definition: parallel.h:726
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:28
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) const
Send a range-of-pointers to one processor while simultaneously receiving another range from a (potent...
A do-nothing class for templated methods that expect output iterator arguments.
unsigned int rank() const
Definition: parallel.h:724

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