From 31e0da5cc0133f312ce5dd57d2945edae9f6a82c Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Wed, 19 Feb 2020 11:40:08 -0500 Subject: [PATCH] Slight improvements to #9529 --- doc/news/changes/minor/20200214KatrinMang | 4 ++-- include/deal.II/base/index_set.h | 8 +++++--- source/base/index_set.cc | 12 ++++++------ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/doc/news/changes/minor/20200214KatrinMang b/doc/news/changes/minor/20200214KatrinMang index 4966c6c58a..b9180df43f 100644 --- a/doc/news/changes/minor/20200214KatrinMang +++ b/doc/news/changes/minor/20200214KatrinMang @@ -1,4 +1,4 @@ -New: An IndexSet::split_by_block() function is added which partitions the set indices for example based on a block structure into blocks. -IndexSet should be defined with respect to the global block structure. In particular, dofs_per_block should be defined consistently across MPI ranks. +New: An IndexSet::split_by_block() function is added which partitions the set +indices, for example based on a block structure, into blocks.
(Katrin Mang, 2020/02/14) diff --git a/include/deal.II/base/index_set.h b/include/deal.II/base/index_set.h index ca00bf3288..d4af23963f 100644 --- a/include/deal.II/base/index_set.h +++ b/include/deal.II/base/index_set.h @@ -345,12 +345,14 @@ public: get_view(const size_type begin, const size_type end) const; /** - * Split the set indices represented by this object into blocks - * given by the @p dofs_per_block structure. + * Split the set indices represented by this object into blocks given by the + * @p n_indices_per_block structure. The sum of its entries must match the + * global size of the current object. + * */ std::vector split_by_block( - const std::vector &dofs_per_block) const; + const std::vector &n_indices_per_block) const; /** * Remove all elements contained in @p other from this set. In other words, diff --git a/source/base/index_set.cc b/source/base/index_set.cc index 67892e6482..089fd80b7f 100644 --- a/source/base/index_set.cc +++ b/source/base/index_set.cc @@ -234,18 +234,18 @@ IndexSet::get_view(const size_type begin, const size_type end) const std::vector IndexSet::split_by_block( - const std::vector &dofs_per_block) const + const std::vector &n_indices_per_block) const { std::vector partitioned; - const unsigned int n_block_dofs = dofs_per_block.size(); + const unsigned int n_blocks = n_indices_per_block.size(); - partitioned.reserve(n_block_dofs); + partitioned.reserve(n_blocks); types::global_dof_index start = 0; types::global_dof_index sum = 0; - for (const auto n_block_dofs : dofs_per_block) + for (const auto n_block_indices : n_indices_per_block) { - partitioned.push_back(this->get_view(start, start + n_block_dofs)); - start += n_block_dofs; + partitioned.push_back(this->get_view(start, start + n_block_indices)); + start += n_block_indices; sum += partitioned.back().size(); } AssertDimension(sum, this->size()); -- 2.39.5