137 const std::vector<std::vector<types::global_dof_index>> &indices,
146 template <
typename T>
150# ifndef DEAL_II_WITH_MPI
171 template <
typename T>
172 using get_mpi_communicator_t =
173 decltype(std::declval<T const>().get_mpi_communicator());
175 template <
typename T>
176 constexpr bool has_get_mpi_communicator =
177 ::internal::is_supported_operation<get_mpi_communicator_t, T>;
179 template <
typename T>
180 using local_size_t =
decltype(std::declval<T const>().local_size());
182 template <
typename T>
184 ::internal::is_supported_operation<local_size_t, T>;
187 std::enable_if_t<has_get_mpi_communicator<SparseMatrixType>,
196 std::enable_if_t<!has_get_mpi_communicator<SparseMatrixType>,
206 std::enable_if_t<has_local_size<SparseMatrixType>,
215 std::enable_if_t<!has_local_size<SparseMatrixType>,
227 template <
typename Number,
230 std::vector<std::vector<std::pair<types::global_dof_index, Number>>>
241 locally_owned_dofs.add_range(std::get<0>(
prefix_sum),
249 std::pair<types::global_dof_index, types::global_dof_index>>,
250 std::vector<unsigned int>>
254 using T1 = std::vector<
256 std::vector<std::pair<types::global_dof_index, Number>>>>;
258 auto requesters = process.get_requesters();
260 std::vector<std::vector<std::pair<types::global_dof_index, Number>>>
264 std::vector<unsigned int>
ranks;
265 ranks.reserve(requesters.size());
267 for (
const auto &i : requesters)
271 locally_owned_dofs.n_elements());
278 std::map<unsigned int, T1> data;
285 const auto row = locally_owned_dofs.nth_index_in_set(i);
286 auto entry = system_matrix.
begin(row);
288 const unsigned int row_length = sparsity_pattern.row_length(row);
292 std::vector<std::pair<types::global_dof_index, Number>>>
296 for (
unsigned int i = 0; i < row_length; ++i)
298 buffer.second.emplace_back(entry->column(), entry->value());
300 if (i + 1 != row_length)
304 for (
const auto &
proc :
309 ::Utilities::MPI::ConsensusAlgorithms::selector<T1>(
317 .index_within_set(i.first)];
319 std::sort(dst.begin(),
321 [](
const auto &a,
const auto &b) {
322 return a.first < b.first;
371 internal::extract_remote_rows<typename SparseMatrixType2::value_type>(
375 internal::get_mpi_communicator(system_matrix));
386 [](
const auto &a,
const auto &b) {
387 return a.size() < b.size();
394 std::vector<typename SparseMatrixType2::value_type>
temp_values;
483 const std::vector<std::vector<types::global_dof_index>> &indices,
487 const auto local_size = internal::get_local_size(system_matrix);
488 const auto prefix_sum = internal::compute_prefix_sum(
489 local_size, internal::get_mpi_communicator(system_matrix));
491 locally_owned_dofs.add_range(std::get<0>(
prefix_sum),
496 for (
const auto &i : indices)
515 internal::extract_remote_rows<Number>(system_matrix,
518 internal::get_mpi_communicator(
524 blocks.resize(indices.size());
526 for (
unsigned int c = 0; c < indices.size(); ++c)
528 if (indices[c].size() == 0)
531 const auto &local_dof_indices = indices[c];
535 const unsigned int dofs_per_cell = indices[c].size();
542 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
543 for (
unsigned int j = 0;
j < dofs_per_cell; ++
j)
545 if (locally_owned_dofs.is_element(
546 local_dof_indices[i]))
549 sparsity_pattern.exists(local_dof_indices[i],
550 local_dof_indices[
j]) ?
551 system_matrix(local_dof_indices[i],
552 local_dof_indices[
j]) :
563 local_dof_indices[i])];
568 std::pair<types::global_dof_index, Number>{
569 local_dof_indices[j], 0.0},
570 [](
const auto a,
const auto b) {
571 return a.first < b.first;
575 local_dof_indices[
j] == ptr->first)
598 all_dof_indices.resize(dof_handler.get_triangulation().n_active_cells());
600 for (
const auto &cell : dof_handler.active_cell_iterators())
602 if (cell->is_locally_owned() ==
false)
606 local_dof_indices.resize(cell->get_fe().n_dofs_per_cell());
607 cell->get_dof_indices(local_dof_indices);