]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
New test.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 31 Aug 2001 08:37:33 +0000 (08:37 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 31 Aug 2001 08:37:33 +0000 (08:37 +0000)
git-svn-id: https://svn.dealii.org/trunk@4925 0785d39b-7218-0410-832d-ea1e28bc413d

tests/fe/Makefile.in
tests/fe/numbering.cc [new file with mode: 0644]
tests/fe/numbering.checked [new file with mode: 0644]

index 4f8e48370be17959f78ff429259a6bc37b15752d..9c3dae06a8bebd180725992c4f2a8cfdd7a75c75 100644 (file)
@@ -35,8 +35,9 @@ fe_data_test.exe   : fe_data_test.go $(libraries)
 mapping.exe        : mapping.go      $(libraries)
 mapping_c1.exe     : mapping_c1.go   $(libraries)
 shapes.exe         : shapes.go       $(libraries)
+numbering.exe      : numbering.go    $(libraries)
 
-tests = derivatives fe_data_test mapping mapping_c1 shapes
+tests = derivatives fe_data_test mapping mapping_c1 shapes numbering
 
 ############################################################
 
diff --git a/tests/fe/numbering.cc b/tests/fe/numbering.cc
new file mode 100644 (file)
index 0000000..faa2277
--- /dev/null
@@ -0,0 +1,114 @@
+// $Id$
+// Author: Wolfgang Bangerth, 2001
+//
+// Check the numbering of finite elements
+
+#include <base/logstream.h>
+#include <fe/fe_q.h>
+#include <fe/fe_dgq.h>
+#include <vector>
+#include <fstream>
+
+
+std::ofstream logfile ("numbering.output");
+
+
+template <int dim>
+void check (const FE_Q<dim> &fe)
+{
+  Assert (fe.n_components() == 1, ExcInternalError());
+  
+  std::vector<unsigned int> hierarchic_to_lexicographic_numbering (fe.dofs_per_cell);
+
+  const unsigned int dofs_per_cell = fe.dofs_per_cell;
+                                  // polynomial degree
+  const unsigned int degree = fe.dofs_per_line+1;
+                                  // number of grid points in each direction
+  const unsigned int n = degree+1;
+
+  switch (dim)
+    {
+      case 1:
+      {
+       hierarchic_to_lexicographic_numbering[0] = 0;
+       hierarchic_to_lexicographic_numbering[1] = dofs_per_cell-1;
+       for (unsigned int i=2; i<dofs_per_cell; ++i)
+         hierarchic_to_lexicographic_numbering[i] = i-1;
+
+       break;
+      };
+
+      case 2:
+      {
+       unsigned int next_index = 0;
+                                        // first the four vertices
+       hierarchic_to_lexicographic_numbering[next_index++] = 0;
+       hierarchic_to_lexicographic_numbering[next_index++] = n-1;
+       hierarchic_to_lexicographic_numbering[next_index++] = n*n-1;
+       hierarchic_to_lexicographic_numbering[next_index++] = n*(n-1);
+                                        // first line
+       for (unsigned int i=0; i<fe.dofs_per_line; ++i)
+         hierarchic_to_lexicographic_numbering[next_index++] = 1+i;
+                                        // second line
+       for (unsigned int i=0; i<fe.dofs_per_line; ++i)
+         hierarchic_to_lexicographic_numbering[next_index++] = (2+i)*n-1;
+                                        // third line
+       for (unsigned int i=0; i<fe.dofs_per_line; ++i)
+         hierarchic_to_lexicographic_numbering[next_index++] = n*(n-1)+i+1;
+                                        // fourth line
+       for (unsigned int i=0; i<fe.dofs_per_line; ++i)
+         hierarchic_to_lexicographic_numbering[next_index++] = (1+i)*n;
+                                        // inside quad
+       Assert (fe.dofs_per_quad == fe.dofs_per_line*fe.dofs_per_line, ExcInternalError());
+       for (unsigned int i=0; i<fe.dofs_per_line; ++i)
+         for (unsigned int j=0; j<fe.dofs_per_line; ++j)
+           hierarchic_to_lexicographic_numbering[next_index++] = n*(i+1)+j+1;
+
+       break;
+      };
+
+      default:
+           Assert (false, ExcNotImplemented());
+    };
+  
+                                  // now check with data from the lib
+  const std::vector<unsigned int> &
+    lexicographic_to_hierarchical_numbering = fe.get_renumber();
+  for (unsigned int i=0; i<dofs_per_cell; ++i)
+    {
+      Assert (lexicographic_to_hierarchical_numbering
+             [hierarchic_to_lexicographic_numbering[i]] == i,
+             ExcInternalError());
+      logfile << dim << "d, degree=" << degree << ": "
+             << lexicographic_to_hierarchical_numbering[i]
+             << ' '
+             << hierarchic_to_lexicographic_numbering[i]
+             << std::endl;
+    };
+};
+
+
+
+template <int dim>
+void check_dim ()
+{
+  for (unsigned int degree=1; degree<4; ++degree)
+    {
+      FE_Q<dim> fe(degree);
+      check (fe);
+    };
+};
+
+
+int main ()
+{
+  logfile.precision (2);
+  logfile.setf(std::ios::fixed);  
+  deallog.attach(logfile);
+  deallog.depth_console (0);
+
+  check_dim<1> ();
+  check_dim<2> ();
+};
+
+
diff --git a/tests/fe/numbering.checked b/tests/fe/numbering.checked
new file mode 100644 (file)
index 0000000..446d356
--- /dev/null
@@ -0,0 +1,39 @@
+
+1d, degree=1: 0 0
+1d, degree=1: 1 1
+1d, degree=2: 0 0
+1d, degree=2: 2 2
+1d, degree=2: 1 1
+1d, degree=3: 0 0
+1d, degree=3: 2 3
+1d, degree=3: 3 1
+1d, degree=3: 1 2
+2d, degree=1: 0 0
+2d, degree=1: 1 1
+2d, degree=1: 3 3
+2d, degree=1: 2 2
+2d, degree=2: 0 0
+2d, degree=2: 4 2
+2d, degree=2: 1 8
+2d, degree=2: 7 6
+2d, degree=2: 8 1
+2d, degree=2: 5 5
+2d, degree=2: 3 7
+2d, degree=2: 6 3
+2d, degree=2: 2 4
+2d, degree=3: 0 0
+2d, degree=3: 4 3
+2d, degree=3: 5 15
+2d, degree=3: 1 12
+2d, degree=3: 10 1
+2d, degree=3: 12 2
+2d, degree=3: 13 7
+2d, degree=3: 6 11
+2d, degree=3: 11 13
+2d, degree=3: 14 14
+2d, degree=3: 15 4
+2d, degree=3: 7 8
+2d, degree=3: 3 5
+2d, degree=3: 8 6
+2d, degree=3: 9 9
+2d, degree=3: 2 10

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.