]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix the mesh_smoothing_0[12] testcases. A description of the problem is found in...
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 18 Aug 2008 21:58:07 +0000 (21:58 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 18 Aug 2008 21:58:07 +0000 (21:58 +0000)
git-svn-id: https://svn.dealii.org/trunk@16591 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/source/grid/tria.cc
tests/deal.II/Makefile
tests/deal.II/mesh_smoothing_01.cc [moved from tests/fail/mesh_smoothing_01.cc with 100% similarity]
tests/deal.II/mesh_smoothing_01/cmp/generic [new file with mode: 0644]
tests/deal.II/mesh_smoothing_02.cc [moved from tests/fail/mesh_smoothing_02.cc with 100% similarity]
tests/deal.II/mesh_smoothing_02/cmp/generic [new file with mode: 0644]

index 94c66adf2b2568aed59ac5ab30194f2db2df7380..7e06e88d63e04d6cf65ef1d1e5612357d9bfb200 100644 (file)
@@ -11213,93 +11213,162 @@ bool Triangulation<dim>::prepare_coarsening_and_refinement ()
                    }
              }
 
-                                          // Loop over all patches of
-                                          // level 2, i.e. over all
-                                          // cells whose
-                                          // grandchildren are all
-                                          // active.  Coarsen the
-                                          // children (and remove the
+                                          // The code above dealt
+                                          // with the case where we
+                                          // may get a
+                                          // non-patch_level_1 mesh
+                                          // from refinement. Now
+                                          // also deal with the case
+                                          // where we could get such
+                                          // a mesh by coarsening.
+                                          // Coarsen the children
+                                          // (and remove the
                                           // grandchildren) only if
                                           // all cell->grandchild(i)
-                                          //       ->coarsen_flag_set()
+                                          //   ->coarsen_flag_set()
                                           // are set.
-         for (cell_iterator cell = begin(); cell != end(); ++cell)         
-           if (!cell->active() &&
-               !cell->child(0)->active() &&
-               cell->child(0)->child(0)->active())
-             {
-               const unsigned int n_children=cell->n_children();
-               unsigned int n_grandchildren=0;         
-                                                // count all coarsen
-                                                // flags of the
-                                                // grandchildren.
-               unsigned int n_coarsen_flags=0;
-                                                // cell is not a
-                                                // patch (of level 1)
-                                                // as it has a
-                                                // grandchild.  Is
-                                                // cell a patch of
-                                                // level 2??
-                                                // Therefore: find
-                                                // out whether all
-                                                // cell->child(i) are
-                                                // patches
-               for (unsigned int c=0; c<n_children; ++c)
+                                          //
+                                          // for a case where this is
+                                          // a bit tricky, take a
+                                          // look at the
+                                          // mesh_smoothing_0[12]
+                                          // testcases
+         for (cell_iterator cell = begin(); cell != end(); ++cell)
+           {
+                                              // check if this cell
+                                              // has active
+                                              // grandchildren. note
+                                              // that we know that it
+                                              // is patch_level_1,
+                                              // i.e. if one of its
+                                              // children is active
+                                              // then so are all, and
+                                              // it isn't going to
+                                              // have any
+                                              // grandchildren at
+                                              // all:
+             if (cell->active()
+                 ||
+                 cell->child(0)->active())
+               continue;
+
+                                              // cell is not active,
+                                              // and so are none of
+                                              // its children. check
+                                              // the
+                                              // grandchildren. note
+                                              // that the children
+                                              // are also
+                                              // patch_level_1, and
+                                              // so we only ever need
+                                              // to check their first
+                                              // child
+             const unsigned int n_children=cell->n_children();
+             bool has_active_grandchildren = false;
+
+             for (unsigned int i=0; i<n_children; ++i)
+               if (cell->child(i)->child(0)->active())
                  {
-                   cell_iterator child=cell->child(c);
-                                                    // check
-                                                    // consistency:
-                                                    // cell is not a
-                                                    // patch of level
-                                                    // 1.
-                   Assert(!child->active(), ExcInternalError());
-                   
-                   if (child->child(0)->active())
-                     {
-                                                        // child is
-                                                        // found to
-                                                        // be a patch
-                       const unsigned int nn_children=child->n_children();
-                       n_grandchildren += nn_children;
-                       for (unsigned int cc=0; cc<nn_children; ++cc)
-                         {
-                           cell_iterator grand_child=child->child(cc);
-                                                            // check
-                                                            // consistency:
-                                                            // child is
-                                                            // a patch
-                           Assert(grand_child->active(), ExcInternalError());
-
-                           if (grand_child->coarsen_flag_set())
-                             ++n_coarsen_flags;
-                         }
-                     }
+                   has_active_grandchildren = true;
+                   break;
                  }
-               
-               if (n_coarsen_flags!=n_grandchildren)
+
+             if (has_active_grandchildren == false)
+               continue;
+             
+
+                                              // ok, there are active
+                                              // grandchildren. see
+                                              // if either all or
+                                              // none of them are
+                                              // flagged for
+                                              // coarsening
+             unsigned int n_grandchildren=0;           
+                                              // count all coarsen
+                                              // flags of the
+                                              // grandchildren.
+             unsigned int n_coarsen_flags=0;
+                                              // cell is not a
+                                              // patch (of level 1)
+                                              // as it has a
+                                              // grandchild.  Is
+                                              // cell a patch of
+                                              // level 2??
+                                              // Therefore: find
+                                              // out whether all
+                                              // cell->child(i) are
+                                              // patches
+             for (unsigned int c=0; c<n_children; ++c)
+               {
+                                                  // get at the
+                                                  // child. by
+                                                  // assumption
+                                                  // (A), and the
+                                                  // check by which
+                                                  // we got here,
+                                                  // the child is
+                                                  // not active
+                 cell_iterator child=cell->child(c);
+
+                 const unsigned int nn_children=child->n_children();
+                 n_grandchildren += nn_children;
+
+                                                  // if child is
+                                                  // found to be a
+                                                  // patch of
+                                                  // active cells
+                                                  // itself, then
+                                                  // add up how
+                                                  // many of its
+                                                  // children are
+                                                  // supposed to be
+                                                  // coarsened
+                 if (child->child(0)->active())
+                   for (unsigned int cc=0; cc<nn_children; ++cc)
+                     if (child->child(cc)->coarsen_flag_set())
+                       ++n_coarsen_flags;
+               }
+
+                                              // if not all
+                                              // grandchildren are
+                                              // supposed to be
+                                              // coarsened
+                                              // (e.g. because some
+                                              // simply don't have
+                                              // the flag set, or
+                                              // because they are not
+                                              // active and therefore
+                                              // cannot carry the
+                                              // flag), then remove
+                                              // the coarsen flag
+                                              // from all of the
+                                              // active
+                                              // grandchildren. note
+                                              // that there may be
+                                              // coarsen flags on the
+                                              // grandgrandchildren
+                                              // -- we don't clear
+                                              // them here, but we'll
+                                              // get to them in later
+                                              // iterations if
+                                              // necessary
+                                              //
+                                              // there is nothing
+                                              // we have to do if
+                                              // no coarsen flags
+                                              // have been set at
+                                              // all
+             if ((n_coarsen_flags != n_grandchildren)
+                 &&
+                 (n_coarsen_flags > 0))
+               for (unsigned int c=0; c<n_children; ++c)
                  {
-                                                    // clear all
-                                                    // grandchildren's
-                                                    // coarsen_flags
-                   for (unsigned int c=0; c<n_children; ++c)
-                     {
-                       cell_iterator child=cell->child(c);
-                       Assert(!child->active(), ExcInternalError());
-                   
-                       if (child->child(0)->active())
-                         {
-                           const unsigned int nn_children=child->n_children();
-                           for (unsigned int cc=0; cc<nn_children; ++cc)
-                             {
-                               cell_iterator grand_child=child->child(cc);
-                               Assert(grand_child->active(), ExcInternalError());
-                               
-                               grand_child->clear_coarsen_flag();
-                             }
-                         }
-                     } 
+                   const cell_iterator child = cell->child(c);
+                   if (child->child(0)->active())
+                     for (unsigned int cc=0; cc<child->n_children(); ++cc)
+                       child->child(cc)->clear_coarsen_flag();
                  }
-             }
+           }
        }
 
                                       //////////////////////////////////
index 895643a368b678a9218f1cc5d07706dc985e5ab9..fe05766403acf5119f2b61764ffa362dc92dcdb5 100644 (file)
@@ -72,6 +72,7 @@ tests_x = block_matrices \
        maximal_cell_diameter \
        union_triangulation \
        refine_flag_set \
+       mesh_smoothing_* \
        create_* \
        line_coarsening_3d \
        no_flux_* \
diff --git a/tests/deal.II/mesh_smoothing_01/cmp/generic b/tests/deal.II/mesh_smoothing_01/cmp/generic
new file mode 100644 (file)
index 0000000..861839f
--- /dev/null
@@ -0,0 +1,215 @@
+
+DEAL::136 (on 5 levels)
+DEAL::256 (on 6 levels)
+DEAL::520 (on 7 levels)
+DEAL::1120 (on 8 levels)
+DEAL::Coarsen flag set: 5.208
+DEAL::Coarsen flag set: 5.209
+DEAL::Coarsen flag set: 5.210
+DEAL::Coarsen flag set: 5.211
+DEAL::Coarsen flag set: 5.212
+DEAL::Coarsen flag set: 5.213
+DEAL::Coarsen flag set: 5.214
+DEAL::Coarsen flag set: 5.215
+DEAL::Coarsen flag set: 5.216
+DEAL::Coarsen flag set: 5.217
+DEAL::Coarsen flag set: 5.218
+DEAL::Coarsen flag set: 5.219
+DEAL::Coarsen flag set: 5.220
+DEAL::Coarsen flag set: 5.221
+DEAL::Coarsen flag set: 5.222
+DEAL::Coarsen flag set: 5.223
+DEAL::Coarsen flag set: 6.288
+DEAL::Coarsen flag set: 6.289
+DEAL::Coarsen flag set: 6.290
+DEAL::Coarsen flag set: 6.291
+DEAL::Coarsen flag set: 6.292
+DEAL::Coarsen flag set: 6.293
+DEAL::Coarsen flag set: 6.294
+DEAL::Coarsen flag set: 6.295
+DEAL::Coarsen flag set: 6.296
+DEAL::Coarsen flag set: 6.297
+DEAL::Coarsen flag set: 6.298
+DEAL::Coarsen flag set: 6.299
+DEAL::Coarsen flag set: 6.300
+DEAL::Coarsen flag set: 6.301
+DEAL::Coarsen flag set: 6.302
+DEAL::Coarsen flag set: 6.303
+DEAL::Coarsen flag set: 6.320
+DEAL::Coarsen flag set: 6.321
+DEAL::Coarsen flag set: 6.322
+DEAL::Coarsen flag set: 6.323
+DEAL::Coarsen flag set: 6.324
+DEAL::Coarsen flag set: 6.325
+DEAL::Coarsen flag set: 6.326
+DEAL::Coarsen flag set: 6.327
+DEAL::Coarsen flag set: 6.328
+DEAL::Coarsen flag set: 6.329
+DEAL::Coarsen flag set: 6.330
+DEAL::Coarsen flag set: 6.331
+DEAL::Coarsen flag set: 6.332
+DEAL::Coarsen flag set: 6.333
+DEAL::Coarsen flag set: 6.334
+DEAL::Coarsen flag set: 6.335
+DEAL::Coarsen flag set: 6.336
+DEAL::Coarsen flag set: 6.337
+DEAL::Coarsen flag set: 6.338
+DEAL::Coarsen flag set: 6.339
+DEAL::Coarsen flag set: 6.340
+DEAL::Coarsen flag set: 6.341
+DEAL::Coarsen flag set: 6.342
+DEAL::Coarsen flag set: 6.343
+DEAL::Coarsen flag set: 6.344
+DEAL::Coarsen flag set: 6.345
+DEAL::Coarsen flag set: 6.346
+DEAL::Coarsen flag set: 6.347
+DEAL::Coarsen flag set: 6.348
+DEAL::Coarsen flag set: 6.349
+DEAL::Coarsen flag set: 6.350
+DEAL::Coarsen flag set: 6.351
+DEAL::Coarsen flag set: 6.368
+DEAL::Coarsen flag set: 6.369
+DEAL::Coarsen flag set: 6.370
+DEAL::Coarsen flag set: 6.371
+DEAL::Coarsen flag set: 6.372
+DEAL::Coarsen flag set: 6.373
+DEAL::Coarsen flag set: 6.374
+DEAL::Coarsen flag set: 6.375
+DEAL::Coarsen flag set: 6.376
+DEAL::Coarsen flag set: 6.377
+DEAL::Coarsen flag set: 6.378
+DEAL::Coarsen flag set: 6.379
+DEAL::Coarsen flag set: 6.380
+DEAL::Coarsen flag set: 6.381
+DEAL::Coarsen flag set: 6.382
+DEAL::Coarsen flag set: 6.383
+DEAL::Coarsen flag set: 6.384
+DEAL::Coarsen flag set: 6.385
+DEAL::Coarsen flag set: 6.386
+DEAL::Coarsen flag set: 6.387
+DEAL::Coarsen flag set: 6.388
+DEAL::Coarsen flag set: 6.389
+DEAL::Coarsen flag set: 6.390
+DEAL::Coarsen flag set: 6.391
+DEAL::Coarsen flag set: 6.392
+DEAL::Coarsen flag set: 6.393
+DEAL::Coarsen flag set: 6.394
+DEAL::Coarsen flag set: 6.395
+DEAL::Coarsen flag set: 6.396
+DEAL::Coarsen flag set: 6.397
+DEAL::Coarsen flag set: 6.398
+DEAL::Coarsen flag set: 6.399
+DEAL::Coarsen flag set: 6.432
+DEAL::Coarsen flag set: 6.433
+DEAL::Coarsen flag set: 6.434
+DEAL::Coarsen flag set: 6.435
+DEAL::Coarsen flag set: 6.436
+DEAL::Coarsen flag set: 6.437
+DEAL::Coarsen flag set: 6.438
+DEAL::Coarsen flag set: 6.439
+DEAL::Coarsen flag set: 6.440
+DEAL::Coarsen flag set: 6.441
+DEAL::Coarsen flag set: 6.442
+DEAL::Coarsen flag set: 6.443
+DEAL::Coarsen flag set: 6.444
+DEAL::Coarsen flag set: 6.445
+DEAL::Coarsen flag set: 6.446
+DEAL::Coarsen flag set: 6.447
+DEAL::Coarsen flag set: 7.16
+DEAL::Coarsen flag set: 7.17
+DEAL::Coarsen flag set: 7.18
+DEAL::Coarsen flag set: 7.19
+DEAL::Coarsen flag set: 7.20
+DEAL::Coarsen flag set: 7.21
+DEAL::Coarsen flag set: 7.22
+DEAL::Coarsen flag set: 7.23
+DEAL::Coarsen flag set: 7.24
+DEAL::Coarsen flag set: 7.25
+DEAL::Coarsen flag set: 7.26
+DEAL::Coarsen flag set: 7.27
+DEAL::Coarsen flag set: 7.28
+DEAL::Coarsen flag set: 7.29
+DEAL::Coarsen flag set: 7.30
+DEAL::Coarsen flag set: 7.31
+DEAL::Coarsen flag set: 7.112
+DEAL::Coarsen flag set: 7.113
+DEAL::Coarsen flag set: 7.114
+DEAL::Coarsen flag set: 7.115
+DEAL::Coarsen flag set: 7.116
+DEAL::Coarsen flag set: 7.117
+DEAL::Coarsen flag set: 7.118
+DEAL::Coarsen flag set: 7.119
+DEAL::Coarsen flag set: 7.120
+DEAL::Coarsen flag set: 7.121
+DEAL::Coarsen flag set: 7.122
+DEAL::Coarsen flag set: 7.123
+DEAL::Coarsen flag set: 7.124
+DEAL::Coarsen flag set: 7.125
+DEAL::Coarsen flag set: 7.126
+DEAL::Coarsen flag set: 7.127
+DEAL::Coarsen flag set: 7.144
+DEAL::Coarsen flag set: 7.145
+DEAL::Coarsen flag set: 7.146
+DEAL::Coarsen flag set: 7.147
+DEAL::Coarsen flag set: 7.148
+DEAL::Coarsen flag set: 7.149
+DEAL::Coarsen flag set: 7.150
+DEAL::Coarsen flag set: 7.151
+DEAL::Coarsen flag set: 7.152
+DEAL::Coarsen flag set: 7.153
+DEAL::Coarsen flag set: 7.154
+DEAL::Coarsen flag set: 7.155
+DEAL::Coarsen flag set: 7.156
+DEAL::Coarsen flag set: 7.157
+DEAL::Coarsen flag set: 7.158
+DEAL::Coarsen flag set: 7.159
+DEAL::Coarsen flag set: 7.160
+DEAL::Coarsen flag set: 7.161
+DEAL::Coarsen flag set: 7.162
+DEAL::Coarsen flag set: 7.163
+DEAL::Coarsen flag set: 7.164
+DEAL::Coarsen flag set: 7.165
+DEAL::Coarsen flag set: 7.166
+DEAL::Coarsen flag set: 7.167
+DEAL::Coarsen flag set: 7.168
+DEAL::Coarsen flag set: 7.169
+DEAL::Coarsen flag set: 7.170
+DEAL::Coarsen flag set: 7.171
+DEAL::Coarsen flag set: 7.172
+DEAL::Coarsen flag set: 7.173
+DEAL::Coarsen flag set: 7.174
+DEAL::Coarsen flag set: 7.175
+DEAL::Coarsen flag set: 7.192
+DEAL::Coarsen flag set: 7.193
+DEAL::Coarsen flag set: 7.194
+DEAL::Coarsen flag set: 7.195
+DEAL::Coarsen flag set: 7.196
+DEAL::Coarsen flag set: 7.197
+DEAL::Coarsen flag set: 7.198
+DEAL::Coarsen flag set: 7.199
+DEAL::Coarsen flag set: 7.200
+DEAL::Coarsen flag set: 7.201
+DEAL::Coarsen flag set: 7.202
+DEAL::Coarsen flag set: 7.203
+DEAL::Coarsen flag set: 7.204
+DEAL::Coarsen flag set: 7.205
+DEAL::Coarsen flag set: 7.206
+DEAL::Coarsen flag set: 7.207
+DEAL::Coarsen flag set: 7.224
+DEAL::Coarsen flag set: 7.225
+DEAL::Coarsen flag set: 7.226
+DEAL::Coarsen flag set: 7.227
+DEAL::Coarsen flag set: 7.228
+DEAL::Coarsen flag set: 7.229
+DEAL::Coarsen flag set: 7.230
+DEAL::Coarsen flag set: 7.231
+DEAL::Coarsen flag set: 7.232
+DEAL::Coarsen flag set: 7.233
+DEAL::Coarsen flag set: 7.234
+DEAL::Coarsen flag set: 7.235
+DEAL::Coarsen flag set: 7.236
+DEAL::Coarsen flag set: 7.237
+DEAL::Coarsen flag set: 7.238
+DEAL::Coarsen flag set: 7.239
+DEAL::988 (on 8 levels)
+DEAL::OK
diff --git a/tests/deal.II/mesh_smoothing_02/cmp/generic b/tests/deal.II/mesh_smoothing_02/cmp/generic
new file mode 100644 (file)
index 0000000..0d83014
--- /dev/null
@@ -0,0 +1,41 @@
+
+DEAL::n_active_cells = 28
+DEAL::Cell = 0.0 is not active and has children: 1.0 1.1 1.2 1.3 
+DEAL::Cell = 1.0 is not active and has children: 2.0 2.1 2.2 2.3 
+DEAL::Cell = 1.1 is not active and has children: 2.4 2.5 2.6 2.7 
+DEAL::Cell = 1.2 is not active and has children: 2.8 2.9 2.10 2.11 
+DEAL::Cell = 1.3 is not active and has children: 2.12 2.13 2.14 2.15 
+DEAL::Cell = 2.0 is not active and has children: 3.0 3.1 3.2 3.3 
+DEAL::Cell = 2.1 is not active and has children: 3.4 3.5 3.6 3.7 
+DEAL::Cell = 2.2 is not active and has children: 3.8 3.9 3.10 3.11 
+DEAL::Cell = 2.3 is not active and has children: 3.12 3.13 3.14 3.15 
+DEAL::Cell = 2.4 is active 
+DEAL::Cell = 2.5 is active 
+DEAL::Cell = 2.6 is active 
+DEAL::Cell = 2.7 is active 
+DEAL::Cell = 2.8 is active 
+DEAL::Cell = 2.9 is active 
+DEAL::Cell = 2.10 is active 
+DEAL::Cell = 2.11 is active 
+DEAL::Cell = 2.12 is active 
+DEAL::Cell = 2.13 is active 
+DEAL::Cell = 2.14 is active 
+DEAL::Cell = 2.15 is active 
+DEAL::Cell = 3.0 is active 
+DEAL::Cell = 3.1 is active 
+DEAL::Cell = 3.2 is active 
+DEAL::Cell = 3.3 is active 
+DEAL::Cell = 3.4 is active 
+DEAL::Cell = 3.5 is active 
+DEAL::Cell = 3.6 is active 
+DEAL::Cell = 3.7 is active 
+DEAL::Cell = 3.8 is active 
+DEAL::Cell = 3.9 is active 
+DEAL::Cell = 3.10 is active 
+DEAL::Cell = 3.11 is active 
+DEAL::Cell = 3.12 is active 
+DEAL::Cell = 3.13 is active 
+DEAL::Cell = 3.14 is active 
+DEAL::Cell = 3.15 is active 
+DEAL::n_active_cells = 16
+DEAL::OK

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.