New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert a few more locally-owned loops with filters. #13073
Conversation
source/distributed/shared_tria.cc
Outdated
IteratorFilters::LocallyOwnedCell()) | ||
{ | ||
(void)cell; | ||
++n_my_cells; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is disappointing that one has to give the loop variable a name, but that appears to be the case based on the standard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be more elegant to use std::count_if
here (and below)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or use what you did above in source/distributed/repartitioning_policy_tools.cc
.
const auto locally_owned_cells =
tria_in.active_cell_iterators() | IteratorFilters::LocallyOwnedCell();
const unsigned int n_locally_owned_active_cells =
std::distance(locally_owned_cells.begin(), locally_owned_cells.end());
source/distributed/tria_base.cc
Outdated
for (const auto &cell : this->active_cell_iterators() | | ||
IteratorFilters::SubdomainEqualTo(my_subdomain)) | ||
{ | ||
(void)cell; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above
source/distributed/tria.cc
Outdated
@@ -22,6 +22,7 @@ | |||
#include <deal.II/distributed/p4est_wrappers.h> | |||
#include <deal.II/distributed/tria.h> | |||
|
|||
#include <deal.II/grid/filtered_iterator.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't look like you need it here?
#include <deal.II/grid/filtered_iterator.h> |
source/distributed/shared_tria.cc
Outdated
for (const auto &cell : this->cell_iterators() | | ||
IteratorFilters::LocallyOwnedLevelCell()) | ||
{ | ||
(void)cell; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above
source/distributed/shared_tria.cc
Outdated
IteratorFilters::LocallyOwnedCell()) | ||
{ | ||
(void)cell; | ||
++n_my_cells; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or use what you did above in source/distributed/repartitioning_policy_tools.cc
.
const auto locally_owned_cells =
tria_in.active_cell_iterators() | IteratorFilters::LocallyOwnedCell();
const unsigned int n_locally_owned_active_cells =
std::distance(locally_owned_cells.begin(), locally_owned_cells.end());
source/grid/grid_tools_cache.cc
Outdated
@@ -156,10 +156,10 @@ namespace GridTools | |||
typename Triangulation<dim, spacedim>::active_cell_iterator>> | |||
boxes; | |||
boxes.reserve(tria->n_active_cells()); | |||
for (const auto &cell : tria->active_cell_iterators()) | |||
for (const auto &cell : tria->active_cell_iterators() | | |||
IteratorFilters::LocallyOwnedCell()) | |||
if (cell->is_locally_owned()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need this anymore I guess.
if (cell->is_locally_owned()) |
Ah yes, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty cool :-)
@@ -19,6 +19,7 @@ | |||
|
|||
#include <deal.II/distributed/fully_distributed_tria.h> | |||
|
|||
#include <deal.II/grid/filtered_iterator.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look as if IteratorFilters
are used in this file?
source/distributed/tria_base.cc
Outdated
// It is very unlikely that a single process has more than 2 billion | ||
// cells, but we might as well check. | ||
// It is very unlikely that a single process has more than 2 | ||
// billion cells, but we might as well check. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're going to push "billon" onto the next line, then maybe it makes sense to move the number "2" as well.
Adjusted as requested! |
Seems to work now! @marcfehling You put the block on this PR. Want to take another look? |
Ping? |
Ping? (@marcfehling had the last set of comments that created a hold on the PR.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late feedback. Forgot about this open PR over the holidays.
const auto locally_owned_cells = | ||
tria_in.active_cell_iterators() | IteratorFilters::LocallyOwnedCell(); | ||
const unsigned int n_locally_owned_active_cells = | ||
std::distance(locally_owned_cells.begin(), locally_owned_cells.end()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want, you can use std::count_if
here, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, so done!
++n_locally_owned_active_cells; | ||
const unsigned int n_locally_owned_active_cells = | ||
std::count_if(tria_in.begin_active(), | ||
tria_in.end(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tria_in.end(), | |
typename Triangulation<dim, spacedim>::active_cell_iterator( | |
tria_in.end()), |
This should fix the compiler problem
/home/runner/work/dealii/dealii/source/distributed/repartitioning_policy_tools.cc:210:20: note: deduced conflicting types for parameter ‘_IIter’ (‘dealii::TriaActiveIterator<dealii::CellAccessor<1, 1> >’ and ‘dealii::TriaIterator<dealii::CellAccessor<1, 1> >’)
Another follow-up to #12952.
/rebuild