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

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

index f3cbd0d93772938350b6e472224921c8bf453085..19ab17082435c07812d0adb0ac1857b944712804 100644 (file)
@@ -26,7 +26,8 @@ tests_x = hp_dof_handler \
          q_collection_* \
          mapping_collection_* \
          fe_collection_* \
-         continuous_2d_*
+         continuous_2d_* \
+         n_dofs
 
 # from above list of regular expressions, generate the real set of
 # tests
diff --git a/tests/hp/n_dofs.cc b/tests/hp/n_dofs.cc
new file mode 100644 (file)
index 0000000..1106194
--- /dev/null
@@ -0,0 +1,179 @@
+//----------------------------  n_dofs_2d.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.
+//
+//----------------------------  n_dofs_2d.cc  ---------------------------
+
+
+// check that even for wickedly complicated finite elements the
+// hp::DoFHandler allocates the same number of degrees of freedom as a
+// ::DoFHandler, as long as the same element is used on all 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 <fe/fe_dgq.h>
+#include <fe/fe_dgp.h>
+#include <fe/fe_nedelec.h>
+#include <fe/fe_raviart_thomas.h>
+#include <fe/fe_system.h>
+
+#include <fstream>
+
+
+
+template <int dim>
+void test (const FiniteElement<dim> &fe)
+{
+  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 (1);  
+
+  const hp::FECollection<dim> fe_collection (fe);
+
+  hp::DoFHandler<dim> hp_dof_handler(tria);
+  hp_dof_handler.distribute_dofs(fe_collection);
+
+  DoFHandler<dim> dof_handler(tria);
+  dof_handler.distribute_dofs (fe);
+
+  deallog << fe.get_name() << ' ' << dof_handler.n_dofs()
+         << ' ' << hp_dof_handler.n_dofs() << std::endl;
+
+  Assert (dof_handler.n_dofs() == hp_dof_handler.n_dofs(),
+         ExcInternalError());
+}
+
+
+
+#define CHECK(EL,deg,dim)\
+ { FE_ ## EL<dim> EL(deg);   \
+   test(EL); }
+
+#define CHECK_SYS1(sub1,N1,dim) \
+ { FESystem<dim> q(sub1, N1);   \
+   test(q); }
+
+#define CHECK_SYS2(sub1,N1,sub2,N2,dim) \
+ { FESystem<dim> q(sub1, N1, sub2, N2); \
+   test(q); }
+
+#define CHECK_SYS3(sub1,N1,sub2,N2,sub3,N3,dim)   \
+ { FESystem<dim> q(sub1, N1, sub2, N2, sub3, N3); \
+   test(q); }
+
+
+#define CHECK_ALL(EL,deg)\
+ { CHECK(EL,deg,1); \
+   CHECK(EL,deg,2); \
+   CHECK(EL,deg,3); \
+ }
+
+
+
+int main ()
+{
+  std::ofstream logfile("n_dofs_2d/output");
+  logfile.precision(2);
+  
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);  
+
+  CHECK_ALL(Q,1);
+  CHECK_ALL(Q,2);
+  CHECK_ALL(Q,3);
+
+  CHECK_ALL(DGQ,0);
+  CHECK_ALL(DGQ,1);
+  CHECK_ALL(DGQ,3);
+
+  CHECK_ALL(DGP,0);
+  CHECK_ALL(DGP,1);
+  CHECK_ALL(DGP,3);
+
+  CHECK(Nedelec, 1, 2);
+  CHECK(Nedelec, 1, 3);
+
+  CHECK(RaviartThomas, 0, 2);
+  CHECK(RaviartThomas, 1, 2);
+  CHECK(RaviartThomas, 2, 2);
+
+  CHECK(RaviartThomasNodal, 0, 2);
+  CHECK(RaviartThomasNodal, 1, 2);
+  CHECK(RaviartThomasNodal, 2, 2);
+  CHECK(RaviartThomasNodal, 0, 3);
+  CHECK(RaviartThomasNodal, 1, 3);
+  CHECK(RaviartThomasNodal, 2, 3);
+      
+  CHECK_SYS1(FE_Q<1>(1),  3,1);
+  CHECK_SYS1(FE_DGQ<1>(2),2,1);
+  CHECK_SYS1(FE_DGP<1>(3),1,1);
+
+  CHECK_SYS1(FE_Q<2>(1),  3,2);
+  CHECK_SYS1(FE_DGQ<2>(2),2,2);
+  CHECK_SYS1(FE_DGP<2>(3),1,2);
+
+  CHECK_SYS1(FE_Q<3>(1),  3,3);
+  CHECK_SYS1(FE_DGQ<3>(2),2,3);
+  CHECK_SYS1(FE_DGP<3>(3),1,3);
+
+
+  CHECK_SYS2(FE_Q<1>(1),  3,FE_DGQ<1>(2),2,1);
+  CHECK_SYS2(FE_DGQ<1>(2),2,FE_DGP<1>(3),1,1);
+  CHECK_SYS2(FE_DGP<1>(3),1,FE_DGQ<1>(2),2,1);
+
+  CHECK_SYS2(FE_Q<2>(1),  3,FE_DGQ<2>(2),2,2);
+  CHECK_SYS2(FE_DGQ<2>(2),2,FE_DGP<2>(3),1,2);
+  CHECK_SYS2(FE_DGP<2>(3),1,FE_DGQ<2>(2),2,2);
+
+  CHECK_SYS3(FE_Q<1>(1),  3,FE_DGP<1>(3),1,FE_Q<1>(1),3,1);
+  CHECK_SYS3(FE_DGQ<1>(2),2,FE_DGQ<1>(2),2,FE_Q<1>(3),3,1);
+  CHECK_SYS3(FE_DGP<1>(3),1,FE_DGP<1>(3),1,FE_Q<1>(2),3,1);
+
+  CHECK_SYS3(FE_Q<2>(1),  3,FE_DGP<2>(3),1,FE_Q<2>(1),3,2);
+  CHECK_SYS3(FE_DGQ<2>(2),2,FE_DGQ<2>(2),2,FE_Q<2>(3),3,2);
+  CHECK_SYS3(FE_DGP<2>(3),1,FE_DGP<2>(3),1,FE_Q<2>(2),3,2);
+
+  CHECK_SYS3(FE_DGQ<3>(1),  3,FE_DGP<3>(3),1,FE_Q<3>(1),3,3);
+
+                                  // systems of systems  
+  CHECK_SYS3((FESystem<2>(FE_Q<2>(1),3)), 3,
+            FE_DGQ<2>(0), 1,
+            FE_Q<2>(1), 3,
+            2);
+  CHECK_SYS3(FE_DGQ<2>(3), 1,
+            FESystem<2>(FE_DGQ<2>(0),3), 1,
+            FESystem<2>(FE_Q<2>(2),1,
+                        FE_DGQ<2>(0),1),2,
+            2);
+
+                                  // systems with Nedelec elements
+  CHECK_SYS2 (FE_DGQ<2>(3), 1,
+             FE_Nedelec<2>(1), 2,
+             2);
+  CHECK_SYS3(FE_Nedelec<2>(1), 1,
+            FESystem<2>(FE_DGQ<2>(1),2), 1,
+            FESystem<2>(FE_Q<2>(2),1,
+                        FE_Nedelec<2>(1),2),2,
+            2);
+  
+  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.