From df10e8af66e923bce8b3cdc2193dc43a40a18a2d Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 3 Aug 1998 08:01:13 +0000 Subject: [PATCH] Fix some bugs related to coarsening when only one level of cells is present. git-svn-id: https://svn.dealii.org/trunk@468 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/source/grid/tria.cc | 65 ++++++++++++++++------------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/deal.II/deal.II/source/grid/tria.cc b/deal.II/deal.II/source/grid/tria.cc index 8137c2c9ed..6c1158a752 100644 --- a/deal.II/deal.II/source/grid/tria.cc +++ b/deal.II/deal.II/source/grid/tria.cc @@ -2979,11 +2979,15 @@ void Triangulation::execute_coarsening () { // delete some cells if their neighbors // have already been deleted (if the latter // are on a higher level for example) - for (cell = last(levels.size()-2); cell!=endc; --cell) - if (cell->user_flag_set()) - // use a separate function, since this - // is dimension specific - delete_cell (cell); + // + // if there is only one level, there can not + // be anything to do + if (levels.size() >= 2) + for (cell = last(levels.size()-2); cell!=endc; --cell) + if (cell->user_flag_set()) + // use a separate function, since this + // is dimension specific + delete_cell (cell); // in principle no user flags should be // set any more at this point #if DEBUG @@ -3318,31 +3322,32 @@ bool Triangulation::prepare_coarsening () { // are only set for refined flags // which do not exist on the // highest level. - for (cell=last(levels.size()-2); cell!=endc; --cell) - if (cell->user_flag_set()) - // cell is flagged for coarsening - for (unsigned int child=0; - child::children_per_cell; ++child) - for (unsigned int neighbor=0; - neighbor::faces_per_cell; ++neighbor) - // for all neighbors of all - // children: if they are - // refined more often than - // the child and are not - // flagged for coarsening, - // we can't coarsen this cell - { - cell_iterator child_neighbor = cell->child(child)-> - neighbor(neighbor); - if ((child_neighbor.state() == valid) && - (child_neighbor->level() == cell->level()+1) && - (child_neighbor->active() == false) && - (child_neighbor->user_flag_set() == false)) - { - cell->clear_user_flag(); - flags_changed_in_this_loop = true; - }; - }; + if (levels.size()>=2) + for (cell=last(levels.size()-2); cell!=endc; --cell) + if (cell->user_flag_set()) + // cell is flagged for coarsening + for (unsigned int child=0; + child::children_per_cell; ++child) + for (unsigned int neighbor=0; + neighbor::faces_per_cell; ++neighbor) + // for all neighbors of all + // children: if they are + // refined more often than + // the child and are not + // flagged for coarsening, + // we can't coarsen this cell + { + cell_iterator child_neighbor = cell->child(child)-> + neighbor(neighbor); + if ((child_neighbor.state() == valid) && + (child_neighbor->level() == cell->level()+1) && + (child_neighbor->active() == false) && + (child_neighbor->user_flag_set() == false)) + { + cell->clear_user_flag(); + flags_changed_in_this_loop = true; + }; + }; } while (flags_changed_in_this_loop); }; -- 2.39.5