]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Adjust a test to use the free function interface. 13414/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Sat, 26 Feb 2022 21:43:16 +0000 (14:43 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Sat, 26 Feb 2022 21:44:13 +0000 (14:44 -0700)
tests/base/consensus_algorithm_01.cc

index af64ddd2b0138b78477c506fa2120bf370539ac3..7f91866e2ac9b9a965623d16356bf7c5c53f787f 100644 (file)
@@ -14,7 +14,7 @@
 // ---------------------------------------------------------------------
 
 
-// Test ConsensusAlgorithms::AnonymousProcess.
+// Test ConsensusAlgorithms::selection().
 
 #include <deal.II/base/mpi_consensus_algorithms.h>
 
@@ -30,31 +30,26 @@ test(const MPI_Comm &comm)
   using T1 = unsigned int;
   using T2 = unsigned int;
 
-  dealii::Utilities::MPI::ConsensusAlgorithms::AnonymousProcess<T1, T2> process(
-    [&]() {
-      std::vector<unsigned int> result{(my_rank + 1) % n_rank};
-      return result;
-    },
-    [&](const unsigned int other_rank, std::vector<T1> &send_buffer) {
-      send_buffer.push_back(my_rank);
-    },
-    [&](const unsigned int &   other_rank,
-        const std::vector<T1> &buffer_recv,
-        std::vector<T2> &      request_buffer) {
-      AssertDimension(other_rank, buffer_recv.front());
-      deallog << "ConsensusAlgorithmProcess::answer_request() passed!"
-              << std::endl;
-      request_buffer.push_back(my_rank);
-    },
-    [&](const unsigned int other_rank, const std::vector<T2> &recv_buffer) {
-      AssertDimension(other_rank, recv_buffer.front());
-      deallog << "ConsensusAlgorithmProcess::function_read_answer() passed!"
-              << std::endl;
-    });
-
   const auto sources =
-    dealii::Utilities::MPI::ConsensusAlgorithms::Selector<T1, T2>(process, comm)
-      .run();
+    dealii::Utilities::MPI::ConsensusAlgorithms::selector<T1, T2>(
+      /* target_processes: */
+      std::vector<unsigned int>{(my_rank + 1) % n_rank},
+      /* create_request: */
+      [my_rank](const unsigned int) { return std::vector<T1>({my_rank}); },
+      /* answer_request: */
+      [my_rank](const unsigned int other_rank, const std::vector<T1> &request) {
+        AssertDimension(other_rank, request.front());
+        deallog << "ConsensusAlgorithmProcess::answer_request() passed!"
+                << std::endl;
+        return std::vector<T2>({my_rank});
+      },
+      /* process_answer: */
+      [](const unsigned int other_rank, const std::vector<T2> &answer) {
+        AssertDimension(other_rank, answer.front());
+        deallog << "ConsensusAlgorithmProcess::function_read_answer() passed!"
+                << std::endl;
+      },
+      comm);
 
   for (const auto &i : sources)
     deallog << i << ' ';

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.