]> https://gitweb.dealii.org/ - dealii.git/commitdiff
New test
authorThomas Wick <twick@ices.utexas.edu>
Fri, 27 Aug 2010 08:42:10 +0000 (08:42 +0000)
committerThomas Wick <twick@ices.utexas.edu>
Fri, 27 Aug 2010 08:42:10 +0000 (08:42 +0000)
git-svn-id: https://svn.dealii.org/trunk@21741 0785d39b-7218-0410-832d-ea1e28bc413d

tests/base/functions_03.cc [new file with mode: 0644]
tests/base/functions_03/cmp/generic [new file with mode: 0644]

diff --git a/tests/base/functions_03.cc b/tests/base/functions_03.cc
new file mode 100644 (file)
index 0000000..90d3ceb
--- /dev/null
@@ -0,0 +1,173 @@
+//-----------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2007, 2008 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.
+//
+//-----------------------------------------------------------------------------
+
+// Checking the PillowFunction
+
+#include "../tests.h"
+#include <base/data_out_base.h>
+#include <base/logstream.h>
+#include <base/quadrature_lib.h>
+#include <base/function_lib.h>
+#include <lac/vector.h>
+
+#include <vector>
+#include <iomanip>
+#include <fstream>
+#include <string>
+
+
+
+template <int dim>
+void check_value (const Function<dim>& f)
+{
+  Point<dim> p;
+  for (unsigned int i=0; i<dim; i++)
+    p[i] = i;
+  
+  deallog << f.value(p) << std::endl;
+  deallog << "values checked" << std::endl;
+
+}
+
+template <int dim>
+void check_value_list (const Function<dim>& f)
+{
+  const unsigned int max_number_of_points = 5;
+  std::vector< Point<dim> >  points(max_number_of_points);
+  
+  for(unsigned int i=0; i<max_number_of_points; ++i)
+  {
+    Point<dim> p;
+    for(unsigned int j=0; j<dim; ++j)
+      p[j]=i+1;
+    
+    points[i] = p;
+  }
+  std::vector< double > values(max_number_of_points);
+  f.value_list(points, values);
+
+  for(unsigned int j=0; j<max_number_of_points; ++j)
+    deallog << values[j] << std::endl; 
+
+  deallog << " value_list checked" << std::endl;
+}
+
+
+template <int dim>
+void check_gradient (const Function<dim>& f)
+{
+  Point<dim> p;
+  for (unsigned int i=0; i<dim; i++)
+    p[i] = i;
+  
+  deallog << f.gradient(p) << std::endl;
+  deallog << " gradients checked" << std::endl;
+}
+
+template <int dim>
+void check_gradient_list (const Function<dim>& f)
+{
+  const unsigned int max_number_of_points = 5;
+  std::vector< Point<dim> >  points(max_number_of_points);
+  
+  for(unsigned int i=0; i<max_number_of_points; ++i)
+  {
+    Point<dim> p;
+    for(unsigned int j=0; j<dim; ++j)
+      p[j]=i+1;
+    
+    points[i] = p;
+  }
+  std::vector< Tensor<1,dim> > tensors(max_number_of_points);
+  f.gradient_list(points, tensors);
+
+  for(unsigned int j=0; j<max_number_of_points; ++j)
+    deallog << tensors[j] << std::endl; 
+
+  deallog << " gradient_list checked" << std::endl;
+}
+
+
+template <int dim>
+void check_laplacian (const Function<dim>& f)
+{
+  Point<dim> p;
+  for (unsigned int i=0; i<dim; i++)
+    p[i] = i;
+  
+  deallog << f.laplacian(p) << std::endl;
+  deallog << " laplacians checked" << std::endl;
+}
+
+
+template <int dim>
+void check_laplacian_list (const Function<dim>& f)
+{
+  const unsigned int max_number_of_points = 5;
+  std::vector< Point<dim> >  points(max_number_of_points);
+  
+  for(unsigned int i=0; i<max_number_of_points; ++i)
+  {
+    Point<dim> p;
+    for(unsigned int j=0; j<dim; ++j)
+      p[j]=i+1;
+    
+    points[i] = p;
+  }
+  std::vector< double > values(max_number_of_points);
+  f.laplacian_list(points, values);
+
+  for(unsigned int j=0; j<max_number_of_points; ++j)
+    deallog << values[j] << std::endl; 
+  deallog << " laplacian_list checked" << std::endl;
+}
+
+
+int main()
+{
+  std::ofstream logfile("functions_03/output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+  
+  deallog << "Functions PillowFunction" << std::endl;
+  check_value (Functions::PillowFunction<1>());
+  check_value (Functions::PillowFunction<2>());
+  check_value (Functions::PillowFunction<3>());
+  
+  check_value_list (Functions::PillowFunction<1>());
+  check_value_list (Functions::PillowFunction<2>());
+  check_value_list (Functions::PillowFunction<3>());
+  
+  check_gradient (Functions::PillowFunction<1>());
+  check_gradient (Functions::PillowFunction<2>());
+  check_gradient (Functions::PillowFunction<3>());
+  
+  check_gradient_list (Functions::PillowFunction<1>());
+  check_gradient_list (Functions::PillowFunction<2>());
+  check_gradient_list (Functions::PillowFunction<3>());
+  
+  check_laplacian (Functions::PillowFunction<1>());
+  check_laplacian (Functions::PillowFunction<2>());
+  check_laplacian (Functions::PillowFunction<3>());
+  
+  check_laplacian_list (Functions::PillowFunction<1>());
+  check_laplacian_list (Functions::PillowFunction<2>());
+  check_laplacian_list (Functions::PillowFunction<3>());
+
+     
+}
+
+
+
diff --git a/tests/base/functions_03/cmp/generic b/tests/base/functions_03/cmp/generic
new file mode 100644 (file)
index 0000000..06146da
--- /dev/null
@@ -0,0 +1,74 @@
+
+DEAL::Functions PillowFunction
+DEAL::1.00000
+DEAL::values checked
+DEAL::0
+DEAL::values checked
+DEAL::0
+DEAL::values checked
+DEAL::0
+DEAL::-3.00000
+DEAL::-8.00000
+DEAL::-15.0000
+DEAL::-24.0000
+DEAL:: value_list checked
+DEAL::0
+DEAL::9.00000
+DEAL::64.0000
+DEAL::225.000
+DEAL::576.000
+DEAL:: value_list checked
+DEAL::0
+DEAL::-27.0000
+DEAL::-512.000
+DEAL::-3375.00
+DEAL::-13824.0
+DEAL:: value_list checked
+DEAL::0.00000
+DEAL:: gradients checked
+DEAL::0.00000 -2.00000
+DEAL:: gradients checked
+DEAL::0.00000 6.00000 0.00000
+DEAL:: gradients checked
+DEAL::-2.00000
+DEAL::-4.00000
+DEAL::-6.00000
+DEAL::-8.00000
+DEAL::-10.0000
+DEAL:: gradient_list checked
+DEAL::0.00000 0.00000
+DEAL::12.0000 12.0000
+DEAL::48.0000 48.0000
+DEAL::120.000 120.000
+DEAL::240.000 240.000
+DEAL:: gradient_list checked
+DEAL::0.00000 0.00000 0.00000
+DEAL::-36.0000 -36.0000 -36.0000
+DEAL::-384.000 -384.000 -384.000
+DEAL::-1800.00 -1800.00 -1800.00
+DEAL::-5760.00 -5760.00 -5760.00
+DEAL:: gradient_list checked
+DEAL::-2.00000
+DEAL:: laplacians checked
+DEAL::-2.00000
+DEAL:: laplacians checked
+DEAL::6.00000
+DEAL:: laplacians checked
+DEAL::-2.00000
+DEAL::-2.00000
+DEAL::-2.00000
+DEAL::-2.00000
+DEAL::-2.00000
+DEAL:: laplacian_list checked
+DEAL::0
+DEAL::12.0000
+DEAL::32.0000
+DEAL::60.0000
+DEAL::96.0000
+DEAL:: laplacian_list checked
+DEAL::0
+DEAL::-54.0000
+DEAL::-384.000
+DEAL::-1350.00
+DEAL::-3456.00
+DEAL:: laplacian_list checked

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.