From: wolf Date: Thu, 10 Oct 2002 22:10:08 +0000 (+0000) Subject: Fix two bugs. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9a834885a81ec217af3277db793b347c143a0791;p=dealii-svn.git Fix two bugs. git-svn-id: https://svn.dealii.org/trunk@6628 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/source/numerics/data_out.cc b/deal.II/deal.II/source/numerics/data_out.cc index 7d31eb50b4..f5cdb9b2d3 100644 --- a/deal.II/deal.II/source/numerics/data_out.cc +++ b/deal.II/deal.II/source/numerics/data_out.cc @@ -438,7 +438,22 @@ void DataOut::build_some_patches (Data data) // but it may also happen // that the neighbor is not // a member of the range of - // cells over which we loop + // cells over which we + // loop, in which case the + // respective entry in the + // cell_to_patch_index_map + // will have the value + // no_neighbor. (note that + // since we allocated only + // as much space in this + // array as the maximum + // index of the cells we + // loop over, not every + // neighbor may have its + // space in it, so we have + // to assume that it is + // extended by values + // no_neighbor) if (cell->at_boundary(f) || (cell->neighbor(f)->level() != cell->level())) @@ -446,9 +461,15 @@ void DataOut::build_some_patches (Data data) const typename DoFHandler::cell_iterator neighbor = cell->neighbor(f); - if ((*data.cell_to_patch_index_map)[neighbor->level()][neighbor->index()] - == - ::DataOutBase::Patch::no_neighbor) + Assert (static_cast(neighbor->level()) < + data.cell_to_patch_index_map->size(), + ExcInternalError()); + if ((static_cast(neighbor->index()) >= + (*data.cell_to_patch_index_map)[neighbor->level()].size()) + || + ((*data.cell_to_patch_index_map)[neighbor->level()][neighbor->index()] + == + ::DataOutBase::Patch::no_neighbor)) continue; // now, there is a @@ -548,16 +569,26 @@ void DataOut::build_patches (const unsigned int n_subdivisions, // first count the cells we want to // create patches of. also fill the - // // object that maps the cell + // object that maps the cell // indices to the patch numbers, as // this will be needed for // generation of neighborship // information std::vector > cell_to_patch_index_map; cell_to_patch_index_map.resize (this->dofs->get_tria().n_levels()); - for (unsigned int l=0; ldofs->get_tria().n_levels(); ++l) - cell_to_patch_index_map[l].resize (this->dofs->get_tria().n_cells(l), - ::DataOutBase::Patch::no_neighbor); + for (unsigned int l=0; ldofs->get_tria().n_levels(); ++l) + { + unsigned int max_index = 0; + for (typename DoFHandler::cell_iterator cell=first_cell(); + cell != this->dofs->end(); + cell = next_cell(cell)) + if (static_cast(cell->level()) == l) + max_index = std::max (max_index, + static_cast(cell->index())); + + cell_to_patch_index_map[l].resize (max_index+1, + ::DataOutBase::Patch::no_neighbor); + }; unsigned int n_patches = 0; for (typename DoFHandler::cell_iterator cell=first_cell();