]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
New tests.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 8 Oct 2009 19:39:10 +0000 (19:39 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 8 Oct 2009 19:39:10 +0000 (19:39 +0000)
git-svn-id: https://svn.dealii.org/trunk@19776 0785d39b-7218-0410-832d-ea1e28bc413d

tests/hp/fe_nothing_05.cc [new file with mode: 0644]
tests/hp/fe_nothing_05/cmp/generic [new file with mode: 0644]
tests/hp/fe_nothing_06.cc [new file with mode: 0644]
tests/hp/fe_nothing_06/cmp/generic [new file with mode: 0644]

diff --git a/tests/hp/fe_nothing_05.cc b/tests/hp/fe_nothing_05.cc
new file mode 100644 (file)
index 0000000..350bc3f
--- /dev/null
@@ -0,0 +1,166 @@
+//----------------------------  fe_nothing_05.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2009 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.
+//
+//----------------------------  fe_nothing_05.cc  ---------------------------
+
+
+// test that FE_Nothing works as intended
+
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <base/quadrature_lib.h>
+#include <fe/fe_nothing.h>
+#include <fe/fe_q.h>
+#include <hp/fe_collection.h>
+#include <hp/dof_handler.h>
+#include <grid/tria.h>
+#include <grid/grid_generator.h>
+#include <grid/tria_accessor.h>
+#include <grid/tria_iterator.h>
+#include <grid/grid_refinement.h>
+#include <dofs/dof_accessor.h>
+#include <dofs/dof_tools.h>
+#include <fe/fe_q.h>
+#include <fe/fe_system.h>
+#include <hp/dof_handler.h>
+#include <hp/fe_values.h>
+#include <lac/constraint_matrix.h>
+
+
+#include <fstream>
+
+                               // Create a mesh with hanging
+                               // nodes and FEQ/FENothing interfaces
+                               // in several admissible configurations
+                                // we'd like to check.  In 2D the mesh
+                                // looks like the following (with 0
+                                // and 1 denoting the two element types)
+                                //
+                                // +---------+----+----+
+                                // |         | 1  | 1  |
+                                // |    0    +----+----+
+                                // |         | 1  | 1  |
+                                // +----+----+----+----+
+                                // | 0  | 0  |         |
+                                // +----+----+    1    |
+                                // | 0  | 0  |         |
+                                // +----+----+---------+
+                               //
+                               // We then attempt to make hanging node
+                               // constraints on this mesh.
+
+template <int dim>
+void test ()
+{
+  Triangulation<dim>       triangulation;
+  GridGenerator :: hyper_cube (triangulation, -0.5, 0.5);
+  triangulation.refine_global(1);
+
+  {
+    typename Triangulation<dim> :: active_cell_iterator
+        cell = triangulation.begin_active(),
+        endc = triangulation.end();
+
+    for(; cell != endc; cell++)
+    {
+        Point<dim> center = cell->center();
+
+        if(center[0] < 0)
+        {
+          cell->set_subdomain_id(1);
+        }
+
+        double h=0;
+        for(unsigned d=0; d<dim; ++d) h += center[d];
+
+        if(std::fabs(h) + 1e-6 > 0.25*dim)
+          cell->set_refine_flag();
+    }
+
+    triangulation.execute_coarsening_and_refinement();
+  }
+
+                               // create fe_collection and
+                               // distribute dofs
+
+  hp::FECollection<dim>    fe_collection;
+
+  fe_collection.push_back (FE_Q<dim>(1));
+  fe_collection.push_back (FE_Nothing<dim>());
+
+  hp::DoFHandler<dim>      dof_handler (triangulation);
+
+                                  // loop over cells, and set cells
+                                  // within a circle to be of type
+                                  // FE_Nothing, while outside the
+                                  // circle to be of type FE_Q(1)
+  {
+    typename hp::DoFHandler<dim>::active_cell_iterator
+      cell = dof_handler.begin_active(),
+      endc = dof_handler.end();
+
+    for(; cell != endc; cell++)
+    {
+      if(cell->subdomain_id()==1 )
+        cell->set_active_fe_index(1);
+      else
+        cell->set_active_fe_index(0);
+    }
+
+    dof_handler.distribute_dofs (fe_collection);
+  }
+
+
+  deallog << "   Number of active cells:       "
+         << triangulation.n_active_cells()
+         << std::endl
+         << "   Number of degrees of freedom: "
+         << dof_handler.n_dofs()
+         << std::endl;
+
+
+  // .... test constraint handling
+
+  ConstraintMatrix constraints;
+
+  DoFTools::make_hanging_node_constraints (dof_handler, constraints);
+
+  constraints.close();
+
+  deallog << "   Number of constraints:        "
+          << constraints.n_constraints()
+          << std::endl;
+
+}
+
+
+
+int main ()
+{
+  std::ofstream logfile("fe_nothing_05/output");
+  logfile.precision(2);
+
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  deallog << "Try dim == 1" << std::flush << std::endl;
+  test<1> ();
+
+  deallog << "Try dim == 2" << std::flush << std::endl;
+  test<2> ();
+
+  deallog << "Try dim == 3" << std::flush << std::endl;
+  test<3> ();
+
+  deallog << "OK" << std::endl;
+}
diff --git a/tests/hp/fe_nothing_05/cmp/generic b/tests/hp/fe_nothing_05/cmp/generic
new file mode 100644 (file)
index 0000000..25229ee
--- /dev/null
@@ -0,0 +1,14 @@
+
+DEAL::Try dim == 1
+DEAL::   Number of active cells:       4
+DEAL::   Number of degrees of freedom: 3
+DEAL::   Number of constraints:        0
+DEAL::Try dim == 2
+DEAL::   Number of active cells:       10
+DEAL::   Number of degrees of freedom: 11
+DEAL::   Number of constraints:        1
+DEAL::Try dim == 3
+DEAL::   Number of active cells:       22
+DEAL::   Number of degrees of freedom: 37
+DEAL::   Number of constraints:        9
+DEAL::OK
diff --git a/tests/hp/fe_nothing_06.cc b/tests/hp/fe_nothing_06.cc
new file mode 100644 (file)
index 0000000..bf93f83
--- /dev/null
@@ -0,0 +1,169 @@
+//----------------------------  fe_nothing_01.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2009 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.
+//
+//----------------------------  fe_nothing_01.cc  ---------------------------
+
+
+// test that FE_Nothing works as intended
+
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <base/quadrature_lib.h>
+#include <fe/fe_nothing.h>
+#include <fe/fe_q.h>
+#include <hp/fe_collection.h>
+#include <hp/dof_handler.h>
+#include <grid/tria.h>
+#include <grid/grid_generator.h>
+#include <grid/tria_accessor.h>
+#include <grid/tria_iterator.h>
+#include <grid/grid_refinement.h>
+#include <dofs/dof_accessor.h>
+#include <dofs/dof_tools.h>
+#include <fe/fe_q.h>
+#include <fe/fe_system.h>
+#include <hp/dof_handler.h>
+#include <hp/fe_values.h>
+#include <lac/constraint_matrix.h>
+
+
+#include <fstream>
+
+                               // Create a mesh with hanging
+                               // nodes and FEQ/FENothing interfaces
+                               // in several admissible configurations
+                                // we'd like to check.  In 2D the mesh
+                                // looks like the following.
+                                //
+                                // +---------+----+----+
+                                // |         | 1  | 1  |
+                                // |    0    +----+----+
+                                // |         | 1  | 1  |
+                                // +----+----+----+----+
+                                // | 0  | 0  |         |
+                                // +----+----+    1    |
+                                // | 0  | 0  |         |
+                                // +----+----+---------+
+                               //
+                               // We then attempt to make hanging node
+                               // constraints on this mesh.
+
+template <int dim>
+void test ()
+{
+  Triangulation<dim>       triangulation;
+  GridGenerator :: hyper_cube (triangulation, -0.5, 0.5);
+  triangulation.refine_global(1);
+
+  {
+    typename Triangulation<dim> :: active_cell_iterator
+        cell = triangulation.begin_active(),
+        endc = triangulation.end();
+
+    for(; cell != endc; cell++)
+    {
+        Point<dim> center = cell->center();
+
+        if(center[0] < 0)
+        {
+          cell->set_subdomain_id(1);
+        }
+
+        double h=0;
+        for(unsigned d=0; d<dim; ++d) h += center[d];
+
+        if(std::fabs(h) + 1e-6 > 0.25*dim)
+          cell->set_refine_flag();
+    }
+
+    triangulation.execute_coarsening_and_refinement();
+  }
+
+                               // create fe_collection and
+                               // distribute dofs. in this test,
+                                // we are looking at FESystems.
+
+  hp::FECollection<dim>    fe_collection;
+
+  fe_collection.push_back (FESystem<dim>(FE_Q<dim>(2), dim,
+                                         FE_Q<dim>(1), 1));
+
+  fe_collection.push_back (FESystem<dim>(FE_Nothing<dim>(), dim,
+                                         FE_Nothing<dim>(), 1));
+
+  hp::DoFHandler<dim>      dof_handler (triangulation);
+
+                                  // loop over cells, and set cells
+                                  // within a circle to be of type
+                                  // FE_Nothing, while outside the
+                                  // circle to be of type FE_Q(1)
+  {
+    typename hp::DoFHandler<dim>::active_cell_iterator
+      cell = dof_handler.begin_active(),
+      endc = dof_handler.end();
+
+    for(; cell != endc; cell++)
+    {
+      if(cell->subdomain_id()==1 )
+        cell->set_active_fe_index(1);
+      else
+        cell->set_active_fe_index(0);
+    }
+
+    dof_handler.distribute_dofs (fe_collection);
+  }
+
+
+  deallog << "   Number of active cells:       "
+         << triangulation.n_active_cells()
+         << std::endl
+         << "   Number of degrees of freedom: "
+         << dof_handler.n_dofs()
+         << std::endl;
+
+
+  // .... test constraint handling
+
+  ConstraintMatrix constraints;
+
+  DoFTools::make_hanging_node_constraints (dof_handler, constraints);
+
+  constraints.close();
+
+  deallog << "   Number of constraints:        "
+          << constraints.n_constraints()
+          << std::endl;
+
+}
+
+
+
+int main ()
+{
+  std::ofstream logfile("fe_nothing_06/output");
+  logfile.precision(2);
+
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  deallog << "Try dim == 1" << std::flush << std::endl;
+  test<1> ();
+
+  deallog << "Try dim == 2" << std::flush << std::endl;
+  test<2> ();
+
+  deallog << "Try dim == 3" << std::flush << std::endl;
+  test<3> ();
+
+  deallog << "OK" << std::endl;
+}
diff --git a/tests/hp/fe_nothing_06/cmp/generic b/tests/hp/fe_nothing_06/cmp/generic
new file mode 100644 (file)
index 0000000..9aeef58
--- /dev/null
@@ -0,0 +1,14 @@
+
+DEAL::Try dim == 1
+DEAL::   Number of active cells:       4
+DEAL::   Number of degrees of freedom: 8
+DEAL::   Number of constraints:        0
+DEAL::Try dim == 2
+DEAL::   Number of active cells:       10
+DEAL::   Number of degrees of freedom: 75
+DEAL::   Number of constraints:        7
+DEAL::Try dim == 3
+DEAL::   Number of active cells:       22
+DEAL::   Number of degrees of freedom: 583
+DEAL::   Number of constraints:        126
+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.