]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add serial test for DoFRenumbering::block_wise for MG
authorTimo Heister <timo.heister@gmail.com>
Wed, 29 Apr 2015 20:34:52 +0000 (16:34 -0400)
committerTimo Heister <timo.heister@gmail.com>
Thu, 30 Apr 2015 20:36:25 +0000 (16:36 -0400)
tests/multigrid/renumbering_04.cc [new file with mode: 0644]
tests/multigrid/renumbering_04.output [new file with mode: 0644]

diff --git a/tests/multigrid/renumbering_04.cc b/tests/multigrid/renumbering_04.cc
new file mode 100644 (file)
index 0000000..2bd6c0f
--- /dev/null
@@ -0,0 +1,108 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2000 - 2015 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.
+//
+// ---------------------------------------------------------------------
+
+
+// Test DoFRenumbering::block_wise(dh, level)
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/vector.h>
+#include <deal.II/lac/block_vector.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/dofs/dof_renumbering.h>
+#include <deal.II/fe/fe_dgp.h>
+#include <deal.II/fe/fe_dgq.h>
+#include <deal.II/fe/fe_q.h>
+#include <deal.II/fe/fe_system.h>
+#include <deal.II/dofs/dof_accessor.h>
+
+#include <fstream>
+#include <iomanip>
+#include <iomanip>
+#include <algorithm>
+
+using namespace std;
+
+template <int dim>
+void check()
+{
+  FESystem<dim> fe(FE_Q<dim>(1), 1, FE_DGQ<dim>(0), 1);
+
+  deallog << fe.get_name() << std::endl;
+
+  Triangulation<dim> tria;
+  GridGenerator::hyper_cube(tria);
+  tria.refine_global(1);
+  tria.begin_active()->set_refine_flag();
+  tria.execute_coarsening_and_refinement ();
+
+  DoFHandler<dim> dh(tria);
+  dh.distribute_dofs(fe);
+  dh.distribute_mg_dofs(fe);
+
+  deallog << "** before:" << std::endl;
+  {
+    unsigned int n_dofs_per_cell = fe.dofs_per_cell;
+    std::vector<types::global_dof_index> local_dofs(n_dofs_per_cell);
+    for (unsigned int level=0; level<tria.n_levels(); ++level)
+      {
+        deallog << "* level " << level << std::endl;
+        for (typename DoFHandler<dim>::cell_iterator cell = dh.begin(level);
+             cell != dh.end(level); ++cell)
+          {
+            deallog << "cell " << cell->id() << ":" << std::endl;
+            cell->get_mg_dof_indices(local_dofs);
+            for (unsigned int i=0; i<n_dofs_per_cell; ++i)
+              deallog << local_dofs[i] << " ";
+            deallog << std::endl;
+          }
+      }
+  }
+
+  for (unsigned int level=0; level<tria.n_levels(); ++level)
+    DoFRenumbering::block_wise(dh, level);
+
+  deallog << std::endl << "** after:" << std::endl;
+  {
+    unsigned int n_dofs_per_cell = fe.dofs_per_cell;
+    std::vector<types::global_dof_index> local_dofs(n_dofs_per_cell);
+    for (unsigned int level=0; level<tria.n_levels(); ++level)
+      {
+        deallog << "* level " << level << std::endl;
+        for (typename DoFHandler<dim>::cell_iterator cell = dh.begin(level);
+             cell != dh.end(level); ++cell)
+          {
+            deallog << "cell " << cell->id() << ":" << std::endl;
+            cell->get_mg_dof_indices(local_dofs);
+            for (unsigned int i=0; i<n_dofs_per_cell; ++i)
+              deallog << local_dofs[i] << " ";
+            deallog << std::endl;
+          }
+      }
+  }
+}
+
+
+
+int main()
+{
+  initlog(__FILE__);
+  //check<1> ();
+  check<2> ();
+  //check<3> ();
+
+  deallog << "OK" << endl;
+}
diff --git a/tests/multigrid/renumbering_04.output b/tests/multigrid/renumbering_04.output
new file mode 100644 (file)
index 0000000..f10b3dd
--- /dev/null
@@ -0,0 +1,48 @@
+
+DEAL::FESystem<2>[FE_Q<2>(1)-FE_DGQ<2>(0)]
+DEAL::** before:
+DEAL::* level 0
+DEAL::cell 0_0::
+DEAL::0 1 2 3 4 
+DEAL::* level 1
+DEAL::cell 0_1:0:
+DEAL::0 1 2 3 4 
+DEAL::cell 0_1:1:
+DEAL::1 5 3 6 7 
+DEAL::cell 0_1:2:
+DEAL::2 3 8 9 10 
+DEAL::cell 0_1:3:
+DEAL::3 6 9 11 12 
+DEAL::* level 2
+DEAL::cell 0_2:00:
+DEAL::0 1 2 3 4 
+DEAL::cell 0_2:01:
+DEAL::1 5 3 6 7 
+DEAL::cell 0_2:02:
+DEAL::2 3 8 9 10 
+DEAL::cell 0_2:03:
+DEAL::3 6 9 11 12 
+DEAL::
+DEAL::** after:
+DEAL::* level 0
+DEAL::cell 0_0::
+DEAL::0 1 2 3 4 
+DEAL::* level 1
+DEAL::cell 0_1:0:
+DEAL::0 1 2 3 9 
+DEAL::cell 0_1:1:
+DEAL::1 4 3 5 10 
+DEAL::cell 0_1:2:
+DEAL::2 3 6 7 11 
+DEAL::cell 0_1:3:
+DEAL::3 5 7 8 12 
+DEAL::* level 2
+DEAL::cell 0_2:00:
+DEAL::0 1 2 3 9 
+DEAL::cell 0_2:01:
+DEAL::1 4 3 5 10 
+DEAL::cell 0_2:02:
+DEAL::2 3 6 7 11 
+DEAL::cell 0_2:03:
+DEAL::3 5 7 8 12 
+DEAL::OK

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.