From 0198afe40341a31a7e4df397c3ecb124a9d3f817 Mon Sep 17 00:00:00 2001 From: heister Date: Wed, 16 Oct 2013 22:42:24 +0000 Subject: [PATCH] GridTools::partition_triangulation no longer uses user_index which fixes step-18 in debug mode git-svn-id: https://svn.dealii.org/trunk@31272 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/source/grid/grid_tools.cc | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/deal.II/source/grid/grid_tools.cc b/deal.II/source/grid/grid_tools.cc index df146a150b..669dccb71b 100644 --- a/deal.II/source/grid/grid_tools.cc +++ b/deal.II/source/grid/grid_tools.cc @@ -1115,16 +1115,17 @@ next_cell: + 1); - // next we have to build a mapping from the - // list of cells to their indices. for - // this, use the user_index field - std::vector saved_user_indices; - triangulation.save_user_indices (saved_user_indices); + // create a map pair -> SparsityPattern index + // TODO: we are no longer using user_indices for this because we can get + // pointer/index clashes when saving/restoring them. The following approach + // works, but this map can get quite big. Not sure about more efficient solutions. + std::map< std::pair, unsigned int > + indexmap; unsigned int index = 0; for (typename Triangulation::active_cell_iterator cell = triangulation.begin_active(); cell != triangulation.end(); ++cell, ++index) - cell->set_user_index (index); + indexmap[std::pair(cell->level(),cell->index())] = index; // next loop over all cells and // their neighbors to build the @@ -1153,21 +1154,15 @@ next_cell: && (cell->neighbor(f)->has_children() == false)) { - cell_connectivity.add (index, - cell->neighbor(f)->user_index()); - cell_connectivity.add (cell->neighbor(f)->user_index(), - index); + unsigned int other_index = indexmap.find( + std::pair(cell->neighbor(f)->level(),cell->neighbor(f)->index()))->second; + cell_connectivity.add (index, other_index); + cell_connectivity.add (other_index, index); } } - // now compress the so-built connectivity - // pattern and restore user indices. the - // const-cast is necessary since we treat - // the triangulation as constant (we here - // return it to its original state) + // now compress the so-built connectivity pattern cell_connectivity.compress (); - const_cast&>(triangulation) - .load_user_indices (saved_user_indices); } -- 2.39.5