]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add get_mpi_communicator to concept vector_space_vector
authorMartin Kronbichler <martin.kronbichler@rub.de>
Mon, 19 Aug 2024 09:27:23 +0000 (11:27 +0200)
committerMartin Kronbichler <martin.kronbichler@rub.de>
Mon, 19 Aug 2024 09:27:23 +0000 (11:27 +0200)
include/deal.II/base/template_constraints.h
include/deal.II/lac/block_vector_base.h
include/deal.II/lac/vector.h

index 16b713c0b4e6bfa96f60d7aab71e57629cb911d2..515ee535e92fa349781988cd4ef17fb66916147f 100644 (file)
@@ -19,6 +19,7 @@
 #include <deal.II/base/config.h>
 
 #include <deal.II/base/complex_overloads.h>
+#include <deal.II/base/mpi_stub.h>
 #include <deal.II/base/std_cxx20/type_traits.h>
 
 #include <complex>
@@ -1051,6 +1052,10 @@ namespace concepts
     {
       U.all_zero()
     } -> std::same_as<bool>;
+
+    {
+      U.get_mpi_communicator()
+    } -> std::same_as<MPI_Comm>;
   };
 
 
index a933da4b750170aa6666cb7b29e817936f809e19..01390fde394fc00561e502a10fbbcc3ac8ed9912 100644 (file)
@@ -949,6 +949,14 @@ public:
   void
   update_ghost_values() const;
 
+  /**
+   * This function returns the MPI communicator of the vector in the
+   * underlying blocks or, if the vector has not been initialized, the empty
+   * MPI_COMM_SELF.
+   */
+  MPI_Comm
+  get_mpi_communicator() const;
+
   /**
    * Determine an estimate for the memory consumption (in bytes) of this
    * object.
@@ -1994,6 +2002,18 @@ BlockVectorBase<VectorType>::update_ghost_values() const
 
 
 
+template <typename VectorType>
+MPI_Comm
+BlockVectorBase<VectorType>::get_mpi_communicator() const
+{
+  if (n_blocks() > 0)
+    return block(0).get_mpi_communicator();
+  else
+    return MPI_COMM_SELF;
+}
+
+
+
 template <typename VectorType>
 BlockVectorBase<VectorType> &
 BlockVectorBase<VectorType>::operator=(const value_type s)
index 045ab4eb8e8df34eec29ad5c549b2887b8e5b1cc..b385674b8707bd2698b0450922565d3ad0699a6e 100644 (file)
@@ -1072,6 +1072,16 @@ public:
    */
   void
   zero_out_ghost_values() const;
+
+  /**
+   * This function returns the empty object MPI_COMM_SELF that does not signal
+   * any parallel communication model, as this vector is in fact serial with
+   * respect to the message passing interface (MPI). The function exists for
+   * compatibility with the @p parallel vector classes (e.g.,
+   * LinearAlgebra::distributed::Vector class).
+   */
+  MPI_Comm
+  get_mpi_communicator() const;
   /** @} */
 
 private:
@@ -1413,6 +1423,14 @@ Vector<Number>::update_ghost_values() const
 
 
 
+template <typename Number>
+inline MPI_Comm
+Vector<Number>::get_mpi_communicator() const
+{
+  return MPI_COMM_SELF;
+}
+
+
 template <typename Number>
 template <typename Number2>
 inline void

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.