From: Wolfgang Bangerth Date: Fri, 14 Aug 1998 12:23:03 +0000 (+0000) Subject: Change some things in the implementation of the grid smoothing algorithms. X-Git-Tag: v8.0.0~22770 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b5fd6403013949ca5c91d5166b6b45cbd42c06f;p=dealii.git Change some things in the implementation of the grid smoothing algorithms. git-svn-id: https://svn.dealii.org/trunk@484 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/grid/tria.h b/deal.II/deal.II/include/grid/tria.h index b86d428be4..66fc1c1bfc 100644 --- a/deal.II/deal.II/include/grid/tria.h +++ b/deal.II/deal.II/include/grid/tria.h @@ -689,17 +689,22 @@ class TriaDimensionInfo<2> { * the author by now. * * \item #eliminate_refined_islands#: - * This algorithm seeks for isolated cells which are refined. An - * island is defined similar as above, i.e. a cell is flagged for coarsening - * if it is refined but more of its neighbors are not refined than are - * refined. For example, in 2D, a cell's refinement is reverted if at most + * This algorithm seeks for isolated cells which are refined or flagged + * for refinement. This definition is unlike that for + * #eliminate_unrefined_islands#, which would mean that an island is + * defined as a cell which + * is refined but more of its neighbors are not refined than are refined. + * For example, in 2D, a cell's refinement would be reverted if at most * one of its neighbors is also refined (or refined but flagged for - * coarsening). This option is a bit dangerous, since if you consider a + * coarsening). + * + * The reason for the change in definition of an island is, that this + * option would be a bit dangerous, since if you consider a * chain of refined cells (e.g. along a kink in the solution), the cells - * at the two ends will be coarsened, after which the next outermost cells + * at the two ends would be coarsened, after which the next outermost cells * would need to be coarsened. Therefore, only one loop of flagging cells - * like this is done to avoid eating up the whole chain of refined cells - * (`chain reaction'...). + * like this could be done to avoid eating up the whole chain of refined + * cells (`chain reaction'...). * * This algorithm also takes into account cells which are not actually * refined but are flagged for refinement. If necessary, it takes away the @@ -966,8 +971,7 @@ class TriaDimensionInfo<2> { * a cell is flagged for refinement or if all of its children are active * and if the number of neighbors which are either active and not flagged * for refinement, or not active but all children flagged for coarsening - * exceeds the number of other neighbors, or the neighbor's refinement - * level is less than the present cell's level, then this cell's children + * equals the total number of neighbors, then this cell's children * are flagged for coarsening or (if this cell was flagged for refinement) * the refine flag is cleared. * diff --git a/deal.II/deal.II/source/grid/tria.cc b/deal.II/deal.II/source/grid/tria.cc index f90cb00deb..57fe54ac1e 100644 --- a/deal.II/deal.II/source/grid/tria.cc +++ b/deal.II/deal.II/source/grid/tria.cc @@ -2999,6 +2999,7 @@ void Triangulation::execute_coarsening () { + template bool Triangulation::prepare_refinement () { bool cells_changed = false; @@ -3149,6 +3150,7 @@ bool Triangulation::prepare_refinement () { + template bool Triangulation::prepare_coarsening () { // checking whether the coarsen flags @@ -3259,12 +3261,16 @@ bool Triangulation::prepare_coarsening () { // are counted as unrefined since // they can only get to the same // level as this cell by the - // next refinement cycle - unsigned int refined_neighbors = 0, - unrefined_neighbors = 0; + // next refinement cycle + unsigned int unrefined_neighbors = 0, + total_neighbors = 0; + for (unsigned int n=0; n::faces_per_cell; ++n) { const cell_iterator neighbor = cell->neighbor(n); + if (neighbor.state() == valid) + ++total_neighbors; + if (neighbor.state() == valid) if ((neighbor->active() && !neighbor->refine_flag_set()) || @@ -3272,20 +3278,17 @@ bool Triangulation::prepare_coarsening () { neighbor->user_flag_set()) || // marked for coarsening (neighbor->level() == cell->level()-1)) ++unrefined_neighbors; - else - ++refined_neighbors; }; - // if the number of unrefined - // neighbors exceed that of the - // refined neighbors: mark this + // if all neighbors unrefined: + // mark this // cell for coarsening or don't // refine if marked for that - if (refined_neighborsactive()) cell->set_user_flag(); - else + else cell->clear_refine_flag(); }; }; @@ -3358,7 +3361,11 @@ bool Triangulation::prepare_coarsening () { { cell->clear_user_flag(); for (unsigned int c=0; c::children_per_cell; ++c) - cell->child(c)->set_coarsen_flag(); + { + if (cell->child(c)->refine_flag_set()) + cell->child(c)->clear_refine_flag(); + cell->child(c)->set_coarsen_flag(); + }; };