]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Remove VectorSlice 10576/head
authorDaniel Arndt <arndtd@ornl.gov>
Tue, 23 Jun 2020 04:15:51 +0000 (00:15 -0400)
committerDaniel Arndt <arndtd@ornl.gov>
Tue, 23 Jun 2020 04:19:24 +0000 (00:19 -0400)
include/deal.II/base/vector_slice.h
tests/base/slice_vector.cc [deleted file]
tests/base/slice_vector.debug.output [deleted file]
tests/integrators/advection_01.cc
tests/integrators/divergence_01.cc
tests/integrators/elasticity_01.cc
tests/integrators/elasticity_02.cc
tests/integrators/grad_div_01.cc
tests/integrators/laplacian_01.cc

index 4cdecf5d64d7dd33630b6aed1d375fc2a241784e..2e5fadf5b88eef8e17f7ab7906277d907c8ab6fc 100644 (file)
 
 #include <deal.II/base/config.h>
 
-#include <deal.II/base/array_view.h>
-#include <deal.II/base/exceptions.h>
-
-DEAL_II_NAMESPACE_OPEN
-
-/**
- * Filter a range out of any object having a random access <tt>operator[]
- * (unsigned int)</tt> and a function <tt>size() const</tt>.
- *
- * The use of this object is straightforward. It duplicates the random access
- * operator of the <tt>VectorType</tt> 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<int>& v)
- *   {
- *     const VectorSlice<const std::vector<int> > slice(v,...);
- *     ...
- *   }
- * @endcode
- *
- * @ingroup data
- *
- * @deprecated Use the more general ArrayView class instead.
- */
-template <typename VectorType>
-class DEAL_II_DEPRECATED VectorSlice
-  : public ArrayView<
-      typename std::conditional<std::is_const<VectorType>::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<typename std::conditional<std::is_const<VectorType>::value,
-                                        const typename VectorType::value_type,
-                                        typename VectorType::value_type>::type>;
-};
-
-
-/**
- * Helper function for creating temporary objects without typing template
- * arguments.
- *
- * @relatesalso VectorSlice
- */
-template <typename VectorType>
-inline const VectorSlice<const VectorType>
-make_slice(VectorType &v)
-{
-  const VectorSlice<const VectorType> r(v);
-  return r;
-}
-
-
-
-/**
- * Helper function for creating temporary objects without typing template
- * arguments.
- *
- * @relatesalso VectorSlice
- */
-template <typename VectorType>
-inline const VectorSlice<const VectorType>
-make_slice(VectorType &v, const unsigned int start, const unsigned int length)
-{
-  const VectorSlice<const VectorType> r(v, start, length);
-  return r;
-}
-
-
-
-//---------------------------------------------------------------------------
-
-template <typename VectorType>
-inline VectorSlice<VectorType>::VectorSlice(VectorType &v)
-  : ArrayViewType(make_array_view(std::begin(v), std::end(v)))
-{}
-
-
-
-template <typename VectorType>
-inline VectorSlice<VectorType>::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 (file)
index fbec388..0000000
+++ /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 <deal.II/base/vector_slice.h>
-
-#include <vector>
-
-#include "../tests.h"
-
-void
-f(const std::vector<int> &v)
-{
-  const VectorSlice<const std::vector<int>> 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<int> v(7);
-
-  for (unsigned int i = 0; i < v.size(); ++i)
-    v[i] = i;
-
-  VectorSlice<std::vector<int>> 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 (file)
index d06911c..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-
-DEAL:: 0       1       2       0       1       2       3
-DEAL:: 2       0       1
-DEAL::dealii::ExcIndexRangeType<typename ::dealii::internal::argument_type<void( typename std::common_type<decltype(length), decltype(v.size() - start + 1)>::type)>:: type>((length), 0, (v.size() - start + 1))
index ee9e6af97b1d41c52cdc700c7ad29296164cf75a..55f68d1b4c02fb2f3a856c594e1f502c3f2b2982 100644 (file)
@@ -63,12 +63,8 @@ test_cell(const FEValuesBase<dim> &fev)
         u    = 0.;
         u(i) = 1.;
         w    = 0.;
-        fev.get_function_values(u,
-                                indices,
-                                VectorSlice<std::vector<std::vector<double>>>(
-                                  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<dim> &fev)
         u    = 0.;
         u(i) = 1.;
         w    = 0.;
-        fev.get_function_values(u,
-                                indices,
-                                VectorSlice<std::vector<std::vector<double>>>(
-                                  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<dim> &fev1, const FEValuesBase<dim> &fev2)
         u1(i1) = 1.;
         w1     = 0.;
         w2     = 0.;
-        fev1.get_function_values(u1,
-                                 indices1,
-                                 VectorSlice<std::vector<std::vector<double>>>(
-                                   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<dim> &fev1, const FEValuesBase<dim> &fev2)
           }
         w1 = 0.;
         w2 = 0.;
-        fev2.get_function_values(u1,
-                                 indices2,
-                                 VectorSlice<std::vector<std::vector<double>>>(
-                                   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);
index c50d09de7a8ca56a9b0ddb49882f7244eb157a03..2d49e7b1accac321a7f53abdf9e84d5080c69a49 100644 (file)
@@ -66,12 +66,8 @@ test_cell(const FEValuesBase<dim> &fev, const FEValuesBase<dim> &fes)
       u    = 0.;
       u(i) = 1.;
       w    = 0.;
-      fev.get_function_gradients(
-        u,
-        indices,
-        VectorSlice<std::vector<std::vector<Tensor<1, dim>>>>(ugrad),
-        true);
-      cell_residual(w, fes, make_slice(ugrad));
+      fev.get_function_gradients(u, indices, ugrad, true);
+      cell_residual<dim>(w, fes, ugrad);
       Md.vmult(v, u);
       w.add(-1., v);
       deallog << ' ' << w.l2_norm();
@@ -127,9 +123,8 @@ test_boundary(const FEValuesBase<dim> &fev, const FEValuesBase<dim> &fes)
       u    = 0.;
       u(i) = 1.;
       w    = 0.;
-      fev.get_function_values(
-        u, indices, VectorSlice<std::vector<std::vector<double>>>(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();
index 17611d531cd573983a1471fef4406122dcbc8da8..65a993619e176c43ee88f43a050d636068c1a11f 100644 (file)
@@ -58,12 +58,8 @@ test_cell(const FEValuesBase<dim> &fev)
         u    = 0.;
         u(i) = 1.;
         w    = 0.;
-        fev.get_function_gradients(
-          u,
-          indices,
-          VectorSlice<std::vector<std::vector<Tensor<1, dim>>>>(ugrad),
-          true);
-        cell_residual(w, fev, make_slice(ugrad));
+        fev.get_function_gradients(u, indices, ugrad, true);
+        cell_residual<dim>(w, fev, ugrad);
         M.vmult(v, u);
         w.add(-1., v);
         deallog << ' ' << w.l2_norm();
@@ -104,22 +100,9 @@ test_boundary(const FEValuesBase<dim> &fev)
         u    = 0.;
         u(i) = 1.;
         w    = 0.;
-        fev.get_function_values(u,
-                                indices,
-                                VectorSlice<std::vector<std::vector<double>>>(
-                                  uval),
-                                true);
-        fev.get_function_gradients(
-          u,
-          indices,
-          VectorSlice<std::vector<std::vector<Tensor<1, dim>>>>(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<dim>(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<dim> &fev1, const FEValuesBase<dim> &fev2)
         u1(i1) = 1.;
         w1     = 0.;
         w2     = 0.;
-        fev1.get_function_values(u1,
-                                 indices1,
-                                 VectorSlice<std::vector<std::vector<double>>>(
-                                   u1val),
-                                 true);
-        fev1.get_function_gradients(
-          u1,
-          indices1,
-          VectorSlice<std::vector<std::vector<Tensor<1, dim>>>>(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<dim>(
+          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<dim> &fev1, const FEValuesBase<dim> &fev2)
 
         w1 = 0.;
         w2 = 0.;
-        fev2.get_function_values(u1,
-                                 indices2,
-                                 VectorSlice<std::vector<std::vector<double>>>(
-                                   u1val),
-                                 true);
-        fev2.get_function_gradients(
-          u1,
-          indices2,
-          VectorSlice<std::vector<std::vector<Tensor<1, dim>>>>(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<dim>(
+          w1, w2, fev1, fev2, nullval, nullgrad, u1val, u1grad, 17);
         M12.vmult(v1, u1);
         w1.add(-1., v1);
         M22.vmult(v2, u1);
index c4e124d1146a7f48e4c64186db06ceadb1b16909..851d363b0e294a268073d80de2ddd6e88ded29a8 100644 (file)
@@ -62,22 +62,9 @@ test_boundary(const FEValuesBase<dim> &fev)
         u    = 0.;
         u(i) = 1.;
         w    = 0.;
-        fev.get_function_values(u,
-                                indices,
-                                VectorSlice<std::vector<std::vector<double>>>(
-                                  uval),
-                                true);
-        fev.get_function_gradients(
-          u,
-          indices,
-          VectorSlice<std::vector<std::vector<Tensor<1, dim>>>>(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<dim>(w, fev, uval, ugrad, null_val, 17);
         M.vmult(v, u);
         w.add(-1., v);
         deallog << ' ' << w.l2_norm();
index 1f3c56248e2320d0bfd46b3f07b859e759da9e9f..378f499a9a483072b165efe8fd08a556188db6fc 100644 (file)
@@ -58,12 +58,8 @@ test_cell(const FEValuesBase<dim> &fev)
         u    = 0.;
         u(i) = 1.;
         w    = 0.;
-        fev.get_function_gradients(
-          u,
-          indices,
-          VectorSlice<std::vector<std::vector<Tensor<1, dim>>>>(ugrad),
-          true);
-        cell_residual(w, fev, make_slice(ugrad));
+        fev.get_function_gradients(u, indices, ugrad, true);
+        cell_residual<dim>(w, fev, ugrad);
         M.vmult(v, u);
         w.add(-1., v);
         deallog << ' ' << w.l2_norm();
@@ -104,22 +100,9 @@ test_boundary(const FEValuesBase<dim> &fev)
         u    = 0.;
         u(i) = 1.;
         w    = 0.;
-        fev.get_function_values(u,
-                                indices,
-                                VectorSlice<std::vector<std::vector<double>>>(
-                                  uval),
-                                true);
-        fev.get_function_gradients(
-          u,
-          indices,
-          VectorSlice<std::vector<std::vector<Tensor<1, dim>>>>(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<dim>(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<dim> &fev1, const FEValuesBase<dim> &fev2)
         u1(i1) = 1.;
         w1     = 0.;
         w2     = 0.;
-        fev1.get_function_values(u1,
-                                 indices1,
-                                 VectorSlice<std::vector<std::vector<double>>>(
-                                   u1val),
-                                 true);
-        fev1.get_function_gradients(
-          u1,
-          indices1,
-          VectorSlice<std::vector<std::vector<Tensor<1, dim>>>>(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<dim>(
+          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<dim> &fev1, const FEValuesBase<dim> &fev2)
 
         w1 = 0.;
         w2 = 0.;
-        fev2.get_function_values(u1,
-                                 indices2,
-                                 VectorSlice<std::vector<std::vector<double>>>(
-                                   u1val),
-                                 true);
-        fev2.get_function_gradients(
-          u1,
-          indices2,
-          VectorSlice<std::vector<std::vector<Tensor<1, dim>>>>(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<dim>(
+          w1, w2, fev1, fev2, nullval, nullgrad, u1val, u1grad, 17);
         M12.vmult(v1, u1);
         w1.add(-1., v1);
         M22.vmult(v2, u1);
index b56eef727bf5e68907ed0a40b0ec8c7ed8b220c7..82a8b9dc676427bd90a66874970794e0a3a48da6 100644 (file)
@@ -57,12 +57,8 @@ test_cell(const FEValuesBase<dim> &fev)
         u    = 0.;
         u(i) = 1.;
         w    = 0.;
-        fev.get_function_gradients(
-          u,
-          indices,
-          VectorSlice<std::vector<std::vector<Tensor<1, dim>>>>(ugrad),
-          true);
-        cell_residual(w, fev, make_slice(ugrad));
+        fev.get_function_gradients(u, indices, ugrad, true);
+        cell_residual<dim>(w, fev, ugrad);
         M.vmult(v, u);
         w.add(-1., v);
         deallog << ' ' << w.l2_norm();
@@ -110,22 +106,9 @@ test_boundary(const FEValuesBase<dim> &fev)
         u    = 0.;
         u(i) = 1.;
         w    = 0.;
-        fev.get_function_values(u,
-                                indices,
-                                VectorSlice<std::vector<std::vector<double>>>(
-                                  uval),
-                                true);
-        fev.get_function_gradients(
-          u,
-          indices,
-          VectorSlice<std::vector<std::vector<Tensor<1, dim>>>>(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<dim>(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<dim> &fev1, const FEValuesBase<dim> &fev2)
         u1(i1) = 1.;
         w1     = 0.;
         w2     = 0.;
-        fev1.get_function_values(u1,
-                                 indices1,
-                                 VectorSlice<std::vector<std::vector<double>>>(
-                                   u1val),
-                                 true);
-        fev1.get_function_gradients(
-          u1,
-          indices1,
-          VectorSlice<std::vector<std::vector<Tensor<1, dim>>>>(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<dim>(
+          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<dim> &fev1, const FEValuesBase<dim> &fev2)
 
         w1 = 0.;
         w2 = 0.;
-        fev2.get_function_values(u1,
-                                 indices2,
-                                 VectorSlice<std::vector<std::vector<double>>>(
-                                   u1val),
-                                 true);
-        fev2.get_function_gradients(
-          u1,
-          indices2,
-          VectorSlice<std::vector<std::vector<Tensor<1, dim>>>>(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<dim>(
+          w1, w2, fev1, fev2, nullval, nullgrad, u1val, u1grad, 17);
         M12.vmult(v1, u1);
         w1.add(-1., v1);
         M22.vmult(v2, u1);

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.