]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix some bugs related to coarsening when only one level of cells is present.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 3 Aug 1998 08:01:13 +0000 (08:01 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 3 Aug 1998 08:01:13 +0000 (08:01 +0000)
git-svn-id: https://svn.dealii.org/trunk@468 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/source/grid/tria.cc

index 8137c2c9ed22d63f4b6d0c3ea6cc82ce05d9af64..6c1158a7526a3a40b3c81d5410e34db3df0c62b0 100644 (file)
@@ -2979,11 +2979,15 @@ void Triangulation<dim>::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<dim>::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<GeometryInfo<dim>::children_per_cell; ++child)
-               for (unsigned int neighbor=0;
-                    neighbor<GeometryInfo<dim>::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<GeometryInfo<dim>::children_per_cell; ++child)
+                 for (unsigned int neighbor=0;
+                      neighbor<GeometryInfo<dim>::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);
     };

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.