From 34c83ff39d903eec3dbe8e387f85aabc3fe92fc6 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Tue, 23 Jun 2020 00:15:51 -0400 Subject: [PATCH] Remove VectorSlice --- include/deal.II/base/vector_slice.h | 114 +-------------------------- tests/base/slice_vector.cc | 64 --------------- tests/base/slice_vector.debug.output | 4 - tests/integrators/advection_01.cc | 35 ++------ tests/integrators/divergence_01.cc | 13 +-- tests/integrators/elasticity_01.cc | 73 +++-------------- tests/integrators/elasticity_02.cc | 19 +---- tests/integrators/grad_div_01.cc | 73 +++-------------- tests/integrators/laplacian_01.cc | 73 +++-------------- 9 files changed, 56 insertions(+), 412 deletions(-) delete mode 100644 tests/base/slice_vector.cc delete mode 100644 tests/base/slice_vector.debug.output diff --git a/include/deal.II/base/vector_slice.h b/include/deal.II/base/vector_slice.h index 4cdecf5d64..2e5fadf5b8 100644 --- a/include/deal.II/base/vector_slice.h +++ b/include/deal.II/base/vector_slice.h @@ -18,117 +18,7 @@ #include -#include -#include - -DEAL_II_NAMESPACE_OPEN - -/** - * Filter a range out of any object having a random access operator[] - * (unsigned int) and a function size() const. - * - * The use of this object is straightforward. It duplicates the random access - * operator of the VectorType and adds an offset to every index. - * - * Some precautions have to be taken if it is used for a constant vector: the - * VectorSlice object has to be constant, too. The appropriate initialization - * sequence is like this: - * - * @code - * void f(const std::vector& v) - * { - * const VectorSlice > slice(v,...); - * ... - * } - * @endcode - * - * @ingroup data - * - * @deprecated Use the more general ArrayView class instead. - */ -template -class DEAL_II_DEPRECATED VectorSlice - : public ArrayView< - typename std::conditional::value, - const typename VectorType::value_type, - typename VectorType::value_type>::type> -{ -public: - /** - * Construct a vector slice containing the whole vector. Comes handy, if you - * did not want to have a slice at all, but the function you call wants it: - * just put in the vector itself as argument and let this constructor make a - * slice for you. - */ - VectorSlice(VectorType &v); - /** - * The real constructor for a vector slice, allowing you to specify the - * start index and the length of the slice. - */ - VectorSlice(VectorType &v, unsigned int start, unsigned int length); - -protected: - /** - * Alias for the base class name. - */ - using ArrayViewType = - ArrayView::value, - const typename VectorType::value_type, - typename VectorType::value_type>::type>; -}; - - -/** - * Helper function for creating temporary objects without typing template - * arguments. - * - * @relatesalso VectorSlice - */ -template -inline const VectorSlice -make_slice(VectorType &v) -{ - const VectorSlice r(v); - return r; -} - - - -/** - * Helper function for creating temporary objects without typing template - * arguments. - * - * @relatesalso VectorSlice - */ -template -inline const VectorSlice -make_slice(VectorType &v, const unsigned int start, const unsigned int length) -{ - const VectorSlice r(v, start, length); - return r; -} - - - -//--------------------------------------------------------------------------- - -template -inline VectorSlice::VectorSlice(VectorType &v) - : ArrayViewType(make_array_view(std::begin(v), std::end(v))) -{} - - - -template -inline VectorSlice::VectorSlice(VectorType & v, - unsigned int start, - unsigned int length) - : ArrayViewType( - make_array_view(std::begin(v) + start, std::begin(v) + start + length)) -{ - AssertIndexRange(length, v.size() - start + 1); -} - -DEAL_II_NAMESPACE_CLOSE +DEAL_II_WARNING( + "This file is deprecated. Use ArrayView instead of VectorSlice.") #endif diff --git a/tests/base/slice_vector.cc b/tests/base/slice_vector.cc deleted file mode 100644 index fbec388f76..0000000000 --- a/tests/base/slice_vector.cc +++ /dev/null @@ -1,64 +0,0 @@ -// --------------------------------------------------------------------- -// -// Copyright (C) 2004 - 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. -// -// --------------------------------------------------------------------- - -#include - -#include - -#include "../tests.h" - -void -f(const std::vector &v) -{ - const VectorSlice> s = make_slice(v, 2, 3); - - for (unsigned int i = 0; i < s.size(); ++i) - deallog << '\t' << s[i]; - deallog << std::endl; -} - - -int -main() -{ - deal_II_exceptions::disable_abort_on_exception(); - - initlog(); - - std::vector v(7); - - for (unsigned int i = 0; i < v.size(); ++i) - v[i] = i; - - VectorSlice> s(v, 3, 4); - - for (unsigned int i = 0; i < s.size(); ++i) - s[i] = i; - - for (unsigned int i = 0; i < v.size(); ++i) - deallog << '\t' << v[i]; - deallog << std::endl; - - f(v); - - try - { - make_slice(v, 3, 5); - } - catch (ExceptionBase &e) - { - deallog << e.get_exc_name() << std::endl; - } -} diff --git a/tests/base/slice_vector.debug.output b/tests/base/slice_vector.debug.output deleted file mode 100644 index d06911c370..0000000000 --- a/tests/base/slice_vector.debug.output +++ /dev/null @@ -1,4 +0,0 @@ - -DEAL:: 0 1 2 0 1 2 3 -DEAL:: 2 0 1 -DEAL::dealii::ExcIndexRangeType::type)>:: type>((length), 0, (v.size() - start + 1)) diff --git a/tests/integrators/advection_01.cc b/tests/integrators/advection_01.cc index ee9e6af97b..55f68d1b4c 100644 --- a/tests/integrators/advection_01.cc +++ b/tests/integrators/advection_01.cc @@ -63,12 +63,8 @@ test_cell(const FEValuesBase &fev) u = 0.; u(i) = 1.; w = 0.; - fev.get_function_values(u, - indices, - VectorSlice>>( - uval), - true); - cell_residual(w, fev, make_slice(uval), vel); + fev.get_function_values(u, indices, uval, true); + cell_residual(w, fev, uval, vel); M.vmult(v, u); w.add(-1., v); deallog << ' ' << w.l2_norm(); @@ -122,13 +118,8 @@ test_boundary(const FEValuesBase &fev) u = 0.; u(i) = 1.; w = 0.; - fev.get_function_values(u, - indices, - VectorSlice>>( - uval), - true); - upwind_value_residual( - w, fev, make_slice(uval), make_slice(null_val), vel); + fev.get_function_values(u, indices, uval, true); + upwind_value_residual(w, fev, uval, null_val, vel); M.vmult(v, u); w.add(-1., v); deallog << ' ' << w.l2_norm(); @@ -200,13 +191,8 @@ test_face(const FEValuesBase &fev1, const FEValuesBase &fev2) u1(i1) = 1.; w1 = 0.; w2 = 0.; - fev1.get_function_values(u1, - indices1, - VectorSlice>>( - u1val), - true); - upwind_face_residual( - w1, w2, fev1, fev2, make_slice(u1val), make_slice(nullval), vel); + fev1.get_function_values(u1, indices1, u1val, true); + upwind_face_residual(w1, w2, fev1, fev2, u1val, nullval, vel); M11.vmult(v1, u1); w1.add(-1., v1); M21.vmult(v2, u1); @@ -227,13 +213,8 @@ test_face(const FEValuesBase &fev1, const FEValuesBase &fev2) } w1 = 0.; w2 = 0.; - fev2.get_function_values(u1, - indices2, - VectorSlice>>( - u1val), - true); - upwind_face_residual( - w1, w2, fev1, fev2, make_slice(nullval), make_slice(u1val), vel); + fev2.get_function_values(u1, indices2, u1val, true); + upwind_face_residual(w1, w2, fev1, fev2, nullval, u1val, vel); M12.vmult(v1, u1); w1.add(-1., v1); M22.vmult(v2, u1); diff --git a/tests/integrators/divergence_01.cc b/tests/integrators/divergence_01.cc index c50d09de7a..2d49e7b1ac 100644 --- a/tests/integrators/divergence_01.cc +++ b/tests/integrators/divergence_01.cc @@ -66,12 +66,8 @@ test_cell(const FEValuesBase &fev, const FEValuesBase &fes) u = 0.; u(i) = 1.; w = 0.; - fev.get_function_gradients( - u, - indices, - VectorSlice>>>(ugrad), - true); - cell_residual(w, fes, make_slice(ugrad)); + fev.get_function_gradients(u, indices, ugrad, true); + cell_residual(w, fes, ugrad); Md.vmult(v, u); w.add(-1., v); deallog << ' ' << w.l2_norm(); @@ -127,9 +123,8 @@ test_boundary(const FEValuesBase &fev, const FEValuesBase &fes) u = 0.; u(i) = 1.; w = 0.; - fev.get_function_values( - u, indices, VectorSlice>>(uval), true); - u_dot_n_residual(w, fev, fes, make_slice(uval)); + fev.get_function_values(u, indices, uval, true); + u_dot_n_residual(w, fev, fes, uval); M.vmult(v, u); w.add(-1., v); deallog << ' ' << w.l2_norm(); diff --git a/tests/integrators/elasticity_01.cc b/tests/integrators/elasticity_01.cc index 17611d531c..65a993619e 100644 --- a/tests/integrators/elasticity_01.cc +++ b/tests/integrators/elasticity_01.cc @@ -58,12 +58,8 @@ test_cell(const FEValuesBase &fev) u = 0.; u(i) = 1.; w = 0.; - fev.get_function_gradients( - u, - indices, - VectorSlice>>>(ugrad), - true); - cell_residual(w, fev, make_slice(ugrad)); + fev.get_function_gradients(u, indices, ugrad, true); + cell_residual(w, fev, ugrad); M.vmult(v, u); w.add(-1., v); deallog << ' ' << w.l2_norm(); @@ -104,22 +100,9 @@ test_boundary(const FEValuesBase &fev) u = 0.; u(i) = 1.; w = 0.; - fev.get_function_values(u, - indices, - VectorSlice>>( - uval), - true); - fev.get_function_gradients( - u, - indices, - VectorSlice>>>(ugrad), - true); - nitsche_residual(w, - fev, - make_slice(uval), - make_slice(ugrad), - make_slice(null_val), - 17); + fev.get_function_values(u, indices, uval, true); + fev.get_function_gradients(u, indices, ugrad, true); + nitsche_residual(w, fev, uval, ugrad, null_val, 17); M.vmult(v, u); w.add(-1., v); deallog << ' ' << w.l2_norm(); @@ -185,25 +168,10 @@ test_face(const FEValuesBase &fev1, const FEValuesBase &fev2) u1(i1) = 1.; w1 = 0.; w2 = 0.; - fev1.get_function_values(u1, - indices1, - VectorSlice>>( - u1val), - true); - fev1.get_function_gradients( - u1, - indices1, - VectorSlice>>>(u1grad), - true); - ip_residual(w1, - w2, - fev1, - fev2, - make_slice(u1val), - make_slice(u1grad), - make_slice(nullval), - make_slice(nullgrad), - 17); + fev1.get_function_values(u1, indices1, u1val, true); + fev1.get_function_gradients(u1, indices1, u1grad, true); + ip_residual( + w1, w2, fev1, fev2, u1val, u1grad, nullval, nullgrad, 17); M11.vmult(v1, u1); w1.add(-1., v1); M21.vmult(v2, u1); @@ -212,25 +180,10 @@ test_face(const FEValuesBase &fev1, const FEValuesBase &fev2) w1 = 0.; w2 = 0.; - fev2.get_function_values(u1, - indices2, - VectorSlice>>( - u1val), - true); - fev2.get_function_gradients( - u1, - indices2, - VectorSlice>>>(u1grad), - true); - ip_residual(w1, - w2, - fev1, - fev2, - make_slice(nullval), - make_slice(nullgrad), - make_slice(u1val), - make_slice(u1grad), - 17); + fev2.get_function_values(u1, indices2, u1val, true); + fev2.get_function_gradients(u1, indices2, u1grad, true); + ip_residual( + w1, w2, fev1, fev2, nullval, nullgrad, u1val, u1grad, 17); M12.vmult(v1, u1); w1.add(-1., v1); M22.vmult(v2, u1); diff --git a/tests/integrators/elasticity_02.cc b/tests/integrators/elasticity_02.cc index c4e124d114..851d363b0e 100644 --- a/tests/integrators/elasticity_02.cc +++ b/tests/integrators/elasticity_02.cc @@ -62,22 +62,9 @@ test_boundary(const FEValuesBase &fev) u = 0.; u(i) = 1.; w = 0.; - fev.get_function_values(u, - indices, - VectorSlice>>( - uval), - true); - fev.get_function_gradients( - u, - indices, - VectorSlice>>>(ugrad), - true); - nitsche_tangential_residual(w, - fev, - make_slice(uval), - make_slice(ugrad), - make_slice(null_val), - 17); + fev.get_function_values(u, indices, uval, true); + fev.get_function_gradients(u, indices, ugrad, true); + nitsche_tangential_residual(w, fev, uval, ugrad, null_val, 17); M.vmult(v, u); w.add(-1., v); deallog << ' ' << w.l2_norm(); diff --git a/tests/integrators/grad_div_01.cc b/tests/integrators/grad_div_01.cc index 1f3c56248e..378f499a9a 100644 --- a/tests/integrators/grad_div_01.cc +++ b/tests/integrators/grad_div_01.cc @@ -58,12 +58,8 @@ test_cell(const FEValuesBase &fev) u = 0.; u(i) = 1.; w = 0.; - fev.get_function_gradients( - u, - indices, - VectorSlice>>>(ugrad), - true); - cell_residual(w, fev, make_slice(ugrad)); + fev.get_function_gradients(u, indices, ugrad, true); + cell_residual(w, fev, ugrad); M.vmult(v, u); w.add(-1., v); deallog << ' ' << w.l2_norm(); @@ -104,22 +100,9 @@ test_boundary(const FEValuesBase &fev) u = 0.; u(i) = 1.; w = 0.; - fev.get_function_values(u, - indices, - VectorSlice>>( - uval), - true); - fev.get_function_gradients( - u, - indices, - VectorSlice>>>(ugrad), - true); - nitsche_residual(w, - fev, - make_slice(uval), - make_slice(ugrad), - make_slice(null_val), - 17); + fev.get_function_values(u, indices, uval, true); + fev.get_function_gradients(u, indices, ugrad, true); + nitsche_residual(w, fev, uval, ugrad, null_val, 17); M.vmult(v, u); w.add(-1., v); deallog << ' ' << w.l2_norm(); @@ -185,25 +168,10 @@ test_face(const FEValuesBase &fev1, const FEValuesBase &fev2) u1(i1) = 1.; w1 = 0.; w2 = 0.; - fev1.get_function_values(u1, - indices1, - VectorSlice>>( - u1val), - true); - fev1.get_function_gradients( - u1, - indices1, - VectorSlice>>>(u1grad), - true); - ip_residual(w1, - w2, - fev1, - fev2, - make_slice(u1val), - make_slice(u1grad), - make_slice(nullval), - make_slice(nullgrad), - 17); + fev1.get_function_values(u1, indices1, u1val, true); + fev1.get_function_gradients(u1, indices1, u1grad, true); + ip_residual( + w1, w2, fev1, fev2, u1val, u1grad, nullval, nullgrad, 17); M11.vmult(v1, u1); w1.add(-1., v1); M21.vmult(v2, u1); @@ -212,25 +180,10 @@ test_face(const FEValuesBase &fev1, const FEValuesBase &fev2) w1 = 0.; w2 = 0.; - fev2.get_function_values(u1, - indices2, - VectorSlice>>( - u1val), - true); - fev2.get_function_gradients( - u1, - indices2, - VectorSlice>>>(u1grad), - true); - ip_residual(w1, - w2, - fev1, - fev2, - make_slice(nullval), - make_slice(nullgrad), - make_slice(u1val), - make_slice(u1grad), - 17); + fev2.get_function_values(u1, indices2, u1val, true); + fev2.get_function_gradients(u1, indices2, u1grad, true); + ip_residual( + w1, w2, fev1, fev2, nullval, nullgrad, u1val, u1grad, 17); M12.vmult(v1, u1); w1.add(-1., v1); M22.vmult(v2, u1); diff --git a/tests/integrators/laplacian_01.cc b/tests/integrators/laplacian_01.cc index b56eef727b..82a8b9dc67 100644 --- a/tests/integrators/laplacian_01.cc +++ b/tests/integrators/laplacian_01.cc @@ -57,12 +57,8 @@ test_cell(const FEValuesBase &fev) u = 0.; u(i) = 1.; w = 0.; - fev.get_function_gradients( - u, - indices, - VectorSlice>>>(ugrad), - true); - cell_residual(w, fev, make_slice(ugrad)); + fev.get_function_gradients(u, indices, ugrad, true); + cell_residual(w, fev, ugrad); M.vmult(v, u); w.add(-1., v); deallog << ' ' << w.l2_norm(); @@ -110,22 +106,9 @@ test_boundary(const FEValuesBase &fev) u = 0.; u(i) = 1.; w = 0.; - fev.get_function_values(u, - indices, - VectorSlice>>( - uval), - true); - fev.get_function_gradients( - u, - indices, - VectorSlice>>>(ugrad), - true); - nitsche_residual(w, - fev, - make_slice(uval), - make_slice(ugrad), - make_slice(null_val), - 17); + fev.get_function_values(u, indices, uval, true); + fev.get_function_gradients(u, indices, ugrad, true); + nitsche_residual(w, fev, uval, ugrad, null_val, 17); M.vmult(v, u); w.add(-1., v); deallog << ' ' << w.l2_norm(); @@ -198,25 +181,10 @@ test_face(const FEValuesBase &fev1, const FEValuesBase &fev2) u1(i1) = 1.; w1 = 0.; w2 = 0.; - fev1.get_function_values(u1, - indices1, - VectorSlice>>( - u1val), - true); - fev1.get_function_gradients( - u1, - indices1, - VectorSlice>>>(u1grad), - true); - ip_residual(w1, - w2, - fev1, - fev2, - make_slice(u1val), - make_slice(u1grad), - make_slice(nullval), - make_slice(nullgrad), - 17); + fev1.get_function_values(u1, indices1, u1val, true); + fev1.get_function_gradients(u1, indices1, u1grad, true); + ip_residual( + w1, w2, fev1, fev2, u1val, u1grad, nullval, nullgrad, 17); M11.vmult(v1, u1); w1.add(-1., v1); M21.vmult(v2, u1); @@ -245,25 +213,10 @@ test_face(const FEValuesBase &fev1, const FEValuesBase &fev2) w1 = 0.; w2 = 0.; - fev2.get_function_values(u1, - indices2, - VectorSlice>>( - u1val), - true); - fev2.get_function_gradients( - u1, - indices2, - VectorSlice>>>(u1grad), - true); - ip_residual(w1, - w2, - fev1, - fev2, - make_slice(nullval), - make_slice(nullgrad), - make_slice(u1val), - make_slice(u1grad), - 17); + fev2.get_function_values(u1, indices2, u1val, true); + fev2.get_function_gradients(u1, indices2, u1grad, true); + ip_residual( + w1, w2, fev1, fev2, nullval, nullgrad, u1val, u1grad, 17); M12.vmult(v1, u1); w1.add(-1., v1); M22.vmult(v2, u1); -- 2.39.5