]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Split the generation of a connectivity pattern between cells into a separate function...
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 31 Oct 2008 16:50:17 +0000 (16:50 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 31 Oct 2008 16:50:17 +0000 (16:50 +0000)
git-svn-id: https://svn.dealii.org/trunk@17426 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/grid/grid_tools.h
deal.II/deal.II/source/grid/grid_tools.cc
deal.II/doc/news/changes.h

index 9e6a88e70e9b74bcf6ea1935b9d39410b7bb971e..9c3f178e8e21b2288b9e3177452b287c017a92f2 100644 (file)
@@ -438,6 +438,22 @@ class GridTools
     static void
     get_active_neighbors (const typename Container::active_cell_iterator        &cell,
                          std::vector<typename Container::active_cell_iterator> &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 <int dim>
+    static void
+    get_face_connectivity_of_cells (const Triangulation<dim> &triangulation,
+                                   SparsityPattern          &connectivity);
     
                                      /**
                                       * Use the METIS partitioner to generate
index 7a3861dbec063f8544777d457c4e91b9238917c4..fd805420bf4c88f3e7db73a70a30adda8af0ab1b 100644 (file)
@@ -822,26 +822,9 @@ GridTools::find_active_cell_around_point (const hp::MappingCollection<dim>   &ma
 template <int dim>
 void
 GridTools::
-partition_triangulation (const unsigned int  n_partitions,
-                         Triangulation<dim> &triangulation)
+get_face_connectivity_of_cells (const Triangulation<dim> &triangulation,
+                               SparsityPattern          &cell_connectivity)
 {
-  Assert (n_partitions > 0, ExcInvalidNumberOfPartitions(n_partitions));
-
-                                   // check for an easy return
-  if (n_partitions == 1)
-    {
-      for (typename Triangulation<dim>::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<dim>::faces_per_cell
-                                    * GeometryInfo<dim>::max_children_per_face
-                                    +
-                                    1);
+  cell_connectivity.reinit (triangulation.n_active_cells(),
+                           triangulation.n_active_cells(),
+                           GeometryInfo<dim>::faces_per_cell
+                           * GeometryInfo<dim>::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<dim>&>(triangulation)
+    .load_user_indices (saved_user_indices);  
+}
+
+
+
+template <int dim>
+void
+GridTools::
+partition_triangulation (const unsigned int  n_partitions,
+                         Triangulation<dim> &triangulation)
+{
+  Assert (n_partitions > 0, ExcInvalidNumberOfPartitions(n_partitions));
+
+                                   // check for an easy return
+  if (n_partitions == 1)
+    {
+      for (typename Triangulation<dim>::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<deal_II_di
                                           const hp::DoFHandler<deal_II_dimension> &,
                                           const Point<deal_II_dimension> &);
 
+template
+void
+GridTools::
+get_face_connectivity_of_cells (const Triangulation<deal_II_dimension> &triangulation,
+                               SparsityPattern          &cell_connectivity)
+
 template
 void
 GridTools::partition_triangulation (const unsigned int,
index bf6e548013dc02b1396dc5a8fca5ad9012659978..1cb171dfedc0b0bd71b01b178b6c5b4417aff54b 100644 (file)
@@ -299,6 +299,10 @@ inconvenience this causes.
 <h3>lac</h3>
 
 <ol>
+  <li>
+  <p>
+  New: The function GridTools::get_face_connectivity_of_cells produces 
+
   <li>
   <p>
   Changed: The function SparsityPattern::partition has been deprecated. It

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.