From: Martin Kronbichler Date: Mon, 19 Aug 2024 09:27:23 +0000 (+0200) Subject: Add get_mpi_communicator to concept vector_space_vector X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4a8764e9e6ca04750e8087f2ae3a4f556176f341;p=dealii.git Add get_mpi_communicator to concept vector_space_vector --- diff --git a/include/deal.II/base/template_constraints.h b/include/deal.II/base/template_constraints.h index 16b713c0b4..515ee535e9 100644 --- a/include/deal.II/base/template_constraints.h +++ b/include/deal.II/base/template_constraints.h @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -1051,6 +1052,10 @@ namespace concepts { U.all_zero() } -> std::same_as; + + { + U.get_mpi_communicator() + } -> std::same_as; }; diff --git a/include/deal.II/lac/block_vector_base.h b/include/deal.II/lac/block_vector_base.h index a933da4b75..01390fde39 100644 --- a/include/deal.II/lac/block_vector_base.h +++ b/include/deal.II/lac/block_vector_base.h @@ -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::update_ghost_values() const +template +MPI_Comm +BlockVectorBase::get_mpi_communicator() const +{ + if (n_blocks() > 0) + return block(0).get_mpi_communicator(); + else + return MPI_COMM_SELF; +} + + + template BlockVectorBase & BlockVectorBase::operator=(const value_type s) diff --git a/include/deal.II/lac/vector.h b/include/deal.II/lac/vector.h index 045ab4eb8e..b385674b87 100644 --- a/include/deal.II/lac/vector.h +++ b/include/deal.II/lac/vector.h @@ -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::update_ghost_values() const +template +inline MPI_Comm +Vector::get_mpi_communicator() const +{ + return MPI_COMM_SELF; +} + + template template inline void