]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add a test for graph_coloring.
authorturcksin <turcksin@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 18 Sep 2013 15:22:33 +0000 (15:22 +0000)
committerturcksin <turcksin@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 18 Sep 2013 15:22:33 +0000 (15:22 +0000)
git-svn-id: https://svn.dealii.org/trunk@30797 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/base/graph_coloring.h
tests/base/graph_coloring_01.cc
tests/base/graph_coloring_02.cc [new file with mode: 0644]
tests/base/graph_coloring_02/cmp/generic [new file with mode: 0644]

index 47c4a0826bfd4ab77c24b098b8d194b3999757dd..843e57f15aa13bf4b4053d2d5d81ecb603e40e95 100644 (file)
@@ -28,8 +28,7 @@
 
 DEAL_II_NAMESPACE_OPEN
 
-// Currently graph_coloring only works for on uniform mesh, with a uniform
-// order for the polynomials, and only for continuous FE.
+// Currently graph_coloring only works only for continuous FE and without hp.
 namespace graph_coloring {
 
   /**
index d53a51d32c80b0524200bf3953e8cdb800474ccd..eaefb06b95221769224577029ea27f346dd3c845 100644 (file)
@@ -1,5 +1,5 @@
 // ---------------------------------------------------------------------
-// $Id: graph_coloring.cc 30045 2013-07-18 19:18:00Z maier $
+// $Id: graph_coloring_01.cc 30045 2013-07-18 19:18:00Z maier $
 //
 // Copyright (C) 2003 - 2013 by the deal.II authors
 //
diff --git a/tests/base/graph_coloring_02.cc b/tests/base/graph_coloring_02.cc
new file mode 100644 (file)
index 0000000..431d0f7
--- /dev/null
@@ -0,0 +1,84 @@
+// ---------------------------------------------------------------------
+// $Id: graph_coloring_02.cc 30045 2013-07-18 19:18:00Z maier $
+//
+// Copyright (C) 2003 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+
+// Check that graph coloring works on adapted mesh with a uniform polynomial
+// order.
+
+
+#include "../tests.h"
+#include <fstream>
+#include <vector>
+
+#include <deal.II/base/graph_coloring.h>
+#include <deal.II/dofs/dof_accessor.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/fe/fe_q.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/tria.h>
+
+template <int dim>
+void check()
+{
+  // Create the Triangulation and the DoFHandler
+  Triangulation<dim> triangulation;
+  GridGenerator::hyper_cube(triangulation);
+  triangulation.refine_global(2);
+  FE_Q<dim> fe(2);
+  DoFHandler<dim> dof_handler(triangulation);
+  dof_handler.distribute_dofs(fe);
+
+  // Create an adapted mesh
+  typename DoFHandler<dim>::active_cell_iterator
+  cell = dof_handler.begin_active();
+  for (; cell<dof_handler.end(); ++cell)
+  {
+    if ((cell->center()[0]==0.625) && (cell->center()[1]==0.625))
+    cell->set_refine_flag();
+  }
+  triangulation.execute_coarsening_and_refinement();
+  dof_handler.distribute_dofs(fe);
+
+  // 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()));      
+
+  // Output the coloring
+  for (unsigned int color=0; color<coloring.size(); ++color)
+  {
+    deallog<<"Color: "<<color<<std::endl;
+    for (unsigned int i=0; i<coloring[color].size(); ++i)
+      for (unsigned int j=0; j<dim; ++j)
+        deallog<<coloring[color][i]->center()[j]<<" ";
+    deallog<<std::endl;
+  }
+}
+
+int main()
+{
+  std::ofstream logfile("graph_coloring_02/output");
+  deallog<<std::setprecision(4);
+  deallog<<std::fixed;
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  check<2> ();
+
+  return 0;
+}
diff --git a/tests/base/graph_coloring_02/cmp/generic b/tests/base/graph_coloring_02/cmp/generic
new file mode 100644 (file)
index 0000000..2e67434
--- /dev/null
@@ -0,0 +1,13 @@
+
+DEAL::Color: 0
+DEAL::0.6250 0.3750 0.1250 0.6250 0.8750 0.8750 
+DEAL::Color: 1
+DEAL::0.3750 0.6250 0.6250 0.1250 
+DEAL::Color: 2
+DEAL::0.5625 0.5625 0.1250 0.1250 
+DEAL::Color: 3
+DEAL::0.3750 0.1250 0.8750 0.6250 0.5625 0.6875 0.8750 0.1250 0.1250 0.8750 
+DEAL::Color: 4
+DEAL::0.1250 0.3750 0.6875 0.6875 0.8750 0.3750 0.3750 0.8750 
+DEAL::Color: 5
+DEAL::0.3750 0.3750 0.6875 0.5625 0.6250 0.8750 

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.