]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add a quick test for GSL
authorDenis Davydov <davydden@gmail.com>
Thu, 13 Oct 2016 08:50:57 +0000 (10:50 +0200)
committerDenis Davydov <davydden@gmail.com>
Thu, 13 Oct 2016 08:50:57 +0000 (10:50 +0200)
tests/quick_tests/CMakeLists.txt
tests/quick_tests/gsl.cc [new file with mode: 0644]

index 6338fa0df96e1c24394d979abc49d6d486b23705..97bae28fca15e78d88e6a1c65444b5598e9b85ab 100644 (file)
@@ -131,6 +131,11 @@ IF (DEAL_II_WITH_UMFPACK)
   make_quicktest("umfpack" ${_mybuild} "")
 ENDIF()
 
+# Test GSL
+IF (DEAL_II_WITH_GSL)
+  make_quicktest("gsl" ${_mybuild} "")
+ENDIF()
+
 
 
 # A custom test target:
diff --git a/tests/quick_tests/gsl.cc b/tests/quick_tests/gsl.cc
new file mode 100644 (file)
index 0000000..a9d8e19
--- /dev/null
@@ -0,0 +1,55 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2016 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+// Test GSL by running CSpline. Copy-paste of /base/functions_cspline
+// take example from https://www.gnu.org/software/gsl/manual/html_node/Interpolation-Example-programs.html
+
+#include "../tests.h"
+#include <cmath>
+#include <deal.II/base/function_cspline.h>
+
+template <int dim>
+void check()
+{
+  const unsigned int n_points = 10;
+  std::vector<double> x(n_points), y(n_points);
+  for (unsigned int i = 0; i < n_points; i++)
+    {
+      x[i] = i + 0.5 * std::sin (i);
+      y[i] = i + std::cos (i * i);
+    }
+
+  std::vector<double> y_dealii;
+  Functions::CSpline<dim> cspline(x,y);
+  for (double xi = x[0]; xi <= x.back(); xi += 0.01)
+    {
+      const double yi = cspline.value(Point<dim>(xi));
+      y_dealii.push_back(yi);
+    }
+
+  deallog << "Ok"<< std::endl;
+}
+
+int main()
+{
+  std::string logname = "output";
+  std::ofstream logfile(logname.c_str());
+  deallog.attach(logfile);
+  deallog.threshold_double(1.e-10);
+
+  check<1>();
+}
+

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.