--- /dev/null
+Moved: The CommunicationPatternBase class has been moved from the LinearAlgebra
+namespace into the more general Utilities::MPI namespace.
+<br>
+(David Wells, 2021/02/15)
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2015 - 2020 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+#ifndef dealii_base_communication_pattern_base_h
+#define dealii_base_communication_pattern_base_h
+
+#include <deal.II/base/config.h>
+
+#include <deal.II/base/mpi.h>
+
+DEAL_II_NAMESPACE_OPEN
+
+// Forward declaration
+#ifndef DOXYGEN
+class IndexSet;
+#endif
+
+namespace Utilities
+{
+ namespace MPI
+ {
+ /**
+ * CommunicationPattern is an abstract class that is used to define a
+ * communication plan that can be called repeatedly to efficiently obtain
+ * off-processor elements. The idea is to decouple the communication pattern
+ * from the data that needs to be communicated. The goal is to reuse the
+ * same communication pattern for different containers. This is similar to
+ * the way SparseMatrix and SparsityPattern works.
+ */
+ class CommunicationPatternBase
+ {
+ public:
+ /**
+ * Destructor.
+ */
+ virtual ~CommunicationPatternBase() = default;
+
+ /**
+ * Reinitialize the communication pattern. The first argument
+ * `vector_space_vector_index_set` is the index set associated to a
+ * VectorSpaceVector object. The second argument
+ * `read_write_vector_index_set` is the index set associated to a
+ * ReadWriteVector object.
+ */
+ virtual void
+ reinit(const IndexSet &vector_space_vector_index_set,
+ const IndexSet &read_write_vector_index_set,
+ const MPI_Comm &communicator) = 0;
+
+ /**
+ * Return a constant reference to the underlying MPI communicator.
+ */
+ virtual const MPI_Comm &
+ get_mpi_communicator() const = 0;
+ };
+
+ } // namespace MPI
+
+} // namespace Utilities
+
+DEAL_II_NAMESPACE_CLOSE
+
+#endif
#include <deal.II/base/config.h>
+#include <deal.II/base/communication_pattern_base.h>
#include <deal.II/base/mpi.h>
#include <deal.II/base/mpi_compute_index_owner_internal.h>
#include <deal.II/base/mpi_tags.h>
-#include <deal.II/lac/communication_pattern_base.h>
#include <deal.II/lac/vector_space_vector.h>
* regarding the order of the underlying index sets.
*/
class NoncontiguousPartitioner
- : public dealii::LinearAlgebra::CommunicationPatternBase
+ : public Utilities::MPI::CommunicationPatternBase
{
public:
/**
#include <deal.II/base/mpi_compute_index_owner_internal.h>
#include <deal.II/base/mpi_noncontiguous_partitioner.h>
-#include <deal.II/lac/communication_pattern_base.h>
#include <deal.II/lac/vector_space_vector.h>
#include <deal.II/base/config.h>
#include <deal.II/base/array_view.h>
+#include <deal.II/base/communication_pattern_base.h>
#include <deal.II/base/index_set.h>
#include <deal.II/base/memory_consumption.h>
#include <deal.II/base/memory_space.h>
#include <deal.II/base/types.h>
#include <deal.II/base/utilities.h>
-#include <deal.II/lac/communication_pattern_base.h>
#include <deal.II/lac/vector.h>
#include <deal.II/lac/vector_operation.h>
* detect this case and only send the selected indices, taken from the
* full array of ghost entries.
*/
- class Partitioner : public ::dealii::LinearAlgebra::CommunicationPatternBase
+ class Partitioner : public Utilities::MPI::CommunicationPatternBase
{
public:
/**
//
// ---------------------------------------------------------------------
-#ifndef dealii_communication_pattern_base_h
-#define dealii_communication_pattern_base_h
+#ifndef dealii_lac_communication_pattern_base_h
+#define dealii_lac_communication_pattern_base_h
-#include <deal.II/base/config.h>
-
-#include <deal.II/base/mpi.h>
+#include <deal.II/base/communication_pattern_base.h>
DEAL_II_NAMESPACE_OPEN
-// Forward declaration
-#ifndef DOXYGEN
-class IndexSet;
-#endif
+DEAL_II_WARNING(
+ "This file is deprecated. Use deal.II/base/communication_pattern_base.h instead!")
namespace LinearAlgebra
{
/**
- * CommunicationPattern is an abstract class that is used to define a
- * communication plan that can be called repeatedly to efficiently obtain
- * off-processor elements. The idea is to decouple the communication pattern
- * from the data that needs to be communicated. The goal is to reuse the same
- * communication pattern for different containers.
- * This is similar to the way SparseMatrix and SparsityPattern works.
+ * Alias for Utilities::MPI::CommunicationPatternBase. This class was
+ * originally defined in the LinearAlgebra namespace but is now used for more
+ * general purposes.
*/
- class CommunicationPatternBase
- {
- public:
- /**
- * Destructor.
- */
- virtual ~CommunicationPatternBase() = default;
-
- /**
- * Reinitialize the communication pattern. The first argument
- * `vector_space_vector_index_set` is the index set associated to a
- * VectorSpaceVector object. The second argument
- * `read_write_vector_index_set` is the index set associated to a
- * ReadWriteVector object.
- */
- virtual void
- reinit(const IndexSet &vector_space_vector_index_set,
- const IndexSet &read_write_vector_index_set,
- const MPI_Comm &communicator) = 0;
-
- /**
- * Return a constant reference to the underlying MPI communicator.
- */
- virtual const MPI_Comm &
- get_mpi_communicator() const = 0;
- };
-
+ using CommunicationPatternBase DEAL_II_DEPRECATED_EARLY =
+ Utilities::MPI::CommunicationPatternBase;
} // end of namespace LinearAlgebra
DEAL_II_NAMESPACE_CLOSE
#include <deal.II/base/config.h>
+#include <deal.II/base/communication_pattern_base.h>
#include <deal.II/base/exceptions.h>
#include <deal.II/base/index_set.h>
// Forward declarations
# ifndef DOXYGEN
-class CommunicationPatternBase;
template <typename Number>
class ReadWriteVector;
# endif
* copy a vector to the GPU.
*/
virtual void
- import(
- const ReadWriteVector<Number> & V,
- VectorOperation::values operation,
- std::shared_ptr<const CommunicationPatternBase> communication_pattern =
- std::shared_ptr<const CommunicationPatternBase>()) override;
+ import(const ReadWriteVector<Number> &V,
+ VectorOperation::values operation,
+ std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
+ communication_pattern = {}) override;
/**
* Sets all elements of the vector to the scalar @p s. This operation is
* improve performance.
*/
virtual void
- import(
- const LinearAlgebra::ReadWriteVector<Number> & V,
- VectorOperation::values operation,
- std::shared_ptr<const CommunicationPatternBase> communication_pattern =
- std::shared_ptr<const CommunicationPatternBase>()) override;
+ import(const LinearAlgebra::ReadWriteVector<Number> &V,
+ VectorOperation::values operation,
+ std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
+ communication_pattern = {}) override;
/**
* Return the scalar product of two vectors.
template <typename Number>
inline void
- BlockVector<Number>::import(const LinearAlgebra::ReadWriteVector<Number> &,
- VectorOperation::values,
- std::shared_ptr<const CommunicationPatternBase>)
+ BlockVector<Number>::import(
+ const LinearAlgebra::ReadWriteVector<Number> &,
+ VectorOperation::values,
+ std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>)
{
AssertThrow(false, ExcNotImplemented());
}
#include <deal.II/base/config.h>
+#include <deal.II/base/communication_pattern_base.h>
#include <deal.II/base/memory_space.h>
#include <deal.II/base/memory_space_data.h>
#include <deal.II/base/mpi.h>
* be moved to the device.
*/
virtual void
- import(
- const LinearAlgebra::ReadWriteVector<Number> & V,
- VectorOperation::values operation,
- std::shared_ptr<const CommunicationPatternBase> communication_pattern =
- std::shared_ptr<const CommunicationPatternBase>()) override;
+ import(const LinearAlgebra::ReadWriteVector<Number> &V,
+ VectorOperation::values operation,
+ std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
+ communication_pattern = {}) override;
/**
* Return the scalar product of two vectors.
template <typename Number, typename MemorySpaceType>
void
Vector<Number, MemorySpaceType>::import(
- const ReadWriteVector<Number> & V,
- VectorOperation::values operation,
- std::shared_ptr<const CommunicationPatternBase> communication_pattern)
+ const ReadWriteVector<Number> &V,
+ VectorOperation::values operation,
+ std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
+ communication_pattern)
{
// If no communication pattern is given, create one. Otherwise, use the
// given one.
* This function is not implemented and will throw an exception.
*/
virtual void
- import(
- const ReadWriteVector<Number> & V,
- VectorOperation::values operation,
- std::shared_ptr<const CommunicationPatternBase> communication_pattern =
- std::shared_ptr<const CommunicationPatternBase>()) override;
+ import(const ReadWriteVector<Number> &V,
+ VectorOperation::values operation,
+ std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
+ communication_pattern = {}) override;
/**
* Add @p a to all components. Note that @p a is a scalar not a vector.
template <typename Number>
void
- Vector<Number>::import(const ReadWriteVector<Number> &,
- VectorOperation::values,
- std::shared_ptr<const CommunicationPatternBase>)
+ Vector<Number>::import(
+ const ReadWriteVector<Number> &,
+ VectorOperation::values,
+ std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>)
{
AssertThrow(false, ExcMessage("This function is not implemented."));
}
#include <deal.II/base/config.h>
+#include <deal.II/base/communication_pattern_base.h>
#include <deal.II/base/index_set.h>
#include <deal.II/base/memory_consumption.h>
#include <deal.II/base/mpi.h>
#ifndef DOXYGEN
namespace LinearAlgebra
{
- class CommunicationPatternBase;
namespace distributed
{
template <typename, typename>
void
import(const distributed::Vector<Number, MemorySpace> &vec,
VectorOperation::values operation,
- const std::shared_ptr<const CommunicationPatternBase>
- &communication_pattern =
- std::shared_ptr<const CommunicationPatternBase>());
+ const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
+ &communication_pattern = {});
#ifdef DEAL_II_WITH_PETSC
/**
void
import(const PETScWrappers::MPI::Vector &petsc_vec,
VectorOperation::values operation,
- const std::shared_ptr<const CommunicationPatternBase>
- &communication_pattern =
- std::shared_ptr<const CommunicationPatternBase>());
+ const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
+ &communication_pattern = {});
#endif
#ifdef DEAL_II_WITH_TRILINOS
void
import(const TrilinosWrappers::MPI::Vector &trilinos_vec,
VectorOperation::values operation,
- const std::shared_ptr<const CommunicationPatternBase>
- &communication_pattern =
- std::shared_ptr<const CommunicationPatternBase>());
+ const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
+ &communication_pattern = {});
# ifdef DEAL_II_WITH_MPI
# ifdef DEAL_II_TRILINOS_WITH_TPETRA
void
import(const TpetraWrappers::Vector<Number> &tpetra_vec,
VectorOperation::values operation,
- const std::shared_ptr<const CommunicationPatternBase>
- &communication_pattern =
- std::shared_ptr<const CommunicationPatternBase>());
+ const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
+ &communication_pattern = {});
# endif
/**
void
import(const EpetraWrappers::Vector &epetra_vec,
VectorOperation::values operation,
- const std::shared_ptr<const CommunicationPatternBase>
- &communication_pattern =
- std::shared_ptr<const CommunicationPatternBase>());
+ const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
+ &communication_pattern = {});
# endif
#endif
void
import(const CUDAWrappers::Vector<Number> &cuda_vec,
VectorOperation::values operation,
- const std::shared_ptr<const CommunicationPatternBase>
- &communication_pattern =
- std::shared_ptr<const CommunicationPatternBase>());
+ const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
+ &communication_pattern = {});
#endif
/**
const IndexSet & locally_owned_elements,
VectorOperation::values operation,
const MPI_Comm & mpi_comm,
- const std::shared_ptr<const CommunicationPatternBase>
+ const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
&communication_pattern);
# endif
const IndexSet & locally_owned_elements,
VectorOperation::values operation,
const MPI_Comm & mpi_comm,
- const std::shared_ptr<const CommunicationPatternBase>
+ const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
&communication_pattern);
#endif
* CommunicationPattern for the communication between the
* source_stored_elements IndexSet and the current vector.
*/
- std::shared_ptr<CommunicationPatternBase> comm_pattern;
+ std::shared_ptr<Utilities::MPI::CommunicationPatternBase> comm_pattern;
/**
* Pointer to the array of local elements of this vector.
ReadWriteVector<Number>::import(
const distributed::Vector<Number, MemorySpace> &vec,
VectorOperation::values operation,
- const std::shared_ptr<const CommunicationPatternBase>
+ const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
&communication_pattern)
{
// If no communication pattern is given, create one. Otherwise, use the
ReadWriteVector<Number>::import(
const PETScWrappers::MPI::Vector &petsc_vec,
VectorOperation::values /*operation*/,
- const std::shared_ptr<const CommunicationPatternBase>
+ const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
& /*communication_pattern*/)
{
// TODO: this works only if no communication is needed.
const IndexSet & source_elements,
VectorOperation::values operation,
const MPI_Comm & mpi_comm,
- const std::shared_ptr<const CommunicationPatternBase>
+ const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
&communication_pattern)
{
std::shared_ptr<const TpetraWrappers::CommunicationPattern>
const IndexSet & source_elements,
VectorOperation::values operation,
const MPI_Comm & mpi_comm,
- const std::shared_ptr<const CommunicationPatternBase>
+ const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
&communication_pattern)
{
std::shared_ptr<const EpetraWrappers::CommunicationPattern>
ReadWriteVector<Number>::import(
const TrilinosWrappers::MPI::Vector &trilinos_vec,
VectorOperation::values operation,
- const std::shared_ptr<const CommunicationPatternBase>
+ const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
&communication_pattern)
{
// While the import does work with Trilinos 12.8.x, it fails with 12.4.x. To
ReadWriteVector<Number>::import(
const LinearAlgebra::TpetraWrappers::Vector<Number> &trilinos_vec,
VectorOperation::values operation,
- const std::shared_ptr<const CommunicationPatternBase>
+ const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
&communication_pattern)
{
import(trilinos_vec.trilinos_vector(),
ReadWriteVector<Number>::import(
const LinearAlgebra::EpetraWrappers::Vector &trilinos_vec,
VectorOperation::values operation,
- const std::shared_ptr<const CommunicationPatternBase>
+ const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
&communication_pattern)
{
import(trilinos_vec.trilinos_vector(),
ReadWriteVector<Number>::import(
const LinearAlgebra::CUDAWrappers::Vector<Number> &cuda_vec,
VectorOperation::values operation,
- const std::shared_ptr<const CommunicationPatternBase> &)
+ const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase> &)
{
const unsigned int n_elements = stored_elements.n_elements();
if (operation == VectorOperation::insert)
# ifdef DEAL_II_WITH_MPI
-# include <deal.II/lac/communication_pattern_base.h>
+# include <deal.II/base/communication_pattern_base.h>
# include <Epetra_Import.h>
{
/**
* This class implements a wrapper to a Trilinos Epetra_Import object,
- * for use in places where a CommunicationPatternBase object is required.
+ * for use in places where a Utilities::MPI::CommunicationPatternBase object
+ * is required.
*/
- class CommunicationPattern : public CommunicationPatternBase
+ class CommunicationPattern : public Utilities::MPI::CommunicationPatternBase
{
public:
/**
* improve performance.
*/
virtual void
- import(
- const ReadWriteVector<double> & V,
- VectorOperation::values operation,
- std::shared_ptr<const CommunicationPatternBase> communication_pattern =
- std::shared_ptr<const CommunicationPatternBase>()) override;
+ import(const ReadWriteVector<double> &V,
+ VectorOperation::values operation,
+ std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
+ communication_pattern = {}) override;
/**
* Multiply the entire vector by a fixed factor.
#if defined(DEAL_II_TRILINOS_WITH_TPETRA) && defined(DEAL_II_WITH_MPI)
-# include <deal.II/lac/communication_pattern_base.h>
+# include <deal.II/base/communication_pattern_base.h>
# include <Tpetra_Export.hpp>
# include <Tpetra_Import.hpp>
/**
* This class implements a wrapper to Tpetra::Import and Tpetra::Export.
*/
- class CommunicationPattern : public CommunicationPatternBase
+ class CommunicationPattern : public Utilities::MPI::CommunicationPatternBase
{
public:
/**
* improve performance.
*/
virtual void
- import(
- const ReadWriteVector<Number> & V,
- VectorOperation::values operation,
- std::shared_ptr<const CommunicationPatternBase> communication_pattern =
- std::shared_ptr<const CommunicationPatternBase>()) override;
+ import(const ReadWriteVector<Number> &V,
+ VectorOperation::values operation,
+ std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
+ communication_pattern = {}) override;
/**
* Multiply the entire vector by a fixed factor.
template <typename Number>
void
Vector<Number>::import(
- const ReadWriteVector<Number> & V,
- VectorOperation::values operation,
- std::shared_ptr<const CommunicationPatternBase> communication_pattern)
+ const ReadWriteVector<Number> &V,
+ VectorOperation::values operation,
+ std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
+ communication_pattern)
{
// If no communication pattern is given, create one. Otherwise, use the
// one given.
#include <deal.II/base/config.h>
+#include <deal.II/base/communication_pattern_base.h>
#include <deal.II/base/numbers.h>
#include <deal.II/lac/vector_operation.h>
class IndexSet;
namespace LinearAlgebra
{
- class CommunicationPatternBase;
template <typename Number>
class ReadWriteVector;
} // namespace LinearAlgebra
* performance.
*/
virtual void
- import(
- const ReadWriteVector<Number> & V,
- VectorOperation::values operation,
- std::shared_ptr<const CommunicationPatternBase> communication_pattern =
- std::shared_ptr<const CommunicationPatternBase>()) = 0;
+ import(const ReadWriteVector<Number> &V,
+ VectorOperation::values operation,
+ std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
+ communication_pattern = {}) = 0;
/**
* Return the scalar product of two vectors.
template <typename Number>
void
- Vector<Number>::import(const ReadWriteVector<Number> &V,
- VectorOperation::values operation,
- std::shared_ptr<const CommunicationPatternBase>)
+ Vector<Number>::import(
+ const ReadWriteVector<Number> &V,
+ VectorOperation::values operation,
+ std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>)
{
if (operation == VectorOperation::insert)
{
ReadWriteVector<float>::import(
const distributed::Vector<float, ::dealii::MemorySpace::Host> &,
VectorOperation::values,
- const std::shared_ptr<const CommunicationPatternBase> &);
+ const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase> &);
template void
ReadWriteVector<double>::import(
const distributed::Vector<double, ::dealii::MemorySpace::Host> &,
VectorOperation::values,
- const std::shared_ptr<const CommunicationPatternBase> &);
+ const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase> &);
# ifdef DEAL_II_WITH_COMPLEX_VALUES
template void
ReadWriteVector<std::complex<float>>::import(
const distributed::Vector<std::complex<float>, ::dealii::MemorySpace::Host>
&,
VectorOperation::values,
- const std::shared_ptr<const CommunicationPatternBase> &);
+ const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase> &);
template void
ReadWriteVector<std::complex<double>>::import(
const distributed::Vector<std::complex<double>, ::dealii::MemorySpace::Host>
&,
VectorOperation::values,
- const std::shared_ptr<const CommunicationPatternBase> &);
+ const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase> &);
# endif
#endif
} // namespace LinearAlgebra
ReadWriteVector<float>::import(
const CUDAWrappers::Vector<float> &,
VectorOperation::values,
- const std::shared_ptr<const CommunicationPatternBase> &);
+ const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase> &);
template void
ReadWriteVector<float>::import(
const distributed::Vector<float, ::dealii::MemorySpace::CUDA> &,
VectorOperation::values,
- const std::shared_ptr<const CommunicationPatternBase> &);
+ const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase> &);
template void
ReadWriteVector<double>::import(
const CUDAWrappers::Vector<double> &,
VectorOperation::values,
- const std::shared_ptr<const CommunicationPatternBase> &);
+ const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase> &);
template void
ReadWriteVector<double>::import(
const distributed::Vector<double, ::dealii::MemorySpace::CUDA> &,
VectorOperation::values,
- const std::shared_ptr<const CommunicationPatternBase> &);
+ const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase> &);
} // namespace LinearAlgebra
DEAL_II_NAMESPACE_CLOSE
void
Vector::import(
- const ReadWriteVector<double> & V,
- VectorOperation::values operation,
- std::shared_ptr<const CommunicationPatternBase> communication_pattern)
+ const ReadWriteVector<double> &V,
+ VectorOperation::values operation,
+ std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
+ communication_pattern)
{
// If no communication pattern is given, create one. Otherwise, use the
// one given.