]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
New test: dof_renumbering.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 11 Apr 2001 22:16:51 +0000 (22:16 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 11 Apr 2001 22:16:51 +0000 (22:16 +0000)
git-svn-id: https://svn.dealii.org/trunk@4442 0785d39b-7218-0410-832d-ea1e28bc413d

tests/deal.II/Makefile.in
tests/deal.II/dof_renumbering.cc [new file with mode: 0644]

index 52f4f5971a699c07f3df4ac4357371fa534e5645..6ff2594c727eaed9e2fc7f72443a5393da201d43 100644 (file)
@@ -28,6 +28,7 @@ data_out.exe                 : data_out.go                           $(lib-2d) $
 derivative_approximation.exe : derivative_approximation.go $(lib-1d) $(lib-2d) $(lib-3d) $(libraries)
 derivatives.exe              : derivatives.go              $(lib-1d) $(lib-2d) $(lib-3d) $(libraries)
 dof_test.exe                 : dof_test.go                           $(lib-2d) $(lib-3d) $(libraries)
+dof_renumbering.exe          : dof_renumbering.go          $(lib-1d) $(lib-2d) $(lib-3d) $(libraries)
 error_estimator.exe          : error_estimator.go          $(lib-1d) $(lib-2d) $(lib-3d) $(libraries)
 gradients.exe                : gradients.go                          $(lib-2d)           $(libraries)
 grid_test.exe                : grid_test.go                          $(lib-2d) $(lib-3d) $(libraries)
@@ -44,7 +45,7 @@ wave-test-3.exe              : wave-test-3.go                        $(lib-2d)
 tests = grid_test dof_test data_out derivatives gradients constraints mg \
         mglocal block_matrices second_derivatives derivative_approximation \
         matrices error_estimator intergrid_constraints intergrid_map \
-        wave-test-3
+        wave-test-3 dof_renumbering
 
 ############################################################
 
diff --git a/tests/deal.II/dof_renumbering.cc b/tests/deal.II/dof_renumbering.cc
new file mode 100644 (file)
index 0000000..65f4100
--- /dev/null
@@ -0,0 +1,109 @@
+//----------------------------  dof_renumbering.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2000, 2001 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------  dof_renumbering.cc  ---------------------------
+
+
+/* Author: Wolfgang Bangerth, University of Heidelberg, 2001 */
+
+
+
+#include <base/logstream.h>
+#include <base/function_lib.h>
+#include <lac/vector.h>
+#include <grid/tria.h>
+#include <grid/tria_iterator.h>
+#include <dofs/dof_accessor.h>
+#include <grid/grid_generator.h>
+#include <dofs/dof_handler.h>
+#include <fe/fe_q.h>
+#include <fe/fe_dgq.h>
+#include <fe/fe_system.h>
+#include <numerics/dof_renumbering.h>
+
+#include <fstream>
+
+
+
+template <int dim>
+void
+print_dofs (const DoFHandler<dim> &dof)
+{
+  std::vector<unsigned int> v (dof.get_fe().dofs_per_cell);
+  for (typename DoFHandler<dim>::active_cell_iterator cell=dof.begin_active();
+       cell != dof.end(); ++cell)
+    {
+      deallog << "Cell " << cell << std::endl;
+      cell->get_dof_indices (v);
+      for (unsigned int i=0; i<v.size(); ++i)
+       deallog << v[i] << ' ';
+      deallog << std::endl;
+    }
+}
+
+
+
+template <int dim>
+void
+check ()
+{
+  CosineFunction<dim> cosine;
+  
+  Triangulation<dim> tr;  
+  if (dim==2)
+    GridGenerator::hyper_ball(tr);
+  else
+    GridGenerator::hyper_cube(tr, -1,1);
+  tr.refine_global (1);
+  tr.begin_active()->set_refine_flag ();
+  tr.execute_coarsening_and_refinement ();
+  if (dim==1)
+    tr.refine_global(2);
+  
+  FESystem<dim> element (FE_Q<dim>(3), 2, FE_DGQ<dim>(1), 1);
+  DoFHandler<dim> dof(tr);
+  dof.distribute_dofs(element);
+
+  print_dofs (dof);
+  
+  DoFRenumbering::Cuthill_McKee (dof);              print_dofs (dof);
+  DoFRenumbering::Cuthill_McKee (dof, true);        print_dofs (dof);
+  DoFRenumbering::Cuthill_McKee (dof, true, true);  print_dofs (dof);
+
+  std::vector<unsigned int> order(element.n_components());
+  for (unsigned int i=0; i<order.size(); ++i) order[i] = order.size()-i-1;
+  DoFRenumbering::component_wise (dof, order);      print_dofs (dof);
+
+  std::vector<bool> selected_dofs (dof.n_dofs(), false);
+  for (unsigned int i=0; i<dof.n_dofs(); ++i) if (i%2==0) selected_dofs[i] = true;
+  DoFRenumbering::sort_selected_dofs_back (dof, selected_dofs);
+  print_dofs (dof);
+}
+
+
+int main ()
+{
+  ofstream logfile ("dof_renumbering.output");
+  logfile.precision (2);
+  logfile.setf(ios::fixed);  
+  deallog.attach(logfile);
+  deallog.depth_console (0);
+
+  deallog.push ("1d");
+  check<1> ();
+  deallog.pop ();
+  deallog.push ("2d");
+  check<2> ();
+  deallog.pop ();
+  deallog.push ("3d");
+  check<3> ();
+  deallog.pop ();
+}

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.