20#include <boost/serialization/utility.hpp>
30 namespace ComputeIndexOwner
38 : use_vector(use_vector)
47 const std::size_t size)
65 const std::size_t start,
66 const std::size_t end,
74 if (
data.empty() && end > start)
85 std::fill(
data.begin() + start,
data.begin() + end, value);
93 std::fill(
data.begin() + start,
data.begin() + end, value);
98 for (
auto i = start; i < end; ++i)
175 std::map<
unsigned int,
186 owned_indices.
size(),
198 std::pair<types::global_dof_index, types::global_dof_index>
199 index_range(*interval->begin(), interval->last() + 1);
208 const unsigned int owner =
229 if (
owner == my_rank)
246#ifdef DEAL_II_WITH_MPI
248 std::vector<MPI_Request> request;
272 request.push_back(MPI_Request());
304 std::pair<types::global_dof_index, types::global_dof_index>>
315 for (
auto interval :
buffer)
350 std::pair<types::global_dof_index, types::global_dof_index>>;
352 ConsensusAlgorithms::selector<RequestType>(
355 std::vector<unsigned int>
targets;
356 targets.reserve(buffers.size());
372 for (
auto interval : request)
382 "Multiple processes seem to own the same global index. "
383 "A possible reason is that the sets of locally owned "
384 "indices are not distinct."));
385 Assert(interval.first < interval.second,
391 "The specified interval is not handled by the current process."));
414 if (request.size() > 0)
461 std::vector<unsigned int> &owning_ranks,
462 const bool track_index_requests)
463 : owned_indices(owned_indices)
464 , indices_to_look_up(indices_to_look_up)
468 , track_index_requests(track_index_requests)
469 , owning_ranks(owning_ranks)
486 for (
auto i = interval.first; i < interval.second; ++i)
502 std::vector<unsigned int>
505 std::vector<unsigned int>
targets;
508 unsigned int index = 0;
528 indices.first.push_back(i);
529 indices.second.push_back(index);
554 for (
auto interval =
is.begin_intervals();
555 interval !=
is.end_intervals();
557 send_buffer.emplace_back(*interval->begin(), interval->last() + 1);
567 const auto &recv_indices =
570 for (
unsigned int j = 0;
j < recv_indices.size(); ++
j)
576 std::map<unsigned int, IndexSet>
580 ExcMessage(
"Must enable index range tracking in "
581 "constructor of ConsensusAlgorithmProcess"));
585#ifdef DEAL_II_WITH_MPI
597 std::vector<MPI_Request> send_requests;
608 std::vector<std::vector<types::global_dof_index>> send_data(
610 for (
unsigned int i = 0; i <
requesters.size(); ++i)
621 for (
const auto &interval :
j.second)
630 send_data[i].push_back(
j.first);
631 send_data[i].push_back(
j.second.size());
632 for (
const auto &interval :
j.second)
634 send_data[i].push_back(interval.first);
635 send_data[i].push_back(interval.second);
638 send_requests.push_back(MPI_Request());
647 &send_requests.back());
664 Utilities::MPI::mpi_type_id_for_type<types::global_dof_index>,
671 std::pair<types::global_dof_index, types::global_dof_index>>
676 Utilities::MPI::mpi_type_id_for_type<types::global_dof_index>,
687 unsigned int offset = 0;
688 while (offset <
buffer.size())
694 for (
unsigned int i = offset + 1;
695 i < offset +
buffer[offset].second + 1;
704 if (index_set.
size() == 0)
708 offset +=
buffer[offset].second + 1;
713 if (send_requests.size() > 0)
716 send_requests.data(),
729 "The indices requested from the current "
730 "MPI rank should be locally owned here!"));
757 request.emplace_back(
760 std::pair<types::global_dof_index, types::global_dof_index>>());
762 auto &intervals = request.back().second;
766 ++intervals.back().second;
IntervalIterator end_intervals() const
size_type n_elements() const
void set_size(const size_type size)
IntervalIterator begin_intervals() const
void add_indices(const ForwardIterator &begin, const ForwardIterator &end)
const unsigned int my_rank
virtual std::vector< unsigned int > compute_targets() override
virtual void answer_request(const unsigned int other_rank, const std::vector< std::pair< types::global_dof_index, types::global_dof_index > > &buffer_recv, std::vector< unsigned int > &request_buffer) override
virtual void read_answer(const unsigned int other_rank, const std::vector< unsigned int > &recv_buffer) override
virtual void create_request(const unsigned int other_rank, std::vector< std::pair< types::global_dof_index, types::global_dof_index > > &send_buffer) override
std::vector< unsigned int > & owning_ranks
const IndexSet & indices_to_look_up
std::vector< std::vector< std::pair< unsigned int, std::vector< std::pair< types::global_dof_index, types::global_dof_index > > > > > requesters
std::map< unsigned int, std::pair< std::vector< types::global_dof_index >, std::vector< unsigned int > > > indices_to_look_up_by_dict_rank
const IndexSet & owned_indices
std::map< unsigned int, IndexSet > get_requesters()
ConsensusAlgorithmsPayload(const IndexSet &owned_indices, const IndexSet &indices_to_look_up, const MPI_Comm comm, std::vector< unsigned int > &owning_ranks, const bool track_index_requests=false)
void append_index_origin(const types::global_dof_index index_within_dictionary, const unsigned int rank_of_request, const unsigned int rank_of_owner, unsigned int &owner_index_guess)
const bool track_index_requests
index_type & operator[](const std::size_t index)
bool entry_has_been_set(const std::size_t index) const
void reinit(const bool use_vector, const bool index_range_contiguous, const std::size_t size)
FlexibleIndexStorage(const bool use_vector=true)
static const index_type invalid_index_value
void fill(const std::size_t start, const std::size_t end, const index_type &value)
std::map< std::size_t, index_type > data_map
std::vector< index_type > data
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
#define AssertThrowMPI(error_code)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
T sum(const T &t, const MPI_Comm mpi_communicator)
unsigned int n_mpi_processes(const MPI_Comm mpi_communicator)
unsigned int this_mpi_process(const MPI_Comm mpi_communicator)
const MPI_Datatype mpi_type_id_for_type
::VectorizedArray< Number, width > min(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
unsigned int global_dof_index
*braid_SplitCommworld & comm
std::vector< unsigned int > actually_owning_rank_list
FlexibleIndexStorage actually_owning_ranks
unsigned int dof_to_dict_rank(const types::global_dof_index i)
types::global_dof_index get_index_offset(const unsigned int rank)
types::global_dof_index locally_owned_size
types::global_dof_index dofs_per_process
unsigned int n_dict_procs_in_owned_indices
static constexpr unsigned int sparsity_factor
unsigned int stride_small_size
static constexpr unsigned int range_minimum_grain_size
std::pair< types::global_dof_index, types::global_dof_index > local_range
void reinit(const IndexSet &owned_indices, const MPI_Comm comm)
void partition(const IndexSet &owned_indices, const MPI_Comm comm)
unsigned int get_owning_rank_index(const unsigned int rank_in_owned_indices, const unsigned int guess=0)
types::global_dof_index size
#define DEAL_II_DOF_INDEX_MPI_TYPE