#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
+++ /dev/null
-// ---------------------------------------------------------------------
-//
-// 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;
- }
-}
+++ /dev/null
-
-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))
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();
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();
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);
}
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);
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();
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();
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();
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();
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);
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);
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();
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();
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();
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);
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);
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();
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();
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);
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);