]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Test MGDoFHandler::distribute_dofs and renumber functions.
authorRalf Hartmann <Ralf.Hartmann@dlr.de>
Mon, 23 Jan 2006 12:34:09 +0000 (12:34 +0000)
committerRalf Hartmann <Ralf.Hartmann@dlr.de>
Mon, 23 Jan 2006 12:34:09 +0000 (12:34 +0000)
git-svn-id: https://svn.dealii.org/trunk@12127 0785d39b-7218-0410-832d-ea1e28bc413d

tests/multigrid/renumbering_02.cc [new file with mode: 0644]
tests/multigrid/renumbering_03.cc [new file with mode: 0644]

diff --git a/tests/multigrid/renumbering_02.cc b/tests/multigrid/renumbering_02.cc
new file mode 100644 (file)
index 0000000..95562b6
--- /dev/null
@@ -0,0 +1,72 @@
+//----------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2000 - 2006 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.
+//
+//----------------------------------------------------------------------------
+
+// Until version 1.50 of mg_dof_handler.cc, the
+// MGDoFHandler::renumbering function could not handle coarsened grids
+// (unused cells). Check that this works now.
+
+#include <base/logstream.h>
+#include <lac/vector.h>
+#include <lac/block_vector.h>
+#include <grid/tria.h>
+#include <grid/grid_generator.h>
+#include <dofs/dof_renumbering.h>
+#include <fe/fe_dgp.h>
+#include <fe/fe_dgq.h>
+#include <fe/fe_q.h>
+#include <fe/fe_system.h>
+#include <multigrid/mg_dof_handler.h>
+#include <multigrid/mg_dof_accessor.h>
+
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <algorithm>
+
+using namespace std;
+
+template <int dim>
+void check()
+{
+  FE_DGQ<dim> fe(1);
+  deallog << fe.get_name() << std::endl;
+  
+  Triangulation<dim> tria;
+  GridGenerator::hyper_cube(tria);
+  tria.refine_global(2);
+  typename Triangulation<dim>::active_cell_iterator cell=tria.begin_active();
+  for (unsigned int i=0; i<GeometryInfo<dim>::children_per_cell; ++i, ++cell)
+    cell->set_coarsen_flag();
+  tria.execute_coarsening_and_refinement ();
+  
+  MGDoFHandler<dim> mg_dof_handler(tria);
+  mg_dof_handler.distribute_dofs(fe);
+  Point<dim> a;
+  a(0)=1;
+  for (unsigned int level=0; level<tria.n_levels(); ++level)
+    DoFRenumbering::downstream_dg(mg_dof_handler, level, a);
+}
+
+
+int main()
+{
+  std::ofstream logfile("renumbering_02/output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  check<1> ();
+  check<2> ();
+  check<3> ();
+
+  deallog << "OK" << endl;
+}
diff --git a/tests/multigrid/renumbering_03.cc b/tests/multigrid/renumbering_03.cc
new file mode 100644 (file)
index 0000000..836fc5a
--- /dev/null
@@ -0,0 +1,79 @@
+//----------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2000 - 2006 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.
+//
+//----------------------------------------------------------------------------
+
+// Until version 1.50 of mg_dof_handler.cc, the
+// MGDoFHandler::distribute_dofs function in 1d and 3d could not
+// handle coarsened grids (unused vertices). Also, the
+// MGDoFHandler::renumbering function could not handle coarsened grids
+// (unused vertices, unused faces). Check that all this works now.
+
+#include <base/logstream.h>
+#include <lac/vector.h>
+#include <lac/block_vector.h>
+#include <grid/tria.h>
+#include <grid/grid_generator.h>
+#include <dofs/dof_renumbering.h>
+#include <fe/fe_dgp.h>
+#include <fe/fe_dgq.h>
+#include <fe/fe_q.h>
+#include <fe/fe_system.h>
+#include <multigrid/mg_dof_handler.h>
+#include <multigrid/mg_dof_accessor.h>
+
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <algorithm>
+
+using namespace std;
+
+template <int dim>
+void check()
+{
+  FE_Q<dim> fe(3);
+  deallog << fe.get_name() << std::endl;
+  
+  Triangulation<dim> tria;
+  GridGenerator::hyper_cube(tria);
+  tria.refine_global(2);
+  typename Triangulation<dim>::active_cell_iterator cell=tria.begin_active();
+  for (unsigned int i=0; i<GeometryInfo<dim>::children_per_cell; ++i, ++cell)
+    cell->set_coarsen_flag();
+  tria.execute_coarsening_and_refinement ();
+  
+  MGDoFHandler<dim> mg_dof_handler(tria);
+  mg_dof_handler.distribute_dofs(fe);
+  for (unsigned int level=0; level<tria.n_levels(); ++level)
+    {
+      const unsigned int n_dofs=mg_dof_handler.n_dofs(level);
+      vector<unsigned int> new_numbers(n_dofs);
+      for (unsigned int i=0; i<n_dofs; ++i)
+       new_numbers[i]=n_dofs-1-i;
+
+      mg_dof_handler.renumber_dofs(level, new_numbers);
+    }
+}
+
+
+int main()
+{
+  std::ofstream logfile("renumbering_03/output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  check<1> ();
+  check<2> ();
+  check<3> ();
+
+  deallog << "OK" << endl;
+}

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.