From: Martin Kronbichler Date: Fri, 7 May 2021 21:18:25 +0000 (+0200) Subject: p:f:Tria: Fix bug when a process does not own cells on a level X-Git-Tag: v9.3.0-rc1~116^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2071274927364190b07fc3bc6a6da9e2c5a6be86;p=dealii.git p:f:Tria: Fix bug when a process does not own cells on a level --- diff --git a/source/distributed/fully_distributed_tria.cc b/source/distributed/fully_distributed_tria.cc index 802d8b5996..ca160614c8 100644 --- a/source/distributed/fully_distributed_tria.cc +++ b/source/distributed/fully_distributed_tria.cc @@ -184,7 +184,9 @@ namespace parallel } // 4b) set actual (level_)subdomain_ids - for (unsigned int level = 0; level < cell_infos.size(); ++level) + for (unsigned int level = 0; + level < cell_infos.size() && !cell_infos[level].empty(); + ++level) { auto cell = this->begin(level); auto cell_info = cell_infos[level].begin(); diff --git a/source/grid/tria.cc b/source/grid/tria.cc index 2f737a0bb4..d7900e35c1 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -10660,8 +10660,12 @@ Triangulation::create_triangulation( return a_id < b_id; }); - // 2) create all levels via a sequence of refinements - for (unsigned int level = 0; level < cell_infos.size(); ++level) + // 2) create all levels via a sequence of refinements. note that + // we must make sure that we actually have cells on this level, + // which is not clear in a parallel context for some processes + for (unsigned int level = 0; + level < cell_infos.size() && !cell_infos[level].empty(); + ++level) { // a) set manifold ids here (because new vertices have to be // positioned correctly during each refinement step) @@ -10714,7 +10718,9 @@ Triangulation::create_triangulation( } // 3) set boundary ids - for (unsigned int level = 0; level < cell_infos.size(); ++level) + for (unsigned int level = 0; + level < cell_infos.size() && !cell_infos[level].empty(); + ++level) { auto cell = this->begin(level); auto cell_info = cell_infos[level].begin();