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

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

index 843e57f15aa13bf4b4053d2d5d81ecb603e40e95..f21b407a90d480f22067ab5464a9774ab28f74b5 100644 (file)
@@ -1,8 +1,8 @@
 
 // ---------------------------------------------------------------------
-// $Id: work_stream.h 30494 2013-08-26 10:04:44Z kronbichler $
+// $Id: graph_coloring.h 30494 2013-08-26 10:04:44Z kronbichler $
 //
-// Copyright (C) 2008 - 2013 by the deal.II authors
+// Copyright (C) 2013 by the deal.II authors
 //
 // This file is part of the deal.II library.
 //
@@ -28,7 +28,7 @@
 
 DEAL_II_NAMESPACE_OPEN
 
-// Currently graph_coloring only works only for continuous FE and without hp.
+// Currently graph_coloring only works only for continuous FE.
 namespace graph_coloring {
 
   /**
diff --git a/tests/base/graph_coloring_03.cc b/tests/base/graph_coloring_03.cc
new file mode 100644 (file)
index 0000000..92f889e
--- /dev/null
@@ -0,0 +1,86 @@
+// ---------------------------------------------------------------------
+// $Id: graph_coloring_03.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 hp-mesh.
+
+
+#include "../tests.h"
+#include <fstream>
+#include <vector>
+
+#include <deal.II/base/graph_coloring.h>
+#include <deal.II/fe/fe_q.h>
+#include <deal.II/hp/dof_handler.h>
+#include <deal.II/hp/fe_values.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);
+  hp::FECollection<dim> fe_collection;
+  for (unsigned int degree=1; degree<4; ++degree)
+    fe_collection.push_back(FE_Q<dim>(degree));
+  hp::DoFHandler<dim> dof_handler(triangulation);
+  typename hp::DoFHandler<dim>::active_cell_iterator
+  cell = dof_handler.begin_active();
+  for (unsigned int degree=1; cell!=dof_handler.end(); ++cell,++degree)
+    cell->set_active_fe_index(degree%3);
+  dof_handler.distribute_dofs(fe_collection);
+
+  // Create an adapted mesh
+  for (cell=dof_handler.begin_active(); 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_collection);
+
+  // 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()));      
+
+  // 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_03/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_03/cmp/generic b/tests/base/graph_coloring_03/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.