From 37e0bb923ca7a434da6774a60bbefa2a7cc684c4 Mon Sep 17 00:00:00 2001 From: heister Date: Wed, 16 Oct 2013 19:23:22 +0000 Subject: [PATCH] fix index computation in DataOut that was completely broken if the cells are filtered 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 | 34 +++++------------------------ 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/deal.II/source/numerics/data_out.cc b/deal.II/source/numerics/data_out.cc index 0a8646d11c..539ac2d973 100644 --- a/deal.II/source/numerics/data_out.cc +++ b/deal.II/source/numerics/data_out.cc @@ -302,12 +302,13 @@ build_one_patch (const std::pair *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::build_patches (const Mapping > 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(cell->level()) < cell_to_patch_index_map.size(), @@ -383,19 +373,7 @@ void DataOut::build_patches (const Mappinglevel()][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); } } -- 2.39.5