From 9b249238b4d374118e93aa693b651ef1791f0ebf Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Thu, 6 Aug 2015 10:07:00 -0500 Subject: [PATCH] fix Tria::has_hanging_nodes - Avoid using MPI::Bool (requires c++ mpi) - do not use MPI commands directly - clean up code, document more --- source/distributed/tria.cc | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/source/distributed/tria.cc b/source/distributed/tria.cc index adf3ead236..327926340d 100644 --- a/source/distributed/tria.cc +++ b/source/distributed/tria.cc @@ -2612,26 +2612,27 @@ namespace parallel bool Triangulation::has_hanging_nodes () const { + if (n_global_levels()<=1) + return false; // can not have hanging nodes without refined cells + // if there are any active cells with level less than n_global_levels()-1, then // there is obviously also one with level n_global_levels()-1, and // consequently there must be a hanging node somewhere. // - // the problem is that we cannot just ask for the first active cell, but - // instead need to filter over locally owned cells - bool res_local = false; - for (typename Triangulation::active_cell_iterator cell = this->begin_active(); - (cell != this->end()) && (cell->level() < (int)(n_global_levels()-1)); - cell++) + // The problem is that we cannot just ask for the first active cell, but + // instead need to filter over locally owned cells. + bool have_coarser_cell = false; + for (typename Triangulation::active_cell_iterator cell = this->begin_active(n_global_levels()-2); + cell != this->end(n_global_levels()-2); + ++cell) if (cell->is_locally_owned()) { - res_local = true; + have_coarser_cell = true; break; } - // reduce over MPI - bool res; - MPI_Allreduce(&res_local, &res, 1, MPI::BOOL, MPI_LOR, mpi_communicator); - return res; + // return true if at least one process has a coarser cell + return 0