]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Use std_cxx1x::function for graph_coloring.
authorturcksin <turcksin@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 26 Sep 2013 20:37:50 +0000 (20:37 +0000)
committerturcksin <turcksin@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 26 Sep 2013 20:37:50 +0000 (20:37 +0000)
git-svn-id: https://svn.dealii.org/trunk@30970 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/base/graph_coloring.h
deal.II/include/deal.II/base/work_stream.h
tests/base/graph_coloring_01.cc
tests/base/graph_coloring_02.cc
tests/base/graph_coloring_03.cc

index b6d49e7d2d5e85ed7599ee8912ee56d352e3ec04..2349fbe99435b89b3764c3b452ea925ed27092e5 100644 (file)
@@ -20,6 +20,7 @@
 
 
 #include <deal.II/base/config.h>
+#include <deal.II/base/std_cxx1x/function.h>
 #include <deal.II/dofs/dof_handler.h>
 #include <boost/unordered_map.hpp>
 #include <boost/unordered_set.hpp>
@@ -38,7 +39,8 @@ namespace graph_coloring {
   template <typename Iterator>
   std::vector<std::vector<Iterator> > create_partitioning(Iterator const &begin,
       typename identity<Iterator>::type const &end,
-      std::vector<types::global_dof_index> (*get_conflict_indices) (Iterator const&))
+      std_cxx1x::function<std::vector<types::global_dof_index> (Iterator const &)> 
+      const &get_conflict_indices)
   {
     std::vector<std::vector<Iterator> > partitioning(1,std::vector<Iterator> (1,begin));
     // Number of iterators.
@@ -47,7 +49,7 @@ namespace graph_coloring {
     boost::unordered_map<types::global_dof_index,std::vector<Iterator> > indices_to_iterators;
     for (Iterator it=begin; it!=end; ++it)
     {
-      std::vector<types::global_dof_index> conflict_indices = (*get_conflict_indices)(it);
+      std::vector<types::global_dof_index> conflict_indices = get_conflict_indices(it);
       const unsigned int n_conflict_indices(conflict_indices.size());
       for (unsigned int i=0; i<n_conflict_indices; ++i)
         indices_to_iterators[conflict_indices[i]].push_back(it);
@@ -64,7 +66,7 @@ namespace graph_coloring {
       std::vector<Iterator> new_zone;
       for (; vector_it!=vector_end; ++vector_it)
       {
-        std::vector<types::global_dof_index> conflict_indices = (*get_conflict_indices)(*vector_it);
+        std::vector<types::global_dof_index> conflict_indices = get_conflict_indices(*vector_it);
         const unsigned int n_conflict_indices(conflict_indices.size());
         for (unsigned int i=0; i<n_conflict_indices; ++i)
         {
@@ -111,7 +113,8 @@ namespace graph_coloring {
    */
   template <typename Iterator>
   std::vector<std::vector<Iterator> > make_dsatur_coloring(std::vector<Iterator> &partition,
-      std::vector<types::global_dof_index> (*get_conflict_indices)(Iterator const&))
+      std_cxx1x::function<std::vector<types::global_dof_index> (Iterator const &)> 
+      const &get_conflict_indices)
   {
     std::vector<std::vector<Iterator> > partition_coloring;
     // Number of zones composing the partitioning.
@@ -125,7 +128,7 @@ namespace graph_coloring {
     // set_intersection can be used later.
     for (unsigned int i=0; i<partition_size; ++i)
     {
-      conflict_indices[i] = (*get_conflict_indices)(partition[i]);
+      conflict_indices[i] = get_conflict_indices(partition[i]);
       std::sort(conflict_indices[i].begin(),conflict_indices[i].end());
     }
 
@@ -343,7 +346,8 @@ namespace graph_coloring {
   template <typename Iterator>
   std::vector<std::vector<Iterator> > 
   make_graph_coloring(Iterator const &begin,typename identity<Iterator>::type const &end,
-      std::vector<types::global_dof_index> (*get_conflict_indices)(Iterator const&)) 
+      std_cxx1x::function<std::vector<types::global_dof_index> (Iterator const &)> 
+      const &get_conflict_indices)
   {
     // Create the partitioning.
     std::vector<std::vector<Iterator> > partitioning = create_partitioning(begin,end,
index 9ab55fec7fdddbf6588b09ca5a6f0d534de14541..21dfb52d09e507ca98711ab7fe47534de06655a1 100644 (file)
@@ -936,7 +936,8 @@ namespace WorkStream
        Copier                                   copier,
        const ScratchData                       &sample_scratch_data,
        const CopyData                          &sample_copy_data,
-       std::vector<types::global_dof_index> (*get_conflict_indices) (const Iterator &),
+       const std_cxx1x::function<std::vector<types::global_dof_index> (const Iterator &)> 
+                                               &get_conflict_indices,
        const unsigned int queue_length = 2*multithread_info.n_default_threads,
        const unsigned int                       chunk_size = 8)
   {
index 63f35366e9a86da61ae2386b7601225215996372..9a0a79d74543466268acaf7952484d18290c55e9 100644 (file)
@@ -58,7 +58,8 @@ void check()
   typename DoFHandler<dim>::active_cell_iterator cell(dof_handler.begin_active());
   std::vector<std::vector<typename DoFHandler<dim>::active_cell_iterator> > coloring(
       graph_coloring::make_graph_coloring(cell,dof_handler.end(),
-      get_conflict_indices_cfem<dim>));      
+      std_cxx1x::function<std::vector<types::global_dof_index> (typename 
+        DoFHandler<dim>::active_cell_iterator const &)> (get_conflict_indices_cfem<dim>)));      
 
   // Output the coloring
   for (unsigned int color=0; color<coloring.size(); ++color)
index 7079cc8ae667c94debde7a7bd0fbd103074fd696..56aae036ea7d7e2fe6cf0426c8f5377cb581e6b5 100644 (file)
@@ -35,7 +35,7 @@
 
 template <int dim>
 std::vector<types::global_dof_index> get_conflict_indices_cfem(
-    typename DoFHandler<dim>::active_cell_iterator const &it)
+    typename DoFHandler<dim>::active_cell_iterator const &it) 
 {
   std::vector<types::global_dof_index> local_dof_indices(it->get_fe().dofs_per_cell);
   it->get_dof_indices(local_dof_indices);
@@ -68,7 +68,8 @@ void check()
   // Create the coloring
   std::vector<std::vector<typename DoFHandler<dim>::active_cell_iterator> > coloring(
       graph_coloring::make_graph_coloring(dof_handler.begin_active(),dof_handler.end(),
-        get_conflict_indices_cfem<dim>));
+        std_cxx1x::function<std::vector<types::global_dof_index> (typename 
+          DoFHandler<dim>::active_cell_iterator const &)> (get_conflict_indices_cfem<dim>)));
 
   // Output the coloring
   for (unsigned int color=0; color<coloring.size(); ++color)
index 255e7dedb0cc348df725680b68bbac4b334965d9..812bb7fdf9743e0cc6427d2baaf618cf7cca89cc 100644 (file)
@@ -70,7 +70,8 @@ void check()
   // Create the coloring
   std::vector<std::vector<typename hp::DoFHandler<dim>::active_cell_iterator> > coloring(
       graph_coloring::make_graph_coloring(dof_handler.begin_active(),dof_handler.end(),
-        get_conflict_indices_cfem<dim>));      
+        std_cxx1x::function<std::vector<types::global_dof_index> (typename 
+          hp::DoFHandler<dim>::active_cell_iterator const &)> (get_conflict_indices_cfem<dim>)));
 
   // Output the coloring
   for (unsigned int color=0; color<coloring.size(); ++color)

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.