--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 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_la_sm_partitioner_h
+#define dealii_la_sm_partitioner_h
+
+
+#include <deal.II/base/config.h>
+
+#include <deal.II/lac/communication_pattern_base.h>
+
+DEAL_II_NAMESPACE_OPEN
+
+
+namespace LinearAlgebra
+{
+ namespace SharedMPI
+ {
+ template <typename Number = double>
+ class Partitioner : public LinearAlgebra::CommunicationPatternBase
+ {
+ public:
+ Partitioner(const MPI_Comm &comm, const MPI_Comm &comm_sm)
+ : comm(comm)
+ , comm_sm(comm_sm)
+ {}
+
+ const MPI_Comm &
+ get_mpi_communicator() const override
+ {
+ return comm;
+ }
+
+ void
+ reinit(const IndexSet &indexset_has,
+ const IndexSet &indexset_want,
+ const MPI_Comm &communicator) override
+ {
+ (void)indexset_has;
+ (void)indexset_want;
+ (void)communicator;
+ }
+
+ private:
+ const MPI_Comm &comm;
+ const MPI_Comm &comm_sm;
+ };
+
+ } // end of namespace SharedMPI
+} // end of namespace LinearAlgebra
+
+
+DEAL_II_NAMESPACE_CLOSE
+
+#endif
\ No newline at end of file
#include <deal.II/base/partitioner.h>
#include <deal.II/base/thread_management.h>
+#include <deal.II/lac/la_sm_partitioner.h>
#include <deal.II/lac/vector_operation.h>
#include <deal.II/lac/vector_space_vector.h>
#include <deal.II/lac/vector_type_traits.h>
void
reinit(
- const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner);
+ const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner,
+ const std::shared_ptr<const Partitioner<Number>> &partitioner_sm);
void
swap(Vector<Number, MemorySpace> &v);
std::shared_ptr<const Utilities::MPI::Partitioner> partitioner;
+ std::shared_ptr<const Partitioner<Number>> partitioner_sm;
+
size_type allocated_size;
mutable MemorySpaceData<Number> data;
//
// ---------------------------------------------------------------------
-#ifndef dealii_la_parallel_vector_templates_h
-#define dealii_la_parallel_vector_templates_h
+#ifndef dealii_la_sm_vector_templates_h
+#define dealii_la_sm_vector_templates_h
#include <deal.II/base/config.h>
template <typename Number, typename MemorySpaceType>
void
Vector<Number, MemorySpaceType>::reinit(
- const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner_in)
+ const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner,
+ const std::shared_ptr<const Partitioner<Number>> & partitioner_sm)
{
clear_mpi_requests();
- partitioner = partitioner_in;
+ this->partitioner = partitioner;
+ this->partitioner_sm = partitioner_sm;
// set vector size and allocate memory
const size_type new_allocated_size =
- partitioner->local_size() + partitioner->n_ghost_indices();
+ this->partitioner->local_size() + this->partitioner->n_ghost_indices();
resize_val(new_allocated_size);
// initialize to zero
#include <deal.II/lac/affine_constraints.h>
#include <deal.II/lac/block_vector_base.h>
#include <deal.II/lac/la_parallel_vector.h>
+#include <deal.II/lac/la_sm_partitioner.h>
#include <deal.II/lac/la_sm_vector.h>
#include <deal.II/lac/vector_operation.h>
template <typename Number2>
void
initialize_dof_vector(LinearAlgebra::SharedMPI::Vector<Number2> &vec,
+ const MPI_Comm comm_sm,
const unsigned int dof_handler_index = 0) const;
/**
*/
std::vector<internal::MatrixFreeFunctions::DoFInfo> dof_info;
+ // TODO: move it to DoFInfo
+ mutable std::map<
+ unsigned int,
+ std::map<
+ const MPI_Comm,
+ std::shared_ptr<const LinearAlgebra::SharedMPI::Partitioner<Number>>>>
+ partitioner_sm;
+
/**
* Contains the weights for constraints stored in DoFInfo. Filled into a
* separate field since several vector components might share similar
inline void
MatrixFree<dim, Number, VectorizedArrayType>::initialize_dof_vector(
LinearAlgebra::SharedMPI::Vector<Number2> &vec,
+ const MPI_Comm comm_sm,
const unsigned int comp) const
{
AssertIndexRange(comp, n_components());
- vec.reinit(dof_info[comp].vector_partitioner);
+
+ if (partitioner_sm[comp][comm_sm] == nullptr)
+ partitioner_sm[comp][comm_sm] =
+ std::make_shared<LinearAlgebra::SharedMPI::Partitioner<Number>>(
+ dof_info[comp].vector_partitioner->get_communicator(), comm_sm);
+
+ vec.reinit(dof_info[comp].vector_partitioner, partitioner_sm[comp][comm_sm]);
}
dealii::MatrixFree<dim, Number> matrix_free;
matrix_free.reinit(mapping, dof_handler, constraint, quad, additional_data);
+ MPI_Comm comm_sm;
+
LinearAlgebra::SharedMPI::Vector<Number> vec;
- matrix_free.initialize_dof_vector(vec);
+ matrix_free.initialize_dof_vector(vec, comm_sm);
}
int