136 const std::vector<std::vector<types::global_dof_index>> &indices,
145 template <
typename T>
146 using get_mpi_communicator_t =
147 decltype(std::declval<const T>().get_mpi_communicator());
149 template <
typename T>
150 constexpr bool has_get_mpi_communicator =
151 ::internal::is_supported_operation<get_mpi_communicator_t, T>;
153 template <
typename T>
154 using local_size_t =
decltype(std::declval<const T>().local_size());
156 template <
typename T>
158 ::internal::is_supported_operation<local_size_t, T>;
161 std::enable_if_t<has_get_mpi_communicator<SparseMatrixType>,
170 std::enable_if_t<!has_get_mpi_communicator<SparseMatrixType>,
180 std::enable_if_t<has_local_size<SparseMatrixType>,
189 std::enable_if_t<!has_local_size<SparseMatrixType>,
201 template <
typename Number,
204 std::vector<std::vector<std::pair<types::global_dof_index, Number>>>
218 using T1 = std::vector<
220 std::vector<std::pair<types::global_dof_index, Number>>>>;
228 std::vector<std::vector<std::pair<types::global_dof_index, Number>>>
232 std::vector<unsigned int>
ranks;
239 locally_owned_dofs.n_elements());
246 std::map<unsigned int, T1>
data;
249 std::vector<std::pair<types::global_dof_index, Number>>>
257 const auto row = locally_owned_dofs.nth_index_in_set(i);
258 auto entry = system_matrix.begin(row);
260 const unsigned int row_length = sparsity_pattern.row_length(row);
263 buffer.second.resize(row_length);
265 for (
unsigned int j = 0;
j < row_length; ++
j, ++entry)
266 buffer.second[
j] = {entry->column(), entry->value()};
272 ::Utilities::MPI::ConsensusAlgorithms::selector<T1>(
280 .index_within_set(i.first)];
282 std::sort(dst.begin(),
284 [](
const auto &a,
const auto &b) {
285 return a.first < b.first;
334 internal::extract_remote_rows<typename SparseMatrixType2::value_type>(
338 internal::get_mpi_communicator(system_matrix));
349 [](
const auto &a,
const auto &b) {
350 return a.size() < b.size();
357 std::vector<typename SparseMatrixType2::value_type>
temp_values;
446 const std::vector<std::vector<types::global_dof_index>> &indices,
450 const auto local_size = internal::get_local_size(system_matrix);
452 local_size, internal::get_mpi_communicator(system_matrix));
454 locally_owned_dofs.add_range(std::get<0>(
prefix_sum),
459 for (
const auto &i : indices)
474 internal::extract_remote_rows<Number>(system_matrix,
477 internal::get_mpi_communicator(
483 blocks.resize(indices.size());
485 for (
unsigned int c = 0; c < indices.size(); ++c)
487 if (indices[c].empty())
490 const auto &local_dof_indices = indices[c];
494 const unsigned int dofs_per_cell = indices[c].size();
501 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
502 for (
unsigned int j = 0;
j < dofs_per_cell; ++
j)
504 if (locally_owned_dofs.is_element(
505 local_dof_indices[i]))
508 sparsity_pattern.exists(local_dof_indices[i],
509 local_dof_indices[
j]) ?
510 system_matrix(local_dof_indices[i],
511 local_dof_indices[
j]) :
522 local_dof_indices[i])];
527 std::pair<types::global_dof_index, Number>{
528 local_dof_indices[j], 0.0},
529 [](
const auto a,
const auto b) {
530 return a.first < b.first;
534 local_dof_indices[
j] == ptr->first)
557 all_dof_indices.resize(dof_handler.get_triangulation().n_active_cells());
559 for (
const auto &cell : dof_handler.active_cell_iterators())
561 if (cell->is_locally_owned() ==
false)
565 local_dof_indices.resize(cell->get_fe().n_dofs_per_cell());
566 cell->get_dof_indices(local_dof_indices);