From 2071274927364190b07fc3bc6a6da9e2c5a6be86 Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Fri, 7 May 2021 23:18:25 +0200 Subject: [PATCH] p:f:Tria: Fix bug when a process does not own cells on a level --- source/distributed/fully_distributed_tria.cc | 4 +++- source/grid/tria.cc | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) 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(); -- 2.39.5