From 57fd1bcf5d0905a74f12923d395751c4ff81f4ad Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Wed, 16 Oct 2013 20:12:52 +0000 Subject: [PATCH] take over 31267,31269,31270 from the branch git-svn-id: https://svn.dealii.org/trunk@31271 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/doc/news/changes.h | 6 +++++ deal.II/source/numerics/data_out.cc | 37 +++++++---------------------- 2 files changed, 15 insertions(+), 28 deletions(-) diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 7cdcdd827e..54d0a2412b 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -145,6 +145,12 @@ inconvenience this causes.

Specific improvements

    +
  1. + Fixed: When deriving from DataOut to filter the cells where output is generated, there were two different bugs that result in segmentation faults or wrong cells written (example, step-18). +
    + (Timo Heister, 2013/10/16) +
  2. +
  3. New: GridIn::read_vtk() reads 2d and 3d meshes in VTK format.
    diff --git a/deal.II/source/numerics/data_out.cc b/deal.II/source/numerics/data_out.cc index eeef590696..be256797bb 100644 --- a/deal.II/source/numerics/data_out.cc +++ b/deal.II/source/numerics/data_out.cc @@ -302,9 +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(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; } @@ -356,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(), @@ -380,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); } } @@ -484,7 +465,7 @@ typename DataOut::cell_iterator DataOut::first_locally_owned_cell () { typename DataOut::cell_iterator - cell = this->triangulation->begin_active (); + cell = first_cell(); // skip cells if the current one has no children (is active) and is a ghost // or artificial cell -- 2.39.5