From 1d5c996c79a25507a03065313ae6260f4a6f01a1 Mon Sep 17 00:00:00 2001 From: turcksin Date: Fri, 6 Dec 2013 23:20:56 +0000 Subject: [PATCH] Add tests for ParalutionWrappers::Vector. git-svn-id: https://svn.dealii.org/branches/branch_paralution@31915 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/cmake/modules/FindPARALUTION.cmake | 4 - .../include/deal.II/lac/paralution_vector.h | 12 +-- tests/lac/paralution_vector_01.cc | 50 +++++++++++++ ...ution_vector_01.with_paralution=yes.output | 7 ++ tests/lac/paralution_vector_02.cc | 54 ++++++++++++++ ...ution_vector_02.with_paralution=yes.output | 21 ++++++ tests/lac/paralution_vector_03.cc | 55 ++++++++++++++ ...ution_vector_03.with_paralution=yes.output | 11 +++ tests/lac/paralution_vector_04.cc | 54 ++++++++++++++ ...ution_vector_04.with_paralution=yes.output | 6 ++ tests/lac/paralution_vector_05.cc | 74 +++++++++++++++++++ ...ution_vector_05.with_paralution=yes.output | 21 ++++++ tests/lac/paralution_vector_06.cc | 52 +++++++++++++ ...ution_vector_06.with_paralution=yes.output | 11 +++ 14 files changed, 422 insertions(+), 10 deletions(-) create mode 100644 tests/lac/paralution_vector_01.cc create mode 100644 tests/lac/paralution_vector_01.with_paralution=yes.output create mode 100644 tests/lac/paralution_vector_02.cc create mode 100644 tests/lac/paralution_vector_02.with_paralution=yes.output create mode 100644 tests/lac/paralution_vector_03.cc create mode 100644 tests/lac/paralution_vector_03.with_paralution=yes.output create mode 100644 tests/lac/paralution_vector_04.cc create mode 100644 tests/lac/paralution_vector_04.with_paralution=yes.output create mode 100644 tests/lac/paralution_vector_05.cc create mode 100644 tests/lac/paralution_vector_05.with_paralution=yes.output create mode 100644 tests/lac/paralution_vector_06.cc create mode 100644 tests/lac/paralution_vector_06.with_paralution=yes.output diff --git a/deal.II/cmake/modules/FindPARALUTION.cmake b/deal.II/cmake/modules/FindPARALUTION.cmake index 078d6f9464..c650ab9868 100644 --- a/deal.II/cmake/modules/FindPARALUTION.cmake +++ b/deal.II/cmake/modules/FindPARALUTION.cmake @@ -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() diff --git a/deal.II/include/deal.II/lac/paralution_vector.h b/deal.II/include/deal.II/lac/paralution_vector.h index d0537b166d..70b3370f9e 100644 --- a/deal.II/include/deal.II/lac/paralution_vector.h +++ b/deal.II/include/deal.II/lac/paralution_vector.h @@ -280,7 +280,7 @@ namespace ParalutionWrappers template - inline size_type Vector::size() const + inline std::size_t Vector::size() const { return static_cast(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 inline void Vector::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 inline Vector& Vector::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 inline Vector& Vector::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 index 0000000000..fdf42a3285 --- /dev/null +++ b/tests/lac/paralution_vector_01.cc @@ -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 +#include "paralution.hpp" + +template +void check() +{ + ParalutionWrappers::Vector vector_1; + ParalutionWrappers::Vector vector_2(100); + + deallog << vector_1.size() <(); + check(); + check(); + + 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 index 0000000000..18cb6fab4e --- /dev/null +++ b/tests/lac/paralution_vector_01.with_paralution=yes.output @@ -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 index 0000000000..d3d3068465 --- /dev/null +++ b/tests/lac/paralution_vector_02.cc @@ -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 +#include "paralution.hpp" + +void check() +{ + ParalutionWrappers::Vector vector(10); + + for (unsigned int i=0; i<10; ++i) + vector[i] = i; + + ParalutionWrappers::Vector 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) < +#include "paralution.hpp" + +void check() +{ + ParalutionWrappers::Vector vector(10); + + ParalutionWrappers::Vector::iterator it(vector.begin()); + ParalutionWrappers::Vector::iterator end_it(vector.end()); + + for (double i=0.; it!=end_it; ++it, i+=1.) + *it = i; + + ParalutionWrappers::Vector::iterator cit(vector.begin()); + ParalutionWrappers::Vector::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 index 0000000000..d8c5cd351e --- /dev/null +++ b/tests/lac/paralution_vector_03.with_paralution=yes.output @@ -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 index 0000000000..c21c6fd418 --- /dev/null +++ b/tests/lac/paralution_vector_04.cc @@ -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 +#include "paralution.hpp" + +void check() +{ + ParalutionWrappers::Vector 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 +#include "paralution.hpp" + +void check_1() +{ + ParalutionWrappers::Vector 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 vector_1(10); + ParalutionWrappers::Vector vector_2(10); + ParalutionWrappers::Vector 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 index 0000000000..4d58f3696f --- /dev/null +++ b/tests/lac/paralution_vector_05.with_paralution=yes.output @@ -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 index 0000000000..fe00d96ed6 --- /dev/null +++ b/tests/lac/paralution_vector_06.cc @@ -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 +#include "paralution.hpp" + +void check() +{ + ParalutionWrappers::Vector vector(10); + + for (unsigned int i=0; i<10; ++i) + vector[i] = i; + + vector.add(5.); + + for (unsigned int i=0; i