From 9d3bd6d66d7438c68a81c291b8d937b0271b3049 Mon Sep 17 00:00:00 2001 From: bangerth Date: Fri, 31 Oct 2008 16:50:17 +0000 Subject: [PATCH] Split the generation of a connectivity pattern between cells into a separate function in GridTools. git-svn-id: https://svn.dealii.org/trunk@17426 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/grid/grid_tools.h | 16 +++++ deal.II/deal.II/source/grid/grid_tools.cc | 77 ++++++++++++++--------- deal.II/doc/news/changes.h | 4 ++ 3 files changed, 69 insertions(+), 28 deletions(-) diff --git a/deal.II/deal.II/include/grid/grid_tools.h b/deal.II/deal.II/include/grid/grid_tools.h index 9e6a88e70e..9c3f178e8e 100644 --- a/deal.II/deal.II/include/grid/grid_tools.h +++ b/deal.II/deal.II/include/grid/grid_tools.h @@ -438,6 +438,22 @@ class GridTools static void get_active_neighbors (const typename Container::active_cell_iterator &cell, std::vector &active_neighbors); + + /** + * Produce a sparsity pattern in which + * nonzero entries indicate that two + * cells are connected via a common + * face. The diagonal entries of the + * sparsity pattern are also set. + * + * The rows and columns refer to the + * cells as they are traversed in their + * natural order using cell iterators. + */ + template + static void + get_face_connectivity_of_cells (const Triangulation &triangulation, + SparsityPattern &connectivity); /** * Use the METIS partitioner to generate diff --git a/deal.II/deal.II/source/grid/grid_tools.cc b/deal.II/deal.II/source/grid/grid_tools.cc index 7a3861dbec..fd805420bf 100644 --- a/deal.II/deal.II/source/grid/grid_tools.cc +++ b/deal.II/deal.II/source/grid/grid_tools.cc @@ -822,26 +822,9 @@ GridTools::find_active_cell_around_point (const hp::MappingCollection &ma template void GridTools:: -partition_triangulation (const unsigned int n_partitions, - Triangulation &triangulation) +get_face_connectivity_of_cells (const Triangulation &triangulation, + SparsityPattern &cell_connectivity) { - Assert (n_partitions > 0, ExcInvalidNumberOfPartitions(n_partitions)); - - // check for an easy return - if (n_partitions == 1) - { - for (typename Triangulation::active_cell_iterator - cell = triangulation.begin_active(); - cell != triangulation.end(); ++cell) - cell->set_subdomain_id (0); - return; - } - - // we decompose the domain by first - // generating the connection graph of all - // 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 @@ -849,12 +832,12 @@ partition_triangulation (const unsigned int n_partitions, // 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 - * GeometryInfo::max_children_per_face - + - 1); + cell_connectivity.reinit (triangulation.n_active_cells(), + triangulation.n_active_cells(), + 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 @@ -902,12 +885,44 @@ partition_triangulation (const unsigned int n_partitions, } // now compress the so-built connectivity - // pattern and restore user indices + // 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) cell_connectivity.compress (); - triangulation.load_user_indices (saved_user_indices); - + const_cast&>(triangulation) + .load_user_indices (saved_user_indices); +} + + + +template +void +GridTools:: +partition_triangulation (const unsigned int n_partitions, + Triangulation &triangulation) +{ + Assert (n_partitions > 0, ExcInvalidNumberOfPartitions(n_partitions)); + + // check for an easy return + if (n_partitions == 1) + { + for (typename Triangulation::active_cell_iterator + cell = triangulation.begin_active(); + cell != triangulation.end(); ++cell) + cell->set_subdomain_id (0); + return; + } + + // we decompose the domain by first + // generating the connection graph of all + // cells with their neighbors, and then + // passing this graph off to METIS. // finally defer to the other function for // partitioning and assigning subdomain ids + SparsityPattern cell_connectivity; + get_face_connectivity_of_cells (triangulation, cell_connectivity); + partition_triangulation (n_partitions, cell_connectivity, triangulation); @@ -1248,6 +1263,12 @@ GridTools::find_active_cell_around_point (const hp::MappingCollection &, const Point &); +template +void +GridTools:: +get_face_connectivity_of_cells (const Triangulation &triangulation, + SparsityPattern &cell_connectivity) + template void GridTools::partition_triangulation (const unsigned int, diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index bf6e548013..1cb171dfed 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -299,6 +299,10 @@ inconvenience this causes.

lac

    +
  1. +

    + New: The function GridTools::get_face_connectivity_of_cells produces +

  2. Changed: The function SparsityPattern::partition has been deprecated. It -- 2.39.5