]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Fix a problem when overloading first_cell/next_cell and giving cell data.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 5 Nov 2009 21:48:15 +0000 (21:48 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 5 Nov 2009 21:48:15 +0000 (21:48 +0000)
git-svn-id: https://svn.dealii.org/trunk@20044 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/source/numerics/data_out.cc
deal.II/doc/news/changes.h

index 2cc094ccfea375d7d147e216c4d5f07f7065cf33..68e0793ed0ab505fab5ac5ab79e26384c392a923 100644 (file)
@@ -961,9 +961,20 @@ void DataOut<dim,DH>::build_patches (const Mapping<DH::dimension,DH::space_dimen
 
   std::vector<std::pair<cell_iterator, unsigned int> > all_cells;
   {
-    unsigned int index = 0;
+                                    // set the index of the first
+                                    // cell. if first_cell/next_cell
+                                    // returns non-active cells, then
+                                    // the index is not usable
+                                    // anyway, but otherwise we
+                                    // should keep track where we are
+    unsigned int index;
+    if (first_cell()->has_children())
+      index = 0;
+    else
+      index = std::distance (this->dofs->begin_active(),
+                            active_cell_iterator(first_cell()));
     for (cell_iterator cell=first_cell(); cell != this->dofs->end();
-        cell = next_cell(cell), ++index)
+        cell = next_cell(cell))
       {
        Assert (static_cast<unsigned int>(cell->level()) <
                cell_to_patch_index_map.size(),
@@ -975,6 +986,23 @@ 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
+       if (!cell->has_children() &&
+           next_cell(cell) != this->dofs->end() &&
+           !next_cell(cell)->has_children())
+         index += std::distance (active_cell_iterator(cell),
+                                 active_cell_iterator(next_cell(cell)));
       }
   }
 
index 841f5e1fa4962f5d5fcb1c08c50960688490aa0b..c2df68f6ae437f8c70f9f99fba4587f21bea66b1 100644 (file)
@@ -511,6 +511,15 @@ inconvenience this causes.
 <h3>deal.II</h3>
 
 <ol>
+  <li>
+  <p>
+  Fixed: The function DataOut class got confused when its DataOut::first_cell() and
+  DataOut::next_cell() were overloaded and cell data was given. This is now fixed.
+  <br>
+  (Wolfgang Bangerth 2009/11/05)
+  </p>
+  </li>
+
   <li>
   <p>
   New: The function DoFRenumbering::component_wise is now also implemented

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.