]> https://gitweb.dealii.org/ - dealii.git/commitdiff
New tests
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 2 May 2006 22:19:19 +0000 (22:19 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 2 May 2006 22:19:19 +0000 (22:19 +0000)
git-svn-id: https://svn.dealii.org/trunk@12984 0785d39b-7218-0410-832d-ea1e28bc413d

tests/hp/Makefile
tests/hp/crash_05.cc [new file with mode: 0644]
tests/hp/random.cc [new file with mode: 0644]

index 163d835ebf11aae0050bb2d6943a82dfb7d5db6a..dac33e0a2c22719ed567833e139cb21b3602ff6b 100644 (file)
@@ -27,7 +27,8 @@ tests_x = hp_dof_handler \
          mapping_collection_* \
          fe_collection_* \
          continuous_* \
-         n_dofs
+         n_dofs \
+         random
 
 # from above list of regular expressions, generate the real set of
 # tests
diff --git a/tests/hp/crash_05.cc b/tests/hp/crash_05.cc
new file mode 100644 (file)
index 0000000..a9578f4
--- /dev/null
@@ -0,0 +1,89 @@
+//----------------------------  crash_05.cc  ---------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2005, 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.
+//
+//----------------------------  crash_05.cc  ---------------------------
+
+
+// a crash when using different fe's on different cells
+
+
+#include <base/logstream.h>
+#include <grid/tria.h>
+#include <grid/grid_generator.h>
+#include <grid/tria_accessor.h>
+#include <grid/grid_out.h>
+#include <grid/tria_iterator.h>
+#include <dofs/hp_dof_handler.h>
+#include <dofs/dof_accessor.h>
+#include <fe/fe_q.h>
+
+#include <fstream>
+
+
+
+template <int dim>
+void test ()
+{
+  Triangulation<dim> tria;
+  GridGenerator::hyper_cube(tria);
+  tria.refine_global (1);
+
+                                  // use the same element, but with
+                                  // different indices
+  hp::FECollection<dim> fe_collection;
+  for (unsigned int i=0; i<tria.n_active_cells(); ++i)
+    fe_collection.push_back(FE_Q<dim> (1));
+
+  hp::DoFHandler<dim> dof_handler(tria);
+
+  unsigned int fe_index = 0;
+  for (typename hp::DoFHandler<dim>::active_cell_iterator
+        cell = dof_handler.begin_active();
+       cell != dof_handler.end(); ++cell, ++fe_index)
+    {
+      deallog << "Setting fe_index=" << fe_index << " on cell " << cell
+             << std::endl;
+      cell->set_active_fe_index (fe_index);
+    }
+  
+  dof_handler.distribute_dofs(fe_collection);
+
+  std::vector<unsigned int> local_dof_indices;
+  for (typename hp::DoFHandler<dim>::active_cell_iterator
+         cell=dof_handler.begin_active();
+       cell!=dof_handler.end(); ++cell)
+    {
+      local_dof_indices.resize (cell->get_fe().dofs_per_cell);
+      cell->get_dof_indices (local_dof_indices);
+
+      deallog << cell << std::endl;
+      for (unsigned int i=0; i<local_dof_indices.size(); ++i)
+        deallog << local_dof_indices[i] << ' ';
+      deallog << std::endl;
+    }
+}
+
+
+int main ()
+{
+  std::ofstream logfile("crash_05/output");
+  logfile.precision(2);
+  
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);  
+
+  test<1> ();
+  test<2> ();
+  test<3> ();
+  
+  deallog << "OK" << std::endl;
+}
diff --git a/tests/hp/random.cc b/tests/hp/random.cc
new file mode 100644 (file)
index 0000000..3f1a33b
--- /dev/null
@@ -0,0 +1,88 @@
+//----------------------------  random.cc  ---------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2005, 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.
+//
+//----------------------------  random.cc  ---------------------------
+
+
+// see what happens if we distribute different finite elements
+// randomly across the domain
+
+
+#include <base/logstream.h>
+#include <grid/tria.h>
+#include <grid/grid_generator.h>
+#include <grid/tria_accessor.h>
+#include <grid/grid_out.h>
+#include <grid/tria_iterator.h>
+#include <dofs/hp_dof_handler.h>
+#include <dofs/dof_accessor.h>
+#include <fe/fe_q.h>
+
+#include <fstream>
+
+
+
+template <int dim>
+void test ()
+{
+  Triangulation<dim> tria;
+  GridGenerator::hyper_cube(tria);
+  tria.refine_global (2);
+  tria.begin_active()->set_refine_flag ();
+  tria.execute_coarsening_and_refinement ();
+  tria.refine_global (2);  
+
+  hp::FECollection<dim> fe_collection;
+  fe_collection.push_back(FE_Q<dim> (1));
+  fe_collection.push_back(FE_Q<dim> (2));
+  fe_collection.push_back(FE_Q<dim> (3));
+  fe_collection.push_back(FE_Q<dim> (4));
+
+  hp::DoFHandler<dim> dof_handler(tria);
+
+  for (typename hp::DoFHandler<dim>::active_cell_iterator
+        cell = dof_handler.begin_active();
+       cell != dof_handler.end(); ++cell)
+    cell->set_active_fe_index (rand() % fe_collection.size());
+  
+  dof_handler.distribute_dofs(fe_collection);
+
+  std::vector<unsigned int> local_dof_indices;
+  for (typename hp::DoFHandler<dim>::active_cell_iterator
+         cell=dof_handler.begin_active();
+       cell!=dof_handler.end(); ++cell)
+    {
+      local_dof_indices.resize (cell->get_fe().dofs_per_cell);
+      cell->get_dof_indices (local_dof_indices);
+
+      deallog << cell << std::endl;
+      for (unsigned int i=0; i<local_dof_indices.size(); ++i)
+        deallog << local_dof_indices[i] << ' ';
+      deallog << std::endl;
+    }
+}
+
+
+int main ()
+{
+  std::ofstream logfile("random/output");
+  logfile.precision(2);
+  
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);  
+
+  test<1> ();
+  test<2> ();
+  test<3> ();
+  
+  deallog << "OK" << std::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.