]> https://gitweb.dealii.org/ - dealii.git/commitdiff
New tests.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 8 May 2003 14:54:41 +0000 (14:54 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 8 May 2003 14:54:41 +0000 (14:54 +0000)
git-svn-id: https://svn.dealii.org/trunk@7608 0785d39b-7218-0410-832d-ea1e28bc413d

tests/fe/dgq_1.cc [new file with mode: 0644]
tests/fe/q_4.cc [new file with mode: 0644]
tests/fe/system_1.cc [new file with mode: 0644]

diff --git a/tests/fe/dgq_1.cc b/tests/fe/dgq_1.cc
new file mode 100644 (file)
index 0000000..09bde3f
--- /dev/null
@@ -0,0 +1,82 @@
+//----------------------------  dgq_1.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2003 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
+//    fuqher information on this license.
+//
+//----------------------------  dgq_1.cc  ---------------------------
+
+
+// previously, the FETools::get_interpolation_matrix function would
+// compute its result itself by interpolation. now, the different
+// finite elements do that themselves, if they can. make sure the
+// result doesn't change
+
+#include <base/logstream.h>
+#include <fe/fe_dgq.h>
+#include <fe/fe_tools.h>
+
+#include <fstream>
+#include <string>
+
+#define PRECISION 5
+
+
+
+template<int dim>
+void
+test(const unsigned int degree1,
+     const unsigned int degree2)
+{
+  deallog << "FE_DGQ<" << dim << "> (" << degree1 << ")"
+          << " to FE_DGQ<" << dim << "> (" << degree2 << ")"
+         << std::endl;
+  
+  FE_DGQ<dim> fe1(degree1);
+  FE_DGQ<dim> fe2(degree2);
+
+  FullMatrix<float> m (fe2.dofs_per_cell,
+                       fe1.dofs_per_cell);
+  FETools::get_interpolation_matrix (fe1, fe2, m);
+
+  for (unsigned int i=0; i<m.m(); ++i)
+    {
+      for (unsigned int j=0; j<m.n(); ++j)
+        deallog << m(i,j) << ' ';
+      
+      deallog << std::endl;
+    }
+  
+  deallog << std::endl;
+}
+
+
+int
+main()
+{
+  std::ofstream logfile ("dgq_1.output");
+  logfile.precision (PRECISION);
+  logfile.setf(std::ios::fixed);  
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  for (unsigned int degree1=0; degree1<=4; ++degree1)
+    for (unsigned int degree2=0; degree2<=4; ++degree2)
+      test<1>(degree1, degree2);
+  for (unsigned int degree1=0; degree1<=3; ++degree1)
+    for (unsigned int degree2=0; degree2<=3; ++degree2)
+      test<2>(degree1, degree2);
+  for (unsigned int degree1=0; degree1<=2; ++degree1)
+    for (unsigned int degree2=0; degree2<=2; ++degree2)
+      test<3>(degree1, degree2);
+  
+  return 0;
+}
+
+
+
diff --git a/tests/fe/q_4.cc b/tests/fe/q_4.cc
new file mode 100644 (file)
index 0000000..cfd4726
--- /dev/null
@@ -0,0 +1,82 @@
+//----------------------------  q_4.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2003 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
+//    fuqher information on this license.
+//
+//----------------------------  q_4.cc  ---------------------------
+
+
+// previously, the FETools::get_interpolation_matrix function would
+// compute its result itself by interpolation. now, the different
+// finite elements do that themselves, if they can. make sure the
+// result doesn't change
+
+#include <base/logstream.h>
+#include <fe/fe_q.h>
+#include <fe/fe_tools.h>
+
+#include <fstream>
+#include <string>
+
+#define PRECISION 5
+
+
+
+template<int dim>
+void
+test(const unsigned int degree1,
+     const unsigned int degree2)
+{
+  deallog << "FE_Q<" << dim << "> (" << degree1 << ")"
+          << " to FE_Q<" << dim << "> (" << degree2 << ")"
+         << std::endl;
+  
+  FE_Q<dim> fe1(degree1);
+  FE_Q<dim> fe2(degree2);
+
+  FullMatrix<float> m (fe2.dofs_per_cell,
+                       fe1.dofs_per_cell);
+  FETools::get_interpolation_matrix (fe1, fe2, m);
+
+  for (unsigned int i=0; i<m.m(); ++i)
+    {
+      for (unsigned int j=0; j<m.n(); ++j)
+        deallog << m(i,j) << ' ';
+      
+      deallog << std::endl;
+    }
+  
+  deallog << std::endl;
+}
+
+
+int
+main()
+{
+  std::ofstream logfile ("q_4.output");
+  logfile.precision (PRECISION);
+  logfile.setf(std::ios::fixed);  
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  for (unsigned int degree1=1; degree1<=4; ++degree1)
+    for (unsigned int degree2=1; degree2<=4; ++degree2)
+      test<1>(degree1, degree2);
+  for (unsigned int degree1=1; degree1<=3; ++degree1)
+    for (unsigned int degree2=1; degree2<=3; ++degree2)
+      test<2>(degree1, degree2);
+  for (unsigned int degree1=1; degree1<=2; ++degree1)
+    for (unsigned int degree2=1; degree2<=2; ++degree2)
+      test<3>(degree1, degree2);
+  
+  return 0;
+}
+
+
+
diff --git a/tests/fe/system_1.cc b/tests/fe/system_1.cc
new file mode 100644 (file)
index 0000000..093c0b9
--- /dev/null
@@ -0,0 +1,130 @@
+//----------------------------  system_1.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2003 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
+//    fuqher information on this license.
+//
+//----------------------------  system_1.cc  ---------------------------
+
+
+// previously, the FETools::get_interpolation_matrix function would
+// compute its result itself by interpolation. now, the different
+// finite elements do that themselves, if they can. make sure the
+// result doesn't change, in this case for this function in FESystem
+// that does it's job by calling the respective function in the base
+// elements and then munging the results
+
+#include <base/logstream.h>
+#include <fe/fe_q.h>
+#include <fe/fe_dgq.h>
+#include <fe/fe_dgp.h>
+#include <fe/fe_system.h>
+#include <fe/fe_tools.h>
+
+#include <fstream>
+#include <string>
+
+#define PRECISION 5
+
+
+
+template<int dim>
+void
+check(const FiniteElement<dim> &fe1,
+      const FiniteElement<dim> &fe2)
+{
+  deallog << fe1.get_name () << " to " << fe2.get_name ()
+         << std::endl;
+
+  FullMatrix<float> m (fe2.dofs_per_cell,
+                       fe1.dofs_per_cell);
+  FETools::get_interpolation_matrix (fe1, fe2, m);
+
+  for (unsigned int i=0; i<m.m(); ++i)
+    {
+      for (unsigned int j=0; j<m.n(); ++j)
+        deallog << m(i,j) << ' ';
+      
+      deallog << std::endl;
+    }
+  
+  deallog << std::endl;
+}
+
+
+
+#define CHECK_SYS1(sub1_1,N1_1,sub2_1,N2_1,dim) \
+ { FESystem<dim> fe1(sub1_1, N1_1);   \
+   FESystem<dim> fe2(sub2_1, N2_1);   \
+   check(fe1, fe2); \
+   check(fe2, fe1); \
+ }
+
+#define CHECK_SYS3(sub1,N1,sub2,N2,sub3,N3,dim)   \
+ { FESystem<dim> q(sub1, N1, sub2, N2, sub3, N3); \
+   check(q, q); }
+
+
+int
+main()
+{
+  std::ofstream logfile ("system_1.output");
+  logfile.precision (PRECISION);
+  logfile.setf(std::ios::fixed);  
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  CHECK_SYS1(FE_Q<1>(1),  3,
+             FE_Q<1>(2),  3,
+             1);
+  CHECK_SYS1(FE_DGQ<1>(2),2,
+             FE_DGQ<1>(3),2,
+             1);
+
+  CHECK_SYS1(FE_Q<2>(1),  3,
+             FE_Q<2>(2),  3,
+             2);
+  CHECK_SYS1(FE_DGQ<2>(2),2,
+             FE_DGQ<2>(3),2,
+             2);
+
+  CHECK_SYS1(FE_Q<3>(1),  3,
+             FE_Q<3>(2),  3,
+             3);
+  CHECK_SYS1(FE_DGQ<3>(2),2,
+             FE_DGQ<3>(3),2,
+             3);
+
+                                   // systems in 1d
+  CHECK_SYS3(FE_Q<1>(1),  3,FE_DGQ<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_DGQ<1>(3),1,FE_DGQ<1>(3),1,FE_Q<1>(2),3,1);
+
+                                   // systems in 2d
+  CHECK_SYS3(FE_Q<2>(1),  3,FE_DGQ<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);
+
+                                   // systems in 3d
+  CHECK_SYS3(FE_Q<3>(1),  3,FE_DGQ<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>(3), 1,
+             FE_Q<2>(1), 3,
+             2);
+  CHECK_SYS3(FE_DGQ<2>(3), 1,
+             FESystem<2>(FE_DGQ<2>(3),3), 1,
+             FESystem<2>(FE_Q<2>(2),3,
+                         FE_DGQ<2>(0),1),2,
+             2);
+
+  return 0;
+}
+
+
+

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.