From: bangerth Date: Wed, 6 Aug 2008 17:49:50 +0000 (+0000) Subject: Fix partition function -- we needed to also consider refined neighbors. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=567ab26f239a0e4f12279332841a196e5a26a498;p=dealii-svn.git Fix partition function -- we needed to also consider refined neighbors. git-svn-id: https://svn.dealii.org/trunk@16506 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/source/grid/grid_tools.cc b/deal.II/deal.II/source/grid/grid_tools.cc index 226bac996d..ec733f3fe4 100644 --- a/deal.II/deal.II/source/grid/grid_tools.cc +++ b/deal.II/deal.II/source/grid/grid_tools.cc @@ -841,14 +841,19 @@ partition_triangulation (const unsigned int n_partitions, // cells with their neighbors, and then // passing this graph off to METIS. // - // as built in this function, we only - // consider face neighbors, which leads to - // a fixed number of entries per row (don't - // forget that each cell couples with - // itself) + // as built in this function, we + // only consider face neighbors, + // which leads to a fixed number of + // entries per row (don't forget + // that each cell couples with + // itself, and that neighbors can + // be refined) SparsityPattern cell_connectivity (triangulation.n_active_cells(), triangulation.n_active_cells(), - GeometryInfo::faces_per_cell+1); + GeometryInfo::faces_per_cell + * GeometryInfo::max_children_per_face + + + 1); // next we have to build a mapping from the // list of cells to their indices. for @@ -861,8 +866,22 @@ partition_triangulation (const unsigned int n_partitions, cell != triangulation.end(); ++cell, ++index) cell->set_user_index (index); - // next loop over all cells and their - // neighbors to build the sparsity pattern + // next loop over all cells and + // their neighbors to build the + // sparsity pattern. note that it's + // a bit hard to enter all the + // connections when a neighbor has + // children since we would need to + // find out which of its children + // is adjacent to the current + // cell. this problem can be + // omitted if we only do something + // if the neighbor has no children + // -- in that case it is either on + // the same or a coarser level than + // we are. in return, we have to + // add entries in both directions + // for both cells index = 0; for (typename Triangulation::active_cell_iterator cell = triangulation.begin_active(); @@ -870,9 +889,15 @@ partition_triangulation (const unsigned int n_partitions, { cell_connectivity.add (index, index); for (unsigned int f=0; f::faces_per_cell; ++f) - if (cell->at_boundary(f) == false) - cell_connectivity.add (index, - cell->neighbor(f)->user_index()); + if ((cell->at_boundary(f) == false) + && + (cell->neighbor(f)->has_children() == false)) + { + cell_connectivity.add (index, + cell->neighbor(f)->user_index()); + cell_connectivity.add (cell->neighbor(f)->user_index(), + index); + } } // now compress the so-built connectivity