]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add tests for ParalutionWrappers::Vector.
authorturcksin <turcksin@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 6 Dec 2013 23:20:56 +0000 (23:20 +0000)
committerturcksin <turcksin@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 6 Dec 2013 23:20:56 +0000 (23:20 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_paralution@31915 0785d39b-7218-0410-832d-ea1e28bc413d

14 files changed:
deal.II/cmake/modules/FindPARALUTION.cmake
deal.II/include/deal.II/lac/paralution_vector.h
tests/lac/paralution_vector_01.cc [new file with mode: 0644]
tests/lac/paralution_vector_01.with_paralution=yes.output [new file with mode: 0644]
tests/lac/paralution_vector_02.cc [new file with mode: 0644]
tests/lac/paralution_vector_02.with_paralution=yes.output [new file with mode: 0644]
tests/lac/paralution_vector_03.cc [new file with mode: 0644]
tests/lac/paralution_vector_03.with_paralution=yes.output [new file with mode: 0644]
tests/lac/paralution_vector_04.cc [new file with mode: 0644]
tests/lac/paralution_vector_04.with_paralution=yes.output [new file with mode: 0644]
tests/lac/paralution_vector_05.cc [new file with mode: 0644]
tests/lac/paralution_vector_05.with_paralution=yes.output [new file with mode: 0644]
tests/lac/paralution_vector_06.cc [new file with mode: 0644]
tests/lac/paralution_vector_06.with_paralution=yes.output [new file with mode: 0644]

index 078d6f94640301da23e4b158aeddb1aa604011e6..c650ab98680fd94118bc5bc6840c91f5845d1457 100644 (file)
@@ -21,7 +21,6 @@
 #
 #   PARALUTION_INCLUDE_DIRS
 #   PARALUTION_LIBRARIES
-#   PARALUTION_LINKER_FLAGS
 #
 
 SET_IF_EMPTY(PARALUTION_DIR "$ENV{PARALUTION_DIR}")
@@ -62,9 +61,6 @@ IF(PARALUTION_FOUND)
   SET(PARALUTION_LIBRARIES
     ${PARALUTION_LIBRARY}
     )
-  SET(PARALUTION_LINKER_FLAGS
-    ${PARALUTION_LINKER_FLAGS}
-    )
 
   MARK_AS_ADVANCED(PARALUTION_DIR)
 ELSE()
index d0537b166d885a1c9edd1e892fcc06055b65050a..70b3370f9e9bbae40c480e0541e049a8f66cfe86 100644 (file)
@@ -280,7 +280,7 @@ namespace ParalutionWrappers
 
 
   template <typename Number>
-  inline size_type Vector<Number>::size() const
+  inline std::size_t Vector<Number>::size() const
   {
     return static_cast<size_type>(local_vector.get_size());
   }
@@ -392,7 +392,7 @@ namespace ParalutionWrappers
   {
     Assert(size()==v.size(),ExcDimensionMismatch(size(),v.size()));
 
-    local_vector.ScaleAdd(-1.,v.paralution_vector());
+    local_vector.ScaleAddScale(1.,v.paralution_vector(),-1.);
 
     return *this;
   }
@@ -402,7 +402,7 @@ namespace ParalutionWrappers
   template <typename Number>
   inline void Vector<Number>::add(const Number s)
   {
-    Assert(Numbers::is_finite(s),ExcNumberNotFinite());
+    Assert(numbers::is_finite(s),ExcNumberNotFinite());
 
     size_type size = local_vector.get_size();
     for (size_type i=0; i<size; ++i)
@@ -414,7 +414,7 @@ namespace ParalutionWrappers
   template <typename Number>
   inline Vector<Number>& Vector<Number>::operator*= (const Number factor)
   {
-    Assert(Numbers::is_finite(factor),ExcNumberNotFinite());
+    Assert(numbers::is_finite(factor),ExcNumberNotFinite());
 
     local_vector.Scale(factor);
 
@@ -426,11 +426,11 @@ namespace ParalutionWrappers
   template <typename Number>
   inline Vector<Number>& Vector<Number>::operator/= (const Number factor)
   {
-    Assert(Numbers::is_finite(factor),ExcNumberNotFinite());
+    Assert(numbers::is_finite(factor),ExcNumberNotFinite());
 
     const Number inv_factor(1./factor);
 
-    Assert(Numbers::is_finite(inv_factor),ExcNumberNotFinite());
+    Assert(numbers::is_finite(inv_factor),ExcNumberNotFinite());
 
     local_vector.Scale(inv_factor);
 
diff --git a/tests/lac/paralution_vector_01.cc b/tests/lac/paralution_vector_01.cc
new file mode 100644 (file)
index 0000000..fdf42a3
--- /dev/null
@@ -0,0 +1,50 @@
+// ---------------------------------------------------------------------
+// $Id: paralution_vector_01.cc 31349 2013-10-20 19:07:06Z maier $
+//
+// Copyright (C) 2013 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 ParalutionWrappers::Vector constructor
+
+#include "../tests.h"
+#include <deal.II/lac/paralution_vector.h>
+#include "paralution.hpp"
+
+template <typename Number>
+void check()
+{
+  ParalutionWrappers::Vector<Number> vector_1;
+  ParalutionWrappers::Vector<Number> vector_2(100);
+
+  deallog << vector_1.size() <<std::endl;
+  deallog << vector_2.size() <<std::endl;
+}
+
+int main()
+{
+  paralution::init_paralution();
+
+  std::ofstream logfile("output");
+  deallog << std::fixed;
+  deallog << std::setprecision(0);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  check<int>();
+  check<float>();
+  check<double>();
+
+  paralution::stop_paralution();
+}
diff --git a/tests/lac/paralution_vector_01.with_paralution=yes.output b/tests/lac/paralution_vector_01.with_paralution=yes.output
new file mode 100644 (file)
index 0000000..18cb6fa
--- /dev/null
@@ -0,0 +1,7 @@
+
+DEAL::0
+DEAL::100
+DEAL::0
+DEAL::100
+DEAL::0
+DEAL::100
diff --git a/tests/lac/paralution_vector_02.cc b/tests/lac/paralution_vector_02.cc
new file mode 100644 (file)
index 0000000..d3d3068
--- /dev/null
@@ -0,0 +1,54 @@
+// ---------------------------------------------------------------------
+// $Id: paralution_vector_01.cc 31349 2013-10-20 19:07:06Z maier $
+//
+// Copyright (C) 2013 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 copy constructor and access elements of ParalutionWrappers::Vector
+
+#include "../tests.h"
+#include <deal.II/lac/paralution_vector.h>
+#include "paralution.hpp"
+
+void check()
+{
+  ParalutionWrappers::Vector<double> vector(10);
+
+  for (unsigned int i=0; i<10; ++i)
+    vector[i] = i;
+
+  ParalutionWrappers::Vector<double> copy_vector(vector);
+
+  for (unsigned int i=0; i<10; ++i)
+    deallog << vector[i] << std::endl;
+
+  for (unsigned int i=0; i<10; ++i)
+    deallog << vector(i)-copy_vector(i) <<std::endl;
+}
+
+int main()
+{
+  paralution::init_paralution();
+
+  std::ofstream logfile("output");
+  deallog << std::fixed;
+  deallog << std::setprecision(0);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  check();
+
+  paralution::stop_paralution();
+}
diff --git a/tests/lac/paralution_vector_02.with_paralution=yes.output b/tests/lac/paralution_vector_02.with_paralution=yes.output
new file mode 100644 (file)
index 0000000..540b0e8
--- /dev/null
@@ -0,0 +1,21 @@
+
+DEAL::0
+DEAL::1
+DEAL::2
+DEAL::3
+DEAL::4
+DEAL::5
+DEAL::6
+DEAL::7
+DEAL::8
+DEAL::9
+DEAL::0
+DEAL::0
+DEAL::0
+DEAL::0
+DEAL::0
+DEAL::0
+DEAL::0
+DEAL::0
+DEAL::0
+DEAL::0
diff --git a/tests/lac/paralution_vector_03.cc b/tests/lac/paralution_vector_03.cc
new file mode 100644 (file)
index 0000000..d4f2986
--- /dev/null
@@ -0,0 +1,55 @@
+// ---------------------------------------------------------------------
+// $Id: paralution_vector_03.cc 31349 2013-10-20 19:07:06Z maier $
+//
+// Copyright (C) 2013 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 ParalutionWrappers::Vector iterator
+
+#include "../tests.h"
+#include <deal.II/lac/paralution_vector.h>
+#include "paralution.hpp"
+
+void check()
+{
+  ParalutionWrappers::Vector<double> vector(10);
+
+  ParalutionWrappers::Vector<double>::iterator it(vector.begin());
+  ParalutionWrappers::Vector<double>::iterator end_it(vector.end());
+
+  for (double i=0.; it!=end_it; ++it, i+=1.)
+    *it = i;
+
+  ParalutionWrappers::Vector<double>::iterator cit(vector.begin());
+  ParalutionWrappers::Vector<double>::iterator cend_it(vector.end());
+
+  for (; cit!=cend_it; ++cit)
+    deallog << *cit << std::endl;
+}
+
+int main()
+{
+  paralution::init_paralution();
+
+  std::ofstream logfile("output");
+  deallog << std::fixed;
+  deallog << std::setprecision(0);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  check();
+
+  paralution::stop_paralution();
+}
diff --git a/tests/lac/paralution_vector_03.with_paralution=yes.output b/tests/lac/paralution_vector_03.with_paralution=yes.output
new file mode 100644 (file)
index 0000000..d8c5cd3
--- /dev/null
@@ -0,0 +1,11 @@
+
+DEAL::0.
+DEAL::1.
+DEAL::2.
+DEAL::3.
+DEAL::4.
+DEAL::5.
+DEAL::6.
+DEAL::7.
+DEAL::8.
+DEAL::9.
diff --git a/tests/lac/paralution_vector_04.cc b/tests/lac/paralution_vector_04.cc
new file mode 100644 (file)
index 0000000..c21c6fd
--- /dev/null
@@ -0,0 +1,54 @@
+// ---------------------------------------------------------------------
+// $Id: paralution_vector_04.cc 31349 2013-10-20 19:07:06Z maier $
+//
+// Copyright (C) 2013 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 reinit for ParalutionWrappers::Vector
+
+#include "../tests.h"
+#include <deal.II/lac/paralution_vector.h>
+#include "paralution.hpp"
+
+void check()
+{
+  ParalutionWrappers::Vector<double> vector(10);
+
+  for (unsigned int i=0; i<10; ++i)
+    vector[i] = i;
+
+  vector.reinit(5);
+
+  for (unsigned int i=0; i<5; ++i)
+    vector[i] = i;
+
+  for (unsigned int i=0; i<vector.size(); ++i)
+    deallog << vector[i] << std::endl;
+}
+
+int main()
+{
+  paralution::init_paralution();
+
+  std::ofstream logfile("output");
+  deallog << std::fixed;
+  deallog << std::setprecision(0);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  check();
+
+  paralution::stop_paralution();
+}
diff --git a/tests/lac/paralution_vector_04.with_paralution=yes.output b/tests/lac/paralution_vector_04.with_paralution=yes.output
new file mode 100644 (file)
index 0000000..ecf123e
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL::0
+DEAL::1
+DEAL::2
+DEAL::3
+DEAL::4
diff --git a/tests/lac/paralution_vector_05.cc b/tests/lac/paralution_vector_05.cc
new file mode 100644 (file)
index 0000000..6e55260
--- /dev/null
@@ -0,0 +1,74 @@
+// ---------------------------------------------------------------------
+// $Id: paralution_vector_04.cc 31349 2013-10-20 19:07:06Z maier $
+//
+// Copyright (C) 2013 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 for ParalutionWrappers::Vector operator*= operator/= operator+=
+// operator-=
+
+#include "../tests.h"
+#include <deal.II/lac/paralution_vector.h>
+#include "paralution.hpp"
+
+void check_1()
+{
+  ParalutionWrappers::Vector<double> vector(10);
+
+  for (unsigned int i=0; i<10; ++i)
+    vector[i] = i;
+  
+  vector *= 10.;
+  vector /= 5.;
+
+  for (unsigned int i=0; i<10; ++i)
+    deallog << vector[i] << std::endl;
+}
+
+void check_2()
+{
+  ParalutionWrappers::Vector<double> vector_1(10);
+  ParalutionWrappers::Vector<double> vector_2(10);
+  ParalutionWrappers::Vector<double> vector_3(10);
+
+  for (unsigned int i=0; i<10; ++i)
+  {
+    vector_1[i] = i;
+    vector_2[i] = 10*i;
+    vector_3[i] = i;
+  }
+
+  vector_1 += vector_2;
+  vector_1 -= vector_3;
+
+  for (unsigned int i=0; i<10; ++i)
+    deallog << vector_1[i] << std::endl;
+}
+
+int main()
+{
+  paralution::init_paralution();
+
+  std::ofstream logfile("output");
+  deallog << std::fixed;
+  deallog << std::setprecision(0);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  check_1();
+  check_2();
+
+  paralution::stop_paralution();
+}
diff --git a/tests/lac/paralution_vector_05.with_paralution=yes.output b/tests/lac/paralution_vector_05.with_paralution=yes.output
new file mode 100644 (file)
index 0000000..4d58f36
--- /dev/null
@@ -0,0 +1,21 @@
+
+DEAL::0
+DEAL::2
+DEAL::4
+DEAL::6
+DEAL::8
+DEAL::10
+DEAL::12
+DEAL::14
+DEAL::16
+DEAL::18
+DEAL::0
+DEAL::10
+DEAL::20
+DEAL::30
+DEAL::40
+DEAL::50
+DEAL::60
+DEAL::70
+DEAL::80
+DEAL::90
diff --git a/tests/lac/paralution_vector_06.cc b/tests/lac/paralution_vector_06.cc
new file mode 100644 (file)
index 0000000..fe00d96
--- /dev/null
@@ -0,0 +1,52 @@
+// ---------------------------------------------------------------------
+// $Id: paralution_vector_06.cc 31349 2013-10-20 19:07:06Z maier $
+//
+// Copyright (C) 2013 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 add for ParalutionWrappers::Vector
+
+
+#include "../tests.h"
+#include <deal.II/lac/paralution_vector.h>
+#include "paralution.hpp"
+
+void check()
+{
+  ParalutionWrappers::Vector<double> vector(10);
+
+  for (unsigned int i=0; i<10; ++i)
+    vector[i] = i;
+
+  vector.add(5.);
+
+  for (unsigned int i=0; i<vector.size(); ++i)
+    deallog << vector[i] << std::endl;
+}
+
+int main()
+{
+  paralution::init_paralution();
+
+  std::ofstream logfile("output");
+  deallog << std::fixed;
+  deallog << std::setprecision(0);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  check();
+
+  paralution::stop_paralution();
+}
diff --git a/tests/lac/paralution_vector_06.with_paralution=yes.output b/tests/lac/paralution_vector_06.with_paralution=yes.output
new file mode 100644 (file)
index 0000000..ccf8cd0
--- /dev/null
@@ -0,0 +1,11 @@
+
+DEAL::5
+DEAL::6
+DEAL::7
+DEAL::8
+DEAL::9
+DEAL::10
+DEAL::11
+DEAL::12
+DEAL::13
+DEAL::14

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.