From 3e40035dec90940f6239d906095d7f565c9a2f32 Mon Sep 17 00:00:00 2001
From: Wolfgang Bangerth <bangerth@math.tamu.edu>
Date: Wed, 5 Mar 2008 15:23:36 +0000
Subject: [PATCH] Implement the still missing boost::compute_Cuthill_McKee
 function. Leave a TODO.

git-svn-id: https://svn.dealii.org/trunk@15858 0785d39b-7218-0410-832d-ea1e28bc413d
---
 .../deal.II/source/dofs/dof_renumbering.cc    | 37 +++++++++++++++++--
 1 file changed, 33 insertions(+), 4 deletions(-)

diff --git a/deal.II/deal.II/source/dofs/dof_renumbering.cc b/deal.II/deal.II/source/dofs/dof_renumbering.cc
index d371bee864..36825e3645 100644
--- a/deal.II/deal.II/source/dofs/dof_renumbering.cc
+++ b/deal.II/deal.II/source/dofs/dof_renumbering.cc
@@ -207,6 +207,26 @@ DoFRenumbering::boost::
 Cuthill_McKee (DH&              dof_handler,
 	       const bool       reversed_numbering,
 	       const bool       use_constraints)
+{
+  std::vector<unsigned int> renumbering(dof_handler.n_dofs(),
+					DH::invalid_dof_index);
+  compute_Cuthill_McKee(renumbering, dof_handler, reversed_numbering,
+			use_constraints);
+
+				   // actually perform renumbering;
+				   // this is dimension specific and
+				   // thus needs an own function
+  dof_handler.renumber_dofs (renumbering);
+}
+
+
+template <class DH>
+void
+DoFRenumbering::boost::
+compute_Cuthill_McKee (std::vector<unsigned int>& new_dof_indices,
+		       const DH        &dof_handler,
+		       const bool       reversed_numbering,
+		       const bool       use_constraints)
 {
   types::Graph
     graph(dof_handler.n_dofs());
@@ -230,11 +250,12 @@ Cuthill_McKee (DH&              dof_handler,
 				    get(::boost::vertex_color, graph),
 				    make_degree_map(graph));
     
-  std::vector<unsigned int> perm(num_vertices(graph));
   for (types::size_type c = 0; c != inv_perm.size(); ++c)
-    perm[index_map[inv_perm[c]]] = c;
+    new_dof_indices[index_map[inv_perm[c]]] = c;
 
-  dof_handler.renumber_dofs (perm);
+  Assert (std::find (new_dof_indices.begin(), new_dof_indices.end(),
+		     DH::invalid_dof_index) == new_dof_indices.end(),
+	  ExcInternalError());
 }
 
 
@@ -1619,7 +1640,15 @@ compute_subdomain_wise (std::vector<unsigned int> &new_dof_indices,
 
 
 // explicit instantiations
-template void DoFRenumbering::boost::Cuthill_McKee (DoFHandler<deal_II_dimension> &, bool, bool);
+//TODO[WB]: also implement the following boost functions for hp DoFHandlers etc.
+template
+void
+DoFRenumbering::boost::Cuthill_McKee (DoFHandler<deal_II_dimension> &, bool, bool);
+
+template
+void
+DoFRenumbering::boost::compute_Cuthill_McKee (std::vector<unsigned int> &,
+					      const DoFHandler<deal_II_dimension> &, bool, bool);
 
 
 template
-- 
2.39.5