]> https://gitweb.dealii.org/ - dealii.git/commitdiff
fix index computation in DataOut that was completely broken if the cells are filtered
authorTimo Heister <timo.heister@gmail.com>
Wed, 16 Oct 2013 19:23:22 +0000 (19:23 +0000)
committerTimo Heister <timo.heister@gmail.com>
Wed, 16 Oct 2013 19:23:22 +0000 (19:23 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_port_the_testsuite@31267 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/source/numerics/data_out.cc

index 0a8646d11c1443814fa18ddcf7a1c5b7b422dad1..539ac2d973a561025f47b669038961c1ed340827 100644 (file)
@@ -302,12 +302,13 @@ build_one_patch (const std::pair<cell_iterator, unsigned int> *cell_and_index,
         = (*data.cell_to_patch_index_map)[neighbor->level()][neighbor->index()];
     }
 
+  const unsigned int patch_idx = cell_and_index->second;
   // did we mess up the indices?
-  Assert(cell_and_index->second < patches.size(), ExcInternalError());
+  Assert(patch_idx < patches.size(), ExcInternalError());
   
   // Put the patch in the patches vector
-  patches[cell_and_index->second] = patch;
-  patches[cell_and_index->second].patch_index = cell_and_index->second;
+  patches[patch_idx] = patch;
+  patches[patch_idx].patch_index = patch_idx;
 }
 
 
@@ -359,19 +360,8 @@ void DataOut<dim,DH>::build_patches (const Mapping<DH::dimension,DH::space_dimen
 
   std::vector<std::pair<cell_iterator, unsigned int> > all_cells;
   {
-    // set the index of the first cell. if first_locally_owned_cell /
-    // next_locally_owned_cell returns non-active cells, then the index is not
-    // usable anyway, but otherwise we should keep track where we are
-    unsigned int index;
     cell_iterator cell = first_locally_owned_cell();
-    if ((cell == this->triangulation->end())
-        ||
-        (cell->has_children()))
-      index = 0;
-    else
-      index = std::distance (this->triangulation->begin_active(),
-                             active_cell_iterator(cell));
-    for ( ; cell != this->triangulation->end(); )
+    for (unsigned int index = 0; cell != this->triangulation->end(); ++index)
       {
         Assert (static_cast<unsigned int>(cell->level()) <
                 cell_to_patch_index_map.size(),
@@ -383,19 +373,7 @@ void DataOut<dim,DH>::build_patches (const Mapping<DH::dimension,DH::space_dimen
         cell_to_patch_index_map[cell->level()][cell->index()] = all_cells.size();
 
         all_cells.push_back (std::make_pair(cell, index));
-
-        // if both this and the next cell are active, then increment the index
-        // that keeps track on which active cell we are sitting correctly. if
-        // one of the cells is not active, then this index doesn't mean
-        // anything anyway, so just ignore it. same if we are at the end of
-        // the range
-        cell_iterator next = next_locally_owned_cell(cell);
-        if (!cell->has_children() &&
-            next != this->triangulation->end() &&
-            !next->has_children())
-          index += std::distance (active_cell_iterator(cell),
-                                  active_cell_iterator(next));
-        cell = next;
+        cell = next_locally_owned_cell(cell);
       }
   }
 

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.