From: David Wells Date: Thu, 3 Jan 2019 21:58:11 +0000 (-0500) Subject: Remove VectorView. X-Git-Tag: v9.1.0-rc1~437^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d44589c7c2c4d83a1a91b000d680463e3d41d3e0;p=dealii.git Remove VectorView. This class was deprecated before the 9.0 release. --- diff --git a/doc/news/changes/incompatibilities/20190111DavidWells b/doc/news/changes/incompatibilities/20190111DavidWells new file mode 100644 index 0000000000..9c338e4a1b --- /dev/null +++ b/doc/news/changes/incompatibilities/20190111DavidWells @@ -0,0 +1,5 @@ +Changed: The class VectorView has been removed. The suggested replacements are +to either use an ArrayView, a BlockVector, or to copy the relevant subset into a +Vector. +
+(David Wells, 2019/01/11) diff --git a/include/deal.II/lac/vector.h b/include/deal.II/lac/vector.h index 7547f044c0..4ba39fcbd9 100644 --- a/include/deal.II/lac/vector.h +++ b/include/deal.II/lac/vector.h @@ -70,9 +70,6 @@ class LAPACKFullMatrix; template class BlockVector; -template -class VectorView; - namespace parallel { namespace internal @@ -1026,11 +1023,6 @@ protected: template friend class LAPACKFullMatrix; - /** - * VectorView will access the pointer. - */ - friend class VectorView; - private: /** * Allocate and align @p values along 64-byte boundaries. The size of the diff --git a/include/deal.II/lac/vector_view.h b/include/deal.II/lac/vector_view.h deleted file mode 100644 index 79e272891b..0000000000 --- a/include/deal.II/lac/vector_view.h +++ /dev/null @@ -1,323 +0,0 @@ -// --------------------------------------------------------------------- -// -// Copyright (C) 2009 - 2018 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.md at -// the top level directory of deal.II. -// -// --------------------------------------------------------------------- - -#ifndef dealii_vector_view_h -#define dealii_vector_view_h - - -#include - -#include -#include - -#include - -#include - -DEAL_II_NAMESPACE_OPEN - - -/*! @addtogroup Vectors - *@{ - */ - -/** - * View of a numerical vector of data. This class provides an interface - * compatible with the Vector class (from which it is inherited), that - * allows fast access to locations of memory already allocated with arrays of - * type Number. - * - * This is in the same style of the vector view in the Trilinos library. - * - * You should consider using the VectorView object ONLY when ALL of the - * following requirements are met: - * - * 1. Your application requires a Vector object. - * - * 2. All you have at your disposal is a Number* pointer. - * - * 3. You are ABSOLUTELY SURE that the above pointer points to a valid area of - * memory of the correct size. - * - * 4. You really believe that making a copy of that memory would be too - * expensive. - * - * 5. You really know what you are doing. - * - * Notice that NO CHECKS are performed on the actual memory, and if you try to - * access illegal areas of memory, your computer will suffer from it. Once - * again, use this class ONLY if you know exactly what you are doing. - * - * Two constructors are provided. One for read-write access, and one for read - * only access, and you are allowed to use this class on objects of type const - * Number*. However you should be aware of the fact that the constness of the - * array pointed to is ignored, which means that you should only use the const - * constructor when the actual object you are constructing is itself a - * constant object. As a corollary, you will be allowed to call even functions - * of the base class that change data of the array; this being a violation of - * the C++ type model, you should make sure that this only happens if it is - * really valid and, in general, if you know what you are doing. - * - * Since this class does not own the memory that you are accessing, you have - * to make sure that the lifetime of the section of memory you are viewing is - * longer than this object. No attempt is made to ensure that this is the - * case. - * - * An example usage of this class is the following: - * - * @code - * // Create an array of length 5; - * double * array = new double[5]; - * // Now create a view of the above array that is compatible with the - * // Vector class - * VectorView view(5, array); - * - * view(1) = 4; - * - * // The following line should output 4. - * cout << array[1] << endl; - * - * // If debug mode is on, then the following triggers an exception: - * view(6) = 4; - * - * // But notice that no checks are performed, so this is legal but WILL - * // NOT work - * VectorView wrong_view(10, array); - * - * // Now no assert will be thrown if you type wrong_view(6), but most - * // likely a segfault will occur. - * view(6) = 4; - * - * // Notice that this construction is legal. It will create a copy of - * // the array. - * const Vector const_copy(view); - * - * // Now this is the correct way to instantiate a constant view of the - * // above vector: - * const VectorView correct_const_copy_view(5, const_copy.begin()); - * - * // While this will compile, BUT WILL NOT COMPLAIN if you try to write - * // on it! - * VectorView wrong_const_copy_view(5, const_copy.begin()); - * - * // Now writing to elements of wrong_const_copy_view is allowed, and - * // will change the same memory as the const_copy object. - * wrong_const_copy_view(1) = 5; - * - * if(copy_view(1) == wrong_const_copy_view(1)) cout << "Tautology"; - * - * @endcode - * - * - * @note Instantiations for this template are provided for @, - * @, @@>, @@>; - * others can be generated in application programs (see the section on - * @ref Instantiations - * in the manual). - * - * @author Luca Heltai, 2009 - * - * @deprecated Use ArrayView instead. - */ -template -class DEAL_II_DEPRECATED VectorView : public Vector -{ -public: - /** - * Declare type for container size. - */ - using size_type = types::global_dof_index; - - /** - * Read write constructor. Takes the size of the vector, just like the - * standard one, but the data is picked starting from the location of the - * pointer @p ptr. - */ - VectorView(const size_type new_size, Number *ptr); - - /** - * The constant constructor is the same as above, however you will not be - * able to access the data for write access. - * - * You should only use this class by constructing it as a const - * VectorView(size, ptr) object. - * - * Undefined behavior will occur if you construct it as a non const object - * or attempt to write on it. - */ - VectorView(const size_type new_size, const Number *ptr); - - /** - * This destructor will only reset the internal sizes and the internal - * pointers, but it will NOT clear the memory. - */ - ~VectorView() override; - - /** - * The reinit function of this object has a behavior which is different from - * the one of the base class. VectorView does not handle memory, and you - * should not attempt to resize the memory that is pointed to by this object - * using the reinit function. You can, however, resize the view that you - * have of the original object. Notice that it is your own responsibility to - * ensure that the memory you are pointing to is big enough. - * - * Similarly to what happens in the base class, if 'omit_zeroing_entries' is - * false, then the entire content of the vector is set to 0, otherwise the - * content of the memory is left unchanged. - * - * Notice that the following snippet of code may not produce what you - * expect: - * - * @code - * // Create a vector of length 1. - * Vector long_vector(1); - * - * // Make a view of it - * VectorView view_of_long_vector(1, long_vector.begin()); - * - * // Resize the original vector to a bigger size - * long_vector.reinit(100); - * - * // And the view, leaving the memory untouched - * view_of_long_vector.reinit(100, true); - * @endcode - * - * In the above case, the Vector::reinit method is called, and a NEW - * area of memory is reserved, possibly not starting at the same place as - * before. However, the VectorView object keeps pointing to the same - * old area. After the two reinits, any call to view_of_long_vector(i), with - * i>0 might cause an attempt to access invalid areas of memory, or might - * function properly, depending on whether or not the system was able to - * allocate some memory consecutively after the original allocation. - * - * In any case, you should not rely on this behavior, and you should only - * call this reinit function if you really know what you are doing. - */ - virtual void - reinit(const size_type N, const bool omit_zeroing_entries = false) override; - - /** - * This reinit function is equivalent to constructing a new object with the - * given size, starting from the pointer ptr. - */ - void - reinit(const size_type N, Number *ptr); - - /** - * This reinit function is equivalent to constructing a new object with the - * given size, starting from the pointer ptr. The same considerations made - * for the constructor apply here. - */ - void - reinit(const size_type N, const Number *ptr); - - /** - * This function is here to prevent memory corruption. It should never be - * called, and will throw an exception if you try to do so. - */ - virtual void - swap(Vector &v) override; -}; - - - -/*@}*/ -/*----------------------- Inline functions ----------------------------------*/ - -#ifndef DOXYGEN - -template -inline VectorView::VectorView(const size_type new_size, Number *ptr) -{ - this->vec_size = new_size; - this->max_vec_size = new_size; - // release the pointer, but do not delete the object pointed to - this->values.release(); - this->values.reset(ptr); -} - - - -template -inline VectorView::VectorView(const size_type new_size, - const Number * ptr) -{ - this->vec_size = new_size; - this->max_vec_size = new_size; - this->values.reset(const_cast(ptr)); -} - - - -template -inline VectorView::~VectorView() -{ - // avoid that the base class releases - // memory it doesn't own - this->vec_size = 0; - this->max_vec_size = 0; - - // release the pointer, but do not delete the object pointed to - this->values.release(); -} - - -template -inline void -VectorView::reinit(const size_type N, const bool omit_zeroing_entries) -{ - this->vec_size = N; - this->max_vec_size = N; - if (omit_zeroing_entries == false) - Vector::operator=(static_cast(0)); -} - - -template -inline void -VectorView::reinit(const size_type new_size, Number *ptr) -{ - this->vec_size = new_size; - this->max_vec_size = new_size; - // release the pointer, but do not delete the object pointed to - this->values.release(); - this->values.reset(ptr); -} - - -template -inline void -VectorView::reinit(const size_type new_size, const Number *ptr) -{ - this->vec_size = new_size; - this->max_vec_size = new_size; - // release the pointer, but do not delete the object pointed to - this->values.release(); - this->values.reset(const_cast(ptr)); -} - - -template -inline void -VectorView::swap(Vector &) -{ - AssertThrow(false, ExcMessage("Can't swap a VectorView with a Vector!")); -} - -#endif - -DEAL_II_NAMESPACE_CLOSE - -#endif diff --git a/include/deal.II/multigrid/mg_transfer.templates.h b/include/deal.II/multigrid/mg_transfer.templates.h index 882b6c5745..1d657c19ed 100644 --- a/include/deal.II/multigrid/mg_transfer.templates.h +++ b/include/deal.II/multigrid/mg_transfer.templates.h @@ -29,7 +29,6 @@ #include #include #include -#include #include #include diff --git a/source/lac/CMakeLists.txt b/source/lac/CMakeLists.txt index 738c2ed38a..2cecfbc24f 100644 --- a/source/lac/CMakeLists.txt +++ b/source/lac/CMakeLists.txt @@ -53,7 +53,6 @@ SET(_unity_include_src tridiagonal_matrix.cc vector.cc vector_memory.cc - vector_view.cc ) SET(_separate_src @@ -81,7 +80,6 @@ SET(_inst vector.inst.in vector_memory.inst.in vector_memory_release.inst.in - vector_view.inst.in ) diff --git a/source/lac/vector_view.cc b/source/lac/vector_view.cc deleted file mode 100644 index 11b4f1f200..0000000000 --- a/source/lac/vector_view.cc +++ /dev/null @@ -1,22 +0,0 @@ -// --------------------------------------------------------------------- -// -// Copyright (C) 1999 - 2014 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.md at -// the top level directory of deal.II. -// -// --------------------------------------------------------------------- - -#include - -DEAL_II_NAMESPACE_OPEN - -#include "vector_view.inst" - -DEAL_II_NAMESPACE_CLOSE diff --git a/source/lac/vector_view.inst.in b/source/lac/vector_view.inst.in deleted file mode 100644 index 22c97b97f9..0000000000 --- a/source/lac/vector_view.inst.in +++ /dev/null @@ -1,26 +0,0 @@ -// --------------------------------------------------------------------- -// -// Copyright (C) 1999 - 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.md at -// the top level directory of deal.II. -// -// --------------------------------------------------------------------- - - - -for (SCALAR : REAL_SCALARS) - { - template class VectorView; - } - -for (SCALAR : COMPLEX_SCALARS) - { - template class VectorView; - } diff --git a/tests/lac/vector_accumulation_02.cc b/tests/lac/vector_accumulation_02.cc index a9895d36ab..4704b820ed 100644 --- a/tests/lac/vector_accumulation_02.cc +++ b/tests/lac/vector_accumulation_02.cc @@ -15,13 +15,15 @@ // check that the inner product is exactly the same down to roundoff for -// various vectors. Due to vectorization and its requirements for alignment, -// we also test that the result does not depend on the alignment of any of the -// vectors by choosing among several start locations of a vector relative to a -// data array allocated as usual. +// various vectors. +// +// It was previously possible to create an unaligned view (a VectorView +// object) into a Vector: an original goal of this test was to verify that +// unaligned dot products were identical to aligned ones, but since Vector now +// uses AlignedVector to store its data it is no longer possible to test this. #include -#include +#include #include "../tests.h" @@ -46,8 +48,10 @@ check_norms() for (unsigned int shift1 = 0; shift1 < 8; ++shift1) for (unsigned int shift2 = 0; shift2 < 8; ++shift2) { - VectorView v1(size, larger1.begin() + shift1); - VectorView v2(size, larger2.begin() + shift2); + Vector v1(larger1.begin() + shift1, + larger1.begin() + shift1 + size); + Vector v2(larger2.begin() + shift2, + larger2.begin() + shift2 + size); for (unsigned int i = 0; i < size; ++i) { v1(i) = in1(i); diff --git a/tests/lac/vector_view.cc b/tests/lac/vector_view.cc deleted file mode 100644 index 1d78e9c0d5..0000000000 --- a/tests/lac/vector_view.cc +++ /dev/null @@ -1,81 +0,0 @@ -// --------------------------------------------------------------------- -// -// Copyright (C) 1998 - 2017 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.md at -// the top level directory of deal.II. -// -// --------------------------------------------------------------------- - - - -#include -#include - -#include "../tests.h" - -const unsigned int N = 10; -unsigned int check_point = 0; - -template -void -print(const Vector &v) -{ - for (unsigned int i = 0; i < v.size(); ++i) - deallog << v(i) << '\t'; - deallog << std::endl; -} - -template -void -fill(T &a) -{ - for (unsigned int i = 0; i < a.size(); ++i) - a(i) = i; -} - -int -main() -{ - std::ofstream logfile("output"); - deallog << std::fixed; - deallog << std::setprecision(2); - deallog.attach(logfile); - - Vector v1(N); - fill(v1); - - deallog << "Vector" << std::endl; - print(v1); - - VectorView v2(N, v1.begin()); - deallog << "Vector View" << std::endl; - print(v2); - - v2(4) = 0; - deallog << "Modified element 4" << std::endl; - deallog << "Vector" << std::endl; - print(v1); - - deallog << "Vector View" << std::endl; - print(v2); - - // Const vector. - const Vector v3(v1); - - deallog << "const Vector" << std::endl; - print(v3); - - VectorView v4(N, v3.begin()); - deallog << "const Vector View" << std::endl; - print(v4); - - v4.reinit(N, v1.begin()); - v4.reinit(N, v3.begin()); -} diff --git a/tests/lac/vector_view.output b/tests/lac/vector_view.output deleted file mode 100644 index 0d4e0c9df6..0000000000 --- a/tests/lac/vector_view.output +++ /dev/null @@ -1,14 +0,0 @@ - -DEAL::Vector -DEAL::0 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 -DEAL::Vector View -DEAL::0 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 -DEAL::Modified element 4 -DEAL::Vector -DEAL::0 1.00 2.00 3.00 0 5.00 6.00 7.00 8.00 9.00 -DEAL::Vector View -DEAL::0 1.00 2.00 3.00 0 5.00 6.00 7.00 8.00 9.00 -DEAL::const Vector -DEAL::0 1.00 2.00 3.00 0 5.00 6.00 7.00 8.00 9.00 -DEAL::const Vector View -DEAL::0 1.00 2.00 3.00 0 5.00 6.00 7.00 8.00 9.00 diff --git a/tests/lac/vector_view_01.cc b/tests/lac/vector_view_01.cc deleted file mode 100644 index 8da1873a0b..0000000000 --- a/tests/lac/vector_view_01.cc +++ /dev/null @@ -1,65 +0,0 @@ -// --------------------------------------------------------------------- -// -// Copyright (C) 1998 - 2017 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.md at -// the top level directory of deal.II. -// -// --------------------------------------------------------------------- - -// check VectorView::checkReadOnlyConstructor - -#include -#include - -#include "../tests.h" - -template -void -checkReadOnlyConstructor(const Vector &V) -{ - deallog << "Read-only constructor" << std::endl; - VectorView VV(V.size(), V.begin()); - - deallog << "Printing Vector" << std::endl; - for (unsigned int i = 0; i < V.size(); ++i) - deallog << V(i) << '\t'; - deallog << std::endl; - - deallog << "Printing VectorView pointing to Vector" - << std::endl; - for (unsigned int i = 0; i < VV.size(); ++i) - deallog << VV(i) << '\t'; - deallog << std::endl; - - /* deallog << "Incrementing Vector elements using Read-only handle of - VectorView" << std::endl; deallog << "Function fails beyond this - point" << std::endl; for (unsigned int i=0; i V1(5); - V1(0) = 1; - V1(1) = 2; - V1(2) = 3; - V1(3) = 4; - V1(4) = 5; - - const Vector V2(V1); - - checkReadOnlyConstructor(V2); -} diff --git a/tests/lac/vector_view_01.output b/tests/lac/vector_view_01.output deleted file mode 100644 index 7ab6f1aa86..0000000000 --- a/tests/lac/vector_view_01.output +++ /dev/null @@ -1,6 +0,0 @@ - -DEAL::Read-only constructor -DEAL::Printing Vector -DEAL::1.00 2.00 3.00 4.00 5.00 -DEAL::Printing VectorView pointing to Vector -DEAL::1.00 2.00 3.00 4.00 5.00 diff --git a/tests/lac/vector_view_02.cc b/tests/lac/vector_view_02.cc deleted file mode 100644 index 55b6ec0506..0000000000 --- a/tests/lac/vector_view_02.cc +++ /dev/null @@ -1,79 +0,0 @@ -// --------------------------------------------------------------------- -// -// Copyright (C) 1998 - 2017 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.md at -// the top level directory of deal.II. -// -// --------------------------------------------------------------------- - -// check VectorView::checkReinit1 - -#include -#include - -#include "../tests.h" - -template -void -checkReinit1(const size_type N, const bool fast = false) -{ - deallog << "Reinit with const size and fast" << std::endl; - - deallog - << "Creating Vector of size N+10 and filling with values 1 to N+10" - << std::endl; - - Vector V(N + 10); - for (unsigned int i = 0; i < V.size(); i++) - V(i) = i + 1; - - deallog - << "Creating VectorView of size N+10 pointing to Vector" - << std::endl; - VectorView VV(V.size(), V.begin()); - - deallog << "Printing Vector" << std::endl; - for (unsigned int i = 0; i < V.size(); ++i) - deallog << V(i) << '\t'; - deallog << std::endl; - - deallog << "Printing VectorView pointing to Vector" - << std::endl; - for (unsigned int i = 0; i < VV.size(); ++i) - deallog << VV(i) << '\t'; - deallog << std::endl; - - deallog << "Reinit VectorView to size N from N+10 with fast=" << fast - << std::endl; - VV.reinit(N, fast); - - deallog << "Printing Vector" << std::endl; - for (unsigned int i = 0; i < V.size(); ++i) - deallog << V(i) << '\t'; - deallog << std::endl; - - deallog << "Printing VectorView pointing to Vector" - << std::endl; - for (unsigned int i = 0; i < VV.size(); ++i) - deallog << VV(i) << '\t'; - deallog << std::endl; -} - -int -main() -{ - std::ofstream logfile("output"); - deallog << std::fixed; - deallog << std::setprecision(2); - deallog.attach(logfile); - - checkReinit1(10, false); - checkReinit1(10, true); -} diff --git a/tests/lac/vector_view_02.output b/tests/lac/vector_view_02.output deleted file mode 100644 index 46a51699ce..0000000000 --- a/tests/lac/vector_view_02.output +++ /dev/null @@ -1,25 +0,0 @@ - -DEAL::Reinit with const size and fast -DEAL::Creating Vector of size N+10 and filling with values 1 to N+10 -DEAL::Creating VectorView of size N+10 pointing to Vector -DEAL::Printing Vector -DEAL::1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 -DEAL::Printing VectorView pointing to Vector -DEAL::1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 -DEAL::Reinit VectorView to size N from N+10 with fast=0 -DEAL::Printing Vector -DEAL::0 0 0 0 0 0 0 0 0 0 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 -DEAL::Printing VectorView pointing to Vector -DEAL::0 0 0 0 0 0 0 0 0 0 -DEAL::Reinit with const size and fast -DEAL::Creating Vector of size N+10 and filling with values 1 to N+10 -DEAL::Creating VectorView of size N+10 pointing to Vector -DEAL::Printing Vector -DEAL::1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 -DEAL::Printing VectorView pointing to Vector -DEAL::1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 -DEAL::Reinit VectorView to size N from N+10 with fast=1 -DEAL::Printing Vector -DEAL::1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 -DEAL::Printing VectorView pointing to Vector -DEAL::1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 diff --git a/tests/lac/vector_view_03.cc b/tests/lac/vector_view_03.cc deleted file mode 100644 index b45f2858d9..0000000000 --- a/tests/lac/vector_view_03.cc +++ /dev/null @@ -1,92 +0,0 @@ -// --------------------------------------------------------------------- -// -// Copyright (C) 1998 - 2017 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.md at -// the top level directory of deal.II. -// -// --------------------------------------------------------------------- - -// check VectorView::checkReinit3 - -#include -#include - -#include "../tests.h" - -template -void -checkReinit3(const Vector &V) -{ - deallog - << "Reinit a ReadOnly VectorView with const Vector and const size" - << std::endl; - - deallog - << "Creating dummy Vector of size V.size() and filling with zeros" - << std::endl; - - Vector _V(V.size()); - for (unsigned int i = 0; i < _V.size(); i++) - _V(i) = 0; - - deallog << "Creating VectorView pointing to dummy Vector" - << std::endl; - VectorView VV(_V.size(), _V.begin()); - - deallog << "Printing dummy Vector" << std::endl; - for (unsigned int i = 0; i < _V.size(); ++i) - deallog << _V(i) << '\t'; - deallog << std::endl; - - deallog << "Printing VectorView pointing to dummy Vector" - << std::endl; - for (unsigned int i = 0; i < VV.size(); ++i) - deallog << VV(i) << '\t'; - deallog << std::endl; - - deallog << "Reinit VectorView to half of Vector" << std::endl; - VV.reinit(V.size() / 2, V.begin()); - - deallog << "Printing Vector" << std::endl; - for (unsigned int i = 0; i < V.size(); ++i) - deallog << V(i) << '\t'; - deallog << std::endl; - - deallog << "Printing VectorView pointing to half of Vector" - << std::endl; - for (unsigned int i = 0; i < VV.size(); ++i) - deallog << VV(i) << '\t'; - deallog << std::endl; - - /* deallog << "Incrementing Vector elements using Read-only handle of - VectorView" << std::endl; deallog << "Function fails beyond this - point" << std::endl; for (unsigned int i=0; i V1(5); - V1(0) = 1; - V1(1) = 2; - V1(2) = 3; - V1(3) = 4; - V1(4) = 5; - - const Vector V2(V1); - - checkReinit3(V2); -} diff --git a/tests/lac/vector_view_03.output b/tests/lac/vector_view_03.output deleted file mode 100644 index cfac6a7daf..0000000000 --- a/tests/lac/vector_view_03.output +++ /dev/null @@ -1,13 +0,0 @@ - -DEAL::Reinit a ReadOnly VectorView with const Vector and const size -DEAL::Creating dummy Vector of size V.size() and filling with zeros -DEAL::Creating VectorView pointing to dummy Vector -DEAL::Printing dummy Vector -DEAL::0 0 0 0 0 -DEAL::Printing VectorView pointing to dummy Vector -DEAL::0 0 0 0 0 -DEAL::Reinit VectorView to half of Vector -DEAL::Printing Vector -DEAL::1.00 2.00 3.00 4.00 5.00 -DEAL::Printing VectorView pointing to half of Vector -DEAL::1.00 2.00 diff --git a/tests/lac/vector_view_04.cc b/tests/lac/vector_view_04.cc deleted file mode 100644 index 3a07b25145..0000000000 --- a/tests/lac/vector_view_04.cc +++ /dev/null @@ -1,96 +0,0 @@ -// --------------------------------------------------------------------- -// -// Copyright (C) 1998 - 2017 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.md at -// the top level directory of deal.II. -// -// --------------------------------------------------------------------- - -// check VectorView::checkReinit2 - -#include -#include - -#include "../tests.h" - -template -void -checkReinit2(Vector &V) -{ - deallog - << "Reinit a ReadWrite VectorView with Vector and const size" - << std::endl; - - deallog - << "Creating dummy Vector of size V.size() and filling with zeros" - << std::endl; - - Vector _V(V.size()); - for (unsigned int i = 0; i < _V.size(); i++) - _V(i) = 0; - - deallog << "Creating VectorView pointing to dummy Vector" - << std::endl; - VectorView VV(_V.size(), _V.begin()); - - deallog << "Printing dummy Vector" << std::endl; - for (unsigned int i = 0; i < _V.size(); ++i) - deallog << _V(i) << '\t'; - deallog << std::endl; - - deallog << "Printing VectorView pointing to dummy Vector" - << std::endl; - for (unsigned int i = 0; i < VV.size(); ++i) - deallog << VV(i) << '\t'; - deallog << std::endl; - - deallog << "Reinit VectorView to half of Vector" << std::endl; - VV.reinit(V.size() / 2, V.begin()); - - deallog << "Printing Vector" << std::endl; - for (unsigned int i = 0; i < V.size(); ++i) - deallog << V(i) << '\t'; - deallog << std::endl; - - deallog << "Printing VectorView pointing to half of Vector" - << std::endl; - for (unsigned int i = 0; i < VV.size(); ++i) - deallog << VV(i) << '\t'; - deallog << std::endl; - - deallog - << "Incrementing Vector elements using Read-write handle of VectorView" - << std::endl; - for (unsigned int i = 0; i < VV.size(); ++i) - VV(i) = VV(i) + 1; - - deallog << "Printing modified Vector" << std::endl; - for (unsigned int i = 0; i < V.size(); ++i) - deallog << V(i) << '\t'; - deallog << std::endl; -} - -int -main() -{ - std::ofstream logfile("output"); - deallog << std::fixed; - deallog << std::setprecision(2); - deallog.attach(logfile); - - Vector V1(5); - V1(0) = 1; - V1(1) = 2; - V1(2) = 3; - V1(3) = 4; - V1(4) = 5; - - checkReinit2(V1); -} diff --git a/tests/lac/vector_view_04.output b/tests/lac/vector_view_04.output deleted file mode 100644 index 19d52f0f9a..0000000000 --- a/tests/lac/vector_view_04.output +++ /dev/null @@ -1,16 +0,0 @@ - -DEAL::Reinit a ReadWrite VectorView with Vector and const size -DEAL::Creating dummy Vector of size V.size() and filling with zeros -DEAL::Creating VectorView pointing to dummy Vector -DEAL::Printing dummy Vector -DEAL::0 0 0 0 0 -DEAL::Printing VectorView pointing to dummy Vector -DEAL::0 0 0 0 0 -DEAL::Reinit VectorView to half of Vector -DEAL::Printing Vector -DEAL::1.00 2.00 3.00 4.00 5.00 -DEAL::Printing VectorView pointing to half of Vector -DEAL::1.00 2.00 -DEAL::Incrementing Vector elements using Read-write handle of VectorView -DEAL::Printing modified Vector -DEAL::2.00 3.00 3.00 4.00 5.00 diff --git a/tests/lac/vector_view_05.cc b/tests/lac/vector_view_05.cc deleted file mode 100644 index 25f7fb26db..0000000000 --- a/tests/lac/vector_view_05.cc +++ /dev/null @@ -1,69 +0,0 @@ -// --------------------------------------------------------------------- -// -// Copyright (C) 1998 - 2017 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.md at -// the top level directory of deal.II. -// -// --------------------------------------------------------------------- - -// check VectorView::checkReadWriteConstructor - -#include -#include - -#include "../tests.h" - -template -void -checkReadWriteConstructor(Vector &V) -{ - deallog << "Read-write constructor" << std::endl; - VectorView VV(V.size(), V.begin()); - - deallog << "Printing Vector" << std::endl; - for (unsigned int i = 0; i < V.size(); ++i) - deallog << V(i) << '\t'; - deallog << std::endl; - - deallog << "Printing VectorView pointing to Vector" - << std::endl; - for (unsigned int i = 0; i < VV.size(); ++i) - deallog << VV(i) << '\t'; - deallog << std::endl; - - deallog - << "Incrementing Vector elements using Read-write handle of VectorView" - << std::endl; - for (unsigned int i = 0; i < VV.size(); ++i) - VV(i) = VV(i) + 1; - - deallog << "Printing modified Vector" << std::endl; - for (unsigned int i = 0; i < V.size(); ++i) - deallog << V(i) << '\t'; - deallog << std::endl; -} - -int -main() -{ - std::ofstream logfile("output"); - deallog << std::fixed; - deallog << std::setprecision(2); - deallog.attach(logfile); - - Vector V1(5); - V1(0) = 1; - V1(1) = 2; - V1(2) = 3; - V1(3) = 4; - V1(4) = 5; - - checkReadWriteConstructor(V1); -} diff --git a/tests/lac/vector_view_05.output b/tests/lac/vector_view_05.output deleted file mode 100644 index e3fa623e5b..0000000000 --- a/tests/lac/vector_view_05.output +++ /dev/null @@ -1,9 +0,0 @@ - -DEAL::Read-write constructor -DEAL::Printing Vector -DEAL::1.00 2.00 3.00 4.00 5.00 -DEAL::Printing VectorView pointing to Vector -DEAL::1.00 2.00 3.00 4.00 5.00 -DEAL::Incrementing Vector elements using Read-write handle of VectorView -DEAL::Printing modified Vector -DEAL::2.00 3.00 4.00 5.00 6.00