From: David Wells Date: Mon, 21 Jan 2019 19:31:10 +0000 (-0500) Subject: Deprecate VectorSlice. X-Git-Tag: v9.1.0-rc1~413^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c28a6958191bcde9364acdf9230bcea53797873d;p=dealii.git Deprecate VectorSlice. ArrayView offers the same functionality but in a more general way. This PR reimplements VectorSlice as a class inheriting from ArrayView, which automatically gives us all of the right conversions. --- diff --git a/doc/news/changes/incompatibilities/20190121DavidWells b/doc/news/changes/incompatibilities/20190121DavidWells new file mode 100644 index 0000000000..1edbce7a12 --- /dev/null +++ b/doc/news/changes/incompatibilities/20190121DavidWells @@ -0,0 +1,6 @@ +Changed: VectorSlice has been deprecated in favor of the more general ArrayView +class. All public interfaces now take ArrayView arguments instead of VectorSlice +arguments. Since VectorSlice now inherits from ArrayView this should be +compatible with the overwhelming majority of use cases. +
+(David Wells, 2019/01/21) diff --git a/include/deal.II/base/vector_slice.h b/include/deal.II/base/vector_slice.h index 52fb648ced..32ebecb9c7 100644 --- a/include/deal.II/base/vector_slice.h +++ b/include/deal.II/base/vector_slice.h @@ -23,7 +23,6 @@ DEAL_II_NAMESPACE_OPEN - /** * Filter a range out of any object having a random access operator[] * (unsigned int) and a function size() const. @@ -45,9 +44,15 @@ DEAL_II_NAMESPACE_OPEN * * @ingroup data * @author Guido Kanschat, 2004 + * + * @deprecated Use the more general ArrayView class instead. */ template -class VectorSlice +class DEAL_II_DEPRECATED VectorSlice + : public ArrayView< + typename std::conditional::value, + const typename VectorType::value_type, + typename VectorType::value_type>::type> { public: /** @@ -63,74 +68,14 @@ public: */ VectorSlice(VectorType &v, unsigned int start, unsigned int length); +protected: /** - * Conversion operator to an ArrayView object that represents an array of - * non-const elements pointing to the same location as the current object. - */ - operator ArrayView(); - - /** - * Conversion operator to an ArrayView object that represents an array of - * const elements pointing to the same location as the current object. - */ - operator ArrayView() const; - - /** - * Return the length of the slice using the same interface as - * std::vector. - */ - unsigned int - size() const; - - /** - * Return a reference to the $i$th element of the range represented by the - * current object. + * Alias for the base class name. */ - typename VectorType::reference operator[](unsigned int i); - - /** - * Return a @p const reference to the $i$th element of the range represented - * by the current object. - */ - typename VectorType::const_reference operator[](unsigned int i) const; - - /** - * Standard-conforming iterator function. - */ - typename VectorType::iterator - begin(); - - /** - * Standard-conforming iterator function. - */ - typename VectorType::const_iterator - begin() const; - - /** - * Standard-conforming iterator function. - */ - typename VectorType::iterator - end(); - - /** - * Standard-conforming iterator function. - */ - typename VectorType::const_iterator - end() const; - -private: - /** - * The vector we extract from. - */ - VectorType &v; - /** - * The start index of the slice. - */ - const unsigned int start; - /** - * The length of the slice. - */ - const unsigned int length; + using ArrayViewType = + ArrayView::value, + const typename VectorType::value_type, + typename VectorType::value_type>::type>; }; @@ -172,99 +117,22 @@ make_slice(VectorType &v, const unsigned int start, const unsigned int length) template inline VectorSlice::VectorSlice(VectorType &v) - : v(v) - , start(0) - , length(v.size()) + : ArrayViewType(make_array_view(std::begin(v), std::end(v))) {} + template inline VectorSlice::VectorSlice(VectorType & v, unsigned int start, unsigned int length) - : v(v) - , start(start) - , length(length) + : ArrayViewType( + make_array_view(std::begin(v) + start, std::begin(v) + start + length)) { Assert((start + length <= v.size()), ExcIndexRange(length, 0, v.size() - start + 1)); } - -template -inline unsigned int -VectorSlice::size() const -{ - return length; -} - - -template -VectorSlice::operator ArrayView() -{ - return ArrayView(&v[start], length); -} - - -template -VectorSlice:: -operator ArrayView() const -{ - return ArrayView(&v[start], length); -} - - -template -inline typename VectorType::reference VectorSlice:: - operator[](unsigned int i) -{ - Assert((i < length), ExcIndexRange(i, 0, length)); - - return v[start + i]; -} - - -template -inline typename VectorType::const_reference VectorSlice:: - operator[](unsigned int i) const -{ - Assert((i < length), ExcIndexRange(i, 0, length)); - - return v[start + i]; -} - - -template -inline typename VectorType::const_iterator -VectorSlice::begin() const -{ - return v.begin() + start; -} - - -template -inline typename VectorType::iterator -VectorSlice::begin() -{ - return v.begin() + start; -} - - -template -inline typename VectorType::const_iterator -VectorSlice::end() const -{ - return v.begin() + start + length; -} - - -template -inline typename VectorType::iterator -VectorSlice::end() -{ - return v.begin() + start + length; -} - DEAL_II_NAMESPACE_CLOSE #endif diff --git a/include/deal.II/fe/fe_values.h b/include/deal.II/fe/fe_values.h index e0f09e6a50..deabd5188f 100644 --- a/include/deal.II/fe/fe_values.h +++ b/include/deal.II/fe/fe_values.h @@ -2331,9 +2331,9 @@ public: template void get_function_values( - const InputVector & fe_function, - const VectorSlice> &indices, - std::vector &values) const; + const InputVector & fe_function, + const ArrayView &indices, + std::vector & values) const; /** * Generate vector function values from an arbitrary vector. @@ -2359,8 +2359,8 @@ public: template void get_function_values( - const InputVector & fe_function, - const VectorSlice> &indices, + const InputVector & fe_function, + const ArrayView & indices, std::vector> &values) const; @@ -2397,10 +2397,9 @@ public: template void get_function_values( - const InputVector & fe_function, - const VectorSlice> &indices, - VectorSlice>> - values, + const InputVector & fe_function, + const ArrayView & indices, + ArrayView> values, const bool quadrature_points_fastest) const; //@} @@ -2485,8 +2484,8 @@ public: template void get_function_gradients( - const InputVector & fe_function, - const VectorSlice> &indices, + const InputVector & fe_function, + const ArrayView &indices, std::vector> &gradients) const; @@ -2499,10 +2498,10 @@ public: template void get_function_gradients( - const InputVector & fe_function, - const VectorSlice> &indices, - VectorSlice>>> + const InputVector & fe_function, + const ArrayView &indices, + ArrayView< + std::vector>> gradients, bool quadrature_points_fastest = false) const; @@ -2590,8 +2589,8 @@ public: template void get_function_hessians( - const InputVector & fe_function, - const VectorSlice> &indices, + const InputVector & fe_function, + const ArrayView &indices, std::vector> &hessians) const; @@ -2604,10 +2603,10 @@ public: template void get_function_hessians( - const InputVector & fe_function, - const VectorSlice> &indices, - VectorSlice>>> + const InputVector & fe_function, + const ArrayView &indices, + ArrayView< + std::vector>> hessians, bool quadrature_points_fastest = false) const; @@ -2693,9 +2692,9 @@ public: template void get_function_laplacians( - const InputVector & fe_function, - const VectorSlice> &indices, - std::vector &laplacians) const; + const InputVector & fe_function, + const ArrayView &indices, + std::vector & laplacians) const; /** * Access to the second derivatives of a function with more flexibility. See @@ -2706,8 +2705,8 @@ public: template void get_function_laplacians( - const InputVector & fe_function, - const VectorSlice> &indices, + const InputVector & fe_function, + const ArrayView & indices, std::vector> &laplacians) const; /** @@ -2719,9 +2718,9 @@ public: template void get_function_laplacians( - const InputVector & fe_function, - const VectorSlice> &indices, - std::vector> & laplacians, + const InputVector & fe_function, + const ArrayView & indices, + std::vector> &laplacians, bool quadrature_points_fastest = false) const; //@} @@ -2809,8 +2808,8 @@ public: template void get_function_third_derivatives( - const InputVector & fe_function, - const VectorSlice> &indices, + const InputVector & fe_function, + const ArrayView &indices, std::vector> &third_derivatives) const; @@ -2823,10 +2822,10 @@ public: template void get_function_third_derivatives( - const InputVector & fe_function, - const VectorSlice> &indices, - VectorSlice>>> + const InputVector & fe_function, + const ArrayView &indices, + ArrayView< + std::vector>> third_derivatives, bool quadrature_points_fastest = false) const; //@} diff --git a/include/deal.II/integrators/advection.h b/include/deal.II/integrators/advection.h index a7f95ee2a7..513489521e 100644 --- a/include/deal.II/integrators/advection.h +++ b/include/deal.II/integrators/advection.h @@ -77,12 +77,11 @@ namespace LocalIntegrators */ template void - cell_matrix( - FullMatrix & M, - const FEValuesBase & fe, - const FEValuesBase & fetest, - const VectorSlice>> &velocity, - const double factor = 1.) + cell_matrix(FullMatrix & M, + const FEValuesBase & fe, + const FEValuesBase & fetest, + const ArrayView> &velocity, + const double factor = 1.) { const unsigned int n_dofs = fe.dofs_per_cell; const unsigned int t_dofs = fetest.dofs_per_cell; @@ -134,12 +133,11 @@ namespace LocalIntegrators */ template inline void - cell_residual( - Vector & result, - const FEValuesBase & fe, - const std::vector> & input, - const VectorSlice>> &velocity, - double factor = 1.) + cell_residual(Vector & result, + const FEValuesBase & fe, + const std::vector> & input, + const ArrayView> &velocity, + double factor = 1.) { const unsigned int nq = fe.n_quadrature_points; const unsigned int n_dofs = fe.dofs_per_cell; @@ -178,12 +176,11 @@ namespace LocalIntegrators */ template inline void - cell_residual( - Vector & result, - const FEValuesBase & fe, - const VectorSlice>>> &input, - const VectorSlice>> &velocity, - double factor = 1.) + cell_residual(Vector & result, + const FEValuesBase & fe, + const ArrayView>> &input, + const ArrayView> & velocity, + double factor = 1.) { const unsigned int nq = fe.n_quadrature_points; const unsigned int n_dofs = fe.dofs_per_cell; @@ -221,12 +218,11 @@ namespace LocalIntegrators */ template inline void - cell_residual( - Vector & result, - const FEValuesBase & fe, - const std::vector & input, - const VectorSlice>> &velocity, - double factor = 1.) + cell_residual(Vector & result, + const FEValuesBase & fe, + const std::vector & input, + const ArrayView> &velocity, + double factor = 1.) { const unsigned int nq = fe.n_quadrature_points; const unsigned int n_dofs = fe.dofs_per_cell; @@ -262,12 +258,11 @@ namespace LocalIntegrators */ template inline void - cell_residual( - Vector & result, - const FEValuesBase & fe, - const VectorSlice>> &input, - const VectorSlice>> &velocity, - double factor = 1.) + cell_residual(Vector & result, + const FEValuesBase & fe, + const ArrayView> &input, + const ArrayView> &velocity, + double factor = 1.) { const unsigned int nq = fe.n_quadrature_points; const unsigned int n_dofs = fe.dofs_per_cell; @@ -307,7 +302,7 @@ namespace LocalIntegrators * u_i v_j \, ds * @f] * - * The velocity is provided as a VectorSlice, having dim + * The velocity is provided as an ArrayView, having dim * vectors, one for each velocity component. Each of the vectors must * either have only a single entry, if the advection velocity is constant, * or have an entry for each quadrature point. @@ -317,12 +312,11 @@ namespace LocalIntegrators */ template void - upwind_value_matrix( - FullMatrix & M, - const FEValuesBase & fe, - const FEValuesBase & fetest, - const VectorSlice>> &velocity, - double factor = 1.) + upwind_value_matrix(FullMatrix & M, + const FEValuesBase & fe, + const FEValuesBase & fetest, + const ArrayView> &velocity, + double factor = 1.) { const unsigned int n_dofs = fe.dofs_per_cell; const unsigned int t_dofs = fetest.dofs_per_cell; @@ -381,7 +375,7 @@ namespace LocalIntegrators * argument `input` on the outflow boundary. On the inflow boundary, it is * the inhomogenous boundary value in the argument `data`. * - * The velocity is provided as a VectorSlice, having dim + * The velocity is provided as an ArrayView, having dim * vectors, one for each velocity component. Each of the vectors must * either have only a single entry, if the advection velocity is constant, * or have an entry for each quadrature point. @@ -391,13 +385,12 @@ namespace LocalIntegrators */ template inline void - upwind_value_residual( - Vector & result, - const FEValuesBase & fe, - const std::vector & input, - const std::vector & data, - const VectorSlice>> &velocity, - double factor = 1.) + upwind_value_residual(Vector & result, + const FEValuesBase & fe, + const std::vector & input, + const std::vector & data, + const ArrayView> &velocity, + double factor = 1.) { const unsigned int n_dofs = fe.dofs_per_cell; @@ -449,7 +442,7 @@ namespace LocalIntegrators * argument `input` on the outflow boundary. On the inflow boundary, it is * the inhomogenous boundary value in the argument `data`. * - * The velocity is provided as a VectorSlice, having dim + * The velocity is provided as an ArrayView, having dim * vectors, one for each velocity component. Each of the vectors must * either have only a single entry, if the advection velocity is constant, * or have an entry for each quadrature point. @@ -459,13 +452,12 @@ namespace LocalIntegrators */ template inline void - upwind_value_residual( - Vector & result, - const FEValuesBase & fe, - const VectorSlice>> &input, - const VectorSlice>> &data, - const VectorSlice>> &velocity, - double factor = 1.) + upwind_value_residual(Vector & result, + const FEValuesBase & fe, + const ArrayView> &input, + const ArrayView> &data, + const ArrayView> &velocity, + double factor = 1.) { const unsigned int n_dofs = fe.dofs_per_cell; const unsigned int n_comp = fe.get_fe().n_components(); @@ -517,7 +509,7 @@ namespace LocalIntegrators * \,ds * @f] * - * The velocity is provided as a VectorSlice, having dim + * The velocity is provided as an ArrayView, having dim * vectors, one for each velocity component. Each of the vectors must * either have only a single entry, if the advection velocity is constant, * or have an entry for each quadrature point. @@ -527,17 +519,16 @@ namespace LocalIntegrators */ template void - upwind_value_matrix( - FullMatrix & M11, - FullMatrix & M12, - FullMatrix & M21, - FullMatrix & M22, - const FEValuesBase & fe1, - const FEValuesBase & fe2, - const FEValuesBase & fetest1, - const FEValuesBase & fetest2, - const VectorSlice>> &velocity, - const double factor = 1.) + upwind_value_matrix(FullMatrix & M11, + FullMatrix & M12, + FullMatrix & M21, + FullMatrix & M22, + const FEValuesBase & fe1, + const FEValuesBase & fe2, + const FEValuesBase & fetest1, + const FEValuesBase & fetest2, + const ArrayView> &velocity, + const double factor = 1.) { const unsigned int n1 = fe1.dofs_per_cell; // Multiply the quadrature point @@ -603,7 +594,7 @@ namespace LocalIntegrators * \,ds * @f] * - * The velocity is provided as a VectorSlice, having dim + * The velocity is provided as an ArrayView, having dim * vectors, one for each velocity component. Each of the vectors must * either have only a single entry, if the advection velocity is constant, * or have an entry for each quadrature point. @@ -613,15 +604,14 @@ namespace LocalIntegrators */ template void - upwind_face_residual( - Vector & result1, - Vector & result2, - const FEValuesBase & fe1, - const FEValuesBase & fe2, - const std::vector & input1, - const std::vector & input2, - const VectorSlice>> &velocity, - const double factor = 1.) + upwind_face_residual(Vector & result1, + Vector & result2, + const FEValuesBase & fe1, + const FEValuesBase & fe2, + const std::vector & input1, + const std::vector & input2, + const ArrayView> &velocity, + const double factor = 1.) { Assert(fe1.get_fe().n_components() == 1, ExcDimensionMismatch(fe1.get_fe().n_components(), 1)); @@ -681,7 +671,7 @@ namespace LocalIntegrators * \,ds * @f] * - * The velocity is provided as a VectorSlice, having dim + * The velocity is provided as an ArrayView, having dim * vectors, one for each velocity component. Each of the vectors must * either have only a single entry, if the advection velocity is constant, * or have an entry for each quadrature point. @@ -691,15 +681,14 @@ namespace LocalIntegrators */ template void - upwind_face_residual( - Vector & result1, - Vector & result2, - const FEValuesBase & fe1, - const FEValuesBase & fe2, - const VectorSlice>> &input1, - const VectorSlice>> &input2, - const VectorSlice>> &velocity, - const double factor = 1.) + upwind_face_residual(Vector & result1, + Vector & result2, + const FEValuesBase & fe1, + const FEValuesBase & fe2, + const ArrayView> &input1, + const ArrayView> &input2, + const ArrayView> &velocity, + const double factor = 1.) { const unsigned int n_comp = fe1.get_fe().n_components(); const unsigned int n1 = fe1.dofs_per_cell; diff --git a/include/deal.II/integrators/divergence.h b/include/deal.II/integrators/divergence.h index 6ecbcffbd9..6345e33c3d 100644 --- a/include/deal.II/integrators/divergence.h +++ b/include/deal.II/integrators/divergence.h @@ -98,11 +98,10 @@ namespace LocalIntegrators */ template void - cell_residual( - Vector & result, - const FEValuesBase & fetest, - const VectorSlice>>> &input, - const double factor = 1.) + cell_residual(Vector & result, + const FEValuesBase & fetest, + const ArrayView>> &input, + const double factor = 1.) { AssertDimension(fetest.get_fe().n_components(), 1); AssertVectorVectorDimension(input, dim, fetest.n_quadrature_points); @@ -135,11 +134,10 @@ namespace LocalIntegrators */ template void - cell_residual( - Vector & result, - const FEValuesBase & fetest, - const VectorSlice>> &input, - const double factor = 1.) + cell_residual(Vector & result, + const FEValuesBase & fetest, + const ArrayView> &input, + const double factor = 1.) { AssertDimension(fetest.get_fe().n_components(), 1); AssertVectorVectorDimension(input, dim, fetest.n_quadrature_points); @@ -317,12 +315,11 @@ namespace LocalIntegrators */ template void - u_dot_n_residual( - Vector & result, - const FEValuesBase & fe, - const FEValuesBase & fetest, - const VectorSlice>> &data, - double factor = 1.) + u_dot_n_residual(Vector & result, + const FEValuesBase & fe, + const FEValuesBase & fetest, + const ArrayView> &data, + double factor = 1.) { const unsigned int t_dofs = fetest.dofs_per_cell; @@ -461,19 +458,17 @@ namespace LocalIntegrators */ template DEAL_II_DEPRECATED void - grad_div_residual( - Vector & result, - const FEValuesBase & fetest, - const VectorSlice>>> &input, - const double factor = 1.); + grad_div_residual(Vector & result, + const FEValuesBase &fetest, + const ArrayView>> &input, + const double factor = 1.); template void - grad_div_residual( - Vector & result, - const FEValuesBase & fetest, - const VectorSlice>>> &input, - const double factor) + grad_div_residual(Vector & result, + const FEValuesBase &fetest, + const ArrayView>> &input, + const double factor) { GradDiv::cell_residual(result, fetest, input, factor); } @@ -550,8 +545,8 @@ namespace LocalIntegrators */ template double - norm(const FEValuesBase & fe, - const VectorSlice>>> &Du) + norm(const FEValuesBase & fe, + const ArrayView>> &Du) { AssertDimension(fe.get_fe().n_components(), dim); AssertVectorVectorDimension(Du, dim, fe.n_quadrature_points); diff --git a/include/deal.II/integrators/elasticity.h b/include/deal.II/integrators/elasticity.h index a5511ebea2..dcd5ccb92c 100644 --- a/include/deal.II/integrators/elasticity.h +++ b/include/deal.II/integrators/elasticity.h @@ -83,11 +83,10 @@ namespace LocalIntegrators */ template inline void - cell_residual( - Vector & result, - const FEValuesBase & fe, - const VectorSlice>>> &input, - double factor = 1.) + cell_residual(Vector & result, + const FEValuesBase & fe, + const ArrayView>> &input, + double factor = 1.) { const unsigned int nq = fe.n_quadrature_points; const unsigned int n_dofs = fe.dofs_per_cell; @@ -260,14 +259,13 @@ namespace LocalIntegrators */ template void - nitsche_residual( - Vector & result, - const FEValuesBase & fe, - const VectorSlice>> & input, - const VectorSlice>>> &Dinput, - const VectorSlice>> & data, - double penalty, - double factor = 1.) + nitsche_residual(Vector & result, + const FEValuesBase & fe, + const ArrayView> & input, + const ArrayView>> &Dinput, + const ArrayView> & data, + double penalty, + double factor = 1.) { const unsigned int n_dofs = fe.dofs_per_cell; AssertVectorVectorDimension(input, dim, fe.n_quadrature_points); @@ -314,13 +312,13 @@ namespace LocalIntegrators template inline void nitsche_tangential_residual( - Vector & result, - const FEValuesBase & fe, - const VectorSlice>> & input, - const VectorSlice>>> &Dinput, - const VectorSlice>> & data, - double penalty, - double factor = 1.) + Vector & result, + const FEValuesBase & fe, + const ArrayView> & input, + const ArrayView>> &Dinput, + const ArrayView> & data, + double penalty, + double factor = 1.) { const unsigned int n_dofs = fe.dofs_per_cell; AssertVectorVectorDimension(input, dim, fe.n_quadrature_points); @@ -395,12 +393,12 @@ namespace LocalIntegrators template void nitsche_residual_homogeneous( - Vector & result, - const FEValuesBase & fe, - const VectorSlice>> & input, - const VectorSlice>>> &Dinput, - double penalty, - double factor = 1.) + Vector & result, + const FEValuesBase & fe, + const ArrayView> & input, + const ArrayView>> &Dinput, + double penalty, + double factor = 1.) { const unsigned int n_dofs = fe.dofs_per_cell; AssertVectorVectorDimension(input, dim, fe.n_quadrature_points); @@ -550,20 +548,17 @@ namespace LocalIntegrators */ template void - ip_residual( - Vector & result1, - Vector & result2, - const FEValuesBase & fe1, - const FEValuesBase & fe2, - const VectorSlice>> &input1, - const VectorSlice>>> - & Dinput1, - const VectorSlice>> &input2, - const VectorSlice>>> - & Dinput2, - double pen, - double int_factor = 1., - double ext_factor = -1.) + ip_residual(Vector & result1, + Vector & result2, + const FEValuesBase & fe1, + const FEValuesBase & fe2, + const ArrayView> & input1, + const ArrayView>> &Dinput1, + const ArrayView> & input2, + const ArrayView>> &Dinput2, + double pen, + double int_factor = 1., + double ext_factor = -1.) { const unsigned int n1 = fe1.dofs_per_cell; diff --git a/include/deal.II/integrators/grad_div.h b/include/deal.II/integrators/grad_div.h index afd7e75984..60187ac0c8 100644 --- a/include/deal.II/integrators/grad_div.h +++ b/include/deal.II/integrators/grad_div.h @@ -91,11 +91,10 @@ namespace LocalIntegrators */ template void - cell_residual( - Vector & result, - const FEValuesBase & fetest, - const VectorSlice>>> &input, - const double factor = 1.) + cell_residual(Vector & result, + const FEValuesBase & fetest, + const ArrayView>> &input, + const double factor = 1.) { const unsigned int n_dofs = fetest.dofs_per_cell; @@ -183,14 +182,13 @@ namespace LocalIntegrators */ template void - nitsche_residual( - Vector & result, - const FEValuesBase & fe, - const VectorSlice>> & input, - const VectorSlice>>> &Dinput, - const VectorSlice>> & data, - double penalty, - double factor = 1.) + nitsche_residual(Vector & result, + const FEValuesBase & fe, + const ArrayView> & input, + const ArrayView>> &Dinput, + const ArrayView> & data, + double penalty, + double factor = 1.) { const unsigned int n_dofs = fe.dofs_per_cell; AssertDimension(fe.get_fe().n_components(), dim) @@ -318,20 +316,17 @@ namespace LocalIntegrators */ template void - ip_residual( - Vector & result1, - Vector & result2, - const FEValuesBase & fe1, - const FEValuesBase & fe2, - const VectorSlice>> &input1, - const VectorSlice>>> - & Dinput1, - const VectorSlice>> &input2, - const VectorSlice>>> - & Dinput2, - double pen, - double int_factor = 1., - double ext_factor = -1.) + ip_residual(Vector & result1, + Vector & result2, + const FEValuesBase & fe1, + const FEValuesBase & fe2, + const ArrayView> & input1, + const ArrayView>> &Dinput1, + const ArrayView> & input2, + const ArrayView>> &Dinput2, + double pen, + double int_factor = 1., + double ext_factor = -1.) { const unsigned int n1 = fe1.dofs_per_cell; diff --git a/include/deal.II/integrators/l2.h b/include/deal.II/integrators/l2.h index 444a762042..a2d2588c10 100644 --- a/include/deal.II/integrators/l2.h +++ b/include/deal.II/integrators/l2.h @@ -176,10 +176,10 @@ namespace LocalIntegrators */ template void - L2(Vector & result, - const FEValuesBase & fe, - const VectorSlice>> &input, - const double factor = 1.) + L2(Vector & result, + const FEValuesBase & fe, + const ArrayView> &input, + const double factor = 1.) { const unsigned int n_dofs = fe.dofs_per_cell; const unsigned int n_components = input.size(); diff --git a/include/deal.II/integrators/laplace.h b/include/deal.II/integrators/laplace.h index 3a8b1b2acc..fb63154e57 100644 --- a/include/deal.II/integrators/laplace.h +++ b/include/deal.II/integrators/laplace.h @@ -121,11 +121,10 @@ namespace LocalIntegrators */ template inline void - cell_residual( - Vector & result, - const FEValuesBase & fe, - const VectorSlice>>> &input, - double factor = 1.) + cell_residual(Vector & result, + const FEValuesBase & fe, + const ArrayView>> &input, + double factor = 1.) { const unsigned int nq = fe.n_quadrature_points; const unsigned int n_dofs = fe.dofs_per_cell; @@ -323,14 +322,13 @@ namespace LocalIntegrators */ template void - nitsche_residual( - Vector & result, - const FEValuesBase & fe, - const VectorSlice>> & input, - const VectorSlice>>> &Dinput, - const VectorSlice>> & data, - double penalty, - double factor = 1.) + nitsche_residual(Vector & result, + const FEValuesBase & fe, + const ArrayView> & input, + const ArrayView>> &Dinput, + const ArrayView> & data, + double penalty, + double factor = 1.) { const unsigned int n_dofs = fe.dofs_per_cell; const unsigned int n_comp = fe.get_fe().n_components(); @@ -639,20 +637,17 @@ namespace LocalIntegrators */ template void - ip_residual( - Vector & result1, - Vector & result2, - const FEValuesBase & fe1, - const FEValuesBase & fe2, - const VectorSlice>> &input1, - const VectorSlice>>> - & Dinput1, - const VectorSlice>> &input2, - const VectorSlice>>> - & Dinput2, - double pen, - double int_factor = 1., - double ext_factor = -1.) + ip_residual(Vector & result1, + Vector & result2, + const FEValuesBase & fe1, + const FEValuesBase & fe2, + const ArrayView> & input1, + const ArrayView>> &Dinput1, + const ArrayView> & input2, + const ArrayView>> &Dinput2, + double pen, + double int_factor = 1., + double ext_factor = -1.) { const unsigned int n_comp = fe1.get_fe().n_components(); const unsigned int n1 = fe1.dofs_per_cell; diff --git a/include/deal.II/integrators/patches.h b/include/deal.II/integrators/patches.h index c0b80e64ac..ee6892b7d4 100644 --- a/include/deal.II/integrators/patches.h +++ b/include/deal.II/integrators/patches.h @@ -40,10 +40,10 @@ namespace LocalIntegrators namespace Patches { template - inline void points_and_values( - Table<2, double> & result, - const FEValuesBase & fe, - const VectorSlice>> &input) + inline void + points_and_values(Table<2, double> & result, + const FEValuesBase & fe, + const ArrayView> &input) { const unsigned int n_comp = fe.get_fe().n_components(); AssertVectorVectorDimension(input, n_comp, fe.n_quadrature_points); diff --git a/include/deal.II/lac/chunk_sparsity_pattern.h b/include/deal.II/lac/chunk_sparsity_pattern.h index 381ade01f3..261786b526 100644 --- a/include/deal.II/lac/chunk_sparsity_pattern.h +++ b/include/deal.II/lac/chunk_sparsity_pattern.h @@ -391,13 +391,13 @@ public: const size_type chunk_size); /** - * Same as above, but with a VectorSlice argument instead. + * Same as above, but with an ArrayView argument instead. */ void - reinit(const size_type m, - const size_type n, - const VectorSlice> &row_lengths, - const size_type chunk_size); + reinit(const size_type m, + const size_type n, + const ArrayView &row_lengths, + const size_type chunk_size); /** * This function compresses the sparsity structure that this object diff --git a/include/deal.II/lac/sparsity_pattern.h b/include/deal.II/lac/sparsity_pattern.h index 12c729bc7c..3f58fe1413 100644 --- a/include/deal.II/lac/sparsity_pattern.h +++ b/include/deal.II/lac/sparsity_pattern.h @@ -19,6 +19,7 @@ #include +#include #include #include #include @@ -51,8 +52,6 @@ template class SparseLUDecomposition; template class SparseILU; -template -class VectorSlice; namespace ChunkSparsityPatternIterators { @@ -510,12 +509,12 @@ public: /** - * Same as above, but with a VectorSlice argument instead. + * Same as above, but with an ArrayView argument instead. */ void - reinit(const size_type m, - const size_type n, - const VectorSlice> &row_lengths); + reinit(const size_type m, + const size_type n, + const ArrayView &row_lengths); /** * This function compresses the sparsity structure that this object diff --git a/source/fe/fe_values.cc b/source/fe/fe_values.cc index 8f17342c52..c997961649 100644 --- a/source/fe/fe_values.cc +++ b/source/fe/fe_values.cc @@ -3680,9 +3680,9 @@ template template void FEValuesBase::get_function_values( - const InputVector & fe_function, - const VectorSlice> &indices, - std::vector & values) const + const InputVector & fe_function, + const ArrayView &indices, + std::vector & values) const { using Number = typename InputVector::value_type; Assert(this->update_flags & update_values, @@ -3732,9 +3732,9 @@ template template void FEValuesBase::get_function_values( - const InputVector & fe_function, - const VectorSlice> &indices, - std::vector> & values) const + const InputVector & fe_function, + const ArrayView & indices, + std::vector> &values) const { using Number = typename InputVector::value_type; // Size of indices must be a multiple of dofs_per_cell such that an integer @@ -3763,10 +3763,9 @@ template template void FEValuesBase::get_function_values( - const InputVector & fe_function, - const VectorSlice> &indices, - VectorSlice>> - values, + const InputVector & fe_function, + const ArrayView & indices, + ArrayView> values, bool quadrature_points_fastest) const { using Number = typename InputVector::value_type; @@ -3823,8 +3822,8 @@ template template void FEValuesBase::get_function_gradients( - const InputVector & fe_function, - const VectorSlice> &indices, + const InputVector & fe_function, + const ArrayView &indices, std::vector> &gradients) const { @@ -3877,10 +3876,9 @@ template template void FEValuesBase::get_function_gradients( - const InputVector & fe_function, - const VectorSlice> &indices, - VectorSlice>>> + const InputVector & fe_function, + const ArrayView &indices, + ArrayView>> gradients, bool quadrature_points_fastest) const { @@ -3937,8 +3935,8 @@ template template void FEValuesBase::get_function_hessians( - const InputVector & fe_function, - const VectorSlice> &indices, + const InputVector & fe_function, + const ArrayView &indices, std::vector> &hessians) const { @@ -3993,10 +3991,9 @@ template template void FEValuesBase::get_function_hessians( - const InputVector & fe_function, - const VectorSlice> &indices, - VectorSlice>>> + const InputVector & fe_function, + const ArrayView &indices, + ArrayView>> hessians, bool quadrature_points_fastest) const { @@ -4050,9 +4047,9 @@ template template void FEValuesBase::get_function_laplacians( - const InputVector & fe_function, - const VectorSlice> &indices, - std::vector &laplacians) const + const InputVector & fe_function, + const ArrayView &indices, + std::vector & laplacians) const { using Number = typename InputVector::value_type; Assert(this->update_flags & update_hessians, @@ -4101,8 +4098,8 @@ template template void FEValuesBase::get_function_laplacians( - const InputVector & fe_function, - const VectorSlice> &indices, + const InputVector & fe_function, + const ArrayView & indices, std::vector> &laplacians) const { using Number = typename InputVector::value_type; @@ -4132,9 +4129,9 @@ template template void FEValuesBase::get_function_laplacians( - const InputVector & fe_function, - const VectorSlice> &indices, - std::vector> & laplacians, + const InputVector & fe_function, + const ArrayView & indices, + std::vector> &laplacians, bool quadrature_points_fastest) const { using Number = typename InputVector::value_type; @@ -4189,8 +4186,8 @@ template template void FEValuesBase::get_function_third_derivatives( - const InputVector & fe_function, - const VectorSlice> &indices, + const InputVector & fe_function, + const ArrayView &indices, std::vector> &third_derivatives) const { @@ -4246,10 +4243,9 @@ template template void FEValuesBase::get_function_third_derivatives( - const InputVector & fe_function, - const VectorSlice> &indices, - VectorSlice>>> + const InputVector & fe_function, + const ArrayView &indices, + ArrayView>> third_derivatives, bool quadrature_points_fastest) const { diff --git a/source/fe/fe_values.inst.in b/source/fe/fe_values.inst.in index de6b29f4cf..863a55f233 100644 --- a/source/fe/fe_values.inst.in +++ b/source/fe/fe_values.inst.in @@ -359,27 +359,24 @@ for (VEC : VECTOR_TYPES; deal_II_dimension : DIMENSIONS; get_function_values(const VEC &, std::vector &) const; template void FEValuesBase:: - get_function_values( - const VEC &, - const VectorSlice> &, - std::vector &) const; + get_function_values(const VEC &, + const ArrayView &, + std::vector &) const; template void FEValuesBase:: get_function_values(const VEC &, std::vector> &) const; template void FEValuesBase:: - get_function_values( - const VEC &, - const VectorSlice> &, - std::vector> &) const; + get_function_values(const VEC &, + const ArrayView &, + std::vector> &) const; template void FEValuesBase:: - get_function_values( - const VEC &, - const VectorSlice> &, - VectorSlice>>, - bool) const; + get_function_values(const VEC &, + const ArrayView &, + ArrayView>, + bool) const; template void FEValuesBase:: get_function_gradients( @@ -389,7 +386,7 @@ for (VEC : VECTOR_TYPES; deal_II_dimension : DIMENSIONS; template void FEValuesBase:: get_function_gradients( const VEC &, - const VectorSlice> &, + const ArrayView &, std::vector> &) const; @@ -402,9 +399,9 @@ for (VEC : VECTOR_TYPES; deal_II_dimension : DIMENSIONS; template void FEValuesBase:: get_function_gradients( const VEC &, - const VectorSlice> &, - VectorSlice>>>, + const ArrayView &, + ArrayView>>, bool) const; template void FEValuesBase:: @@ -415,7 +412,7 @@ for (VEC : VECTOR_TYPES; deal_II_dimension : DIMENSIONS; template void FEValuesBase:: get_function_hessians( const VEC &, - const VectorSlice> &, + const ArrayView &, std::vector> &) const; @@ -428,9 +425,9 @@ for (VEC : VECTOR_TYPES; deal_II_dimension : DIMENSIONS; template void FEValuesBase:: get_function_hessians( const VEC &, - const VectorSlice> &, - VectorSlice>>>, + const ArrayView &, + ArrayView>>, bool) const; template void FEValuesBase:: @@ -439,7 +436,7 @@ for (VEC : VECTOR_TYPES; deal_II_dimension : DIMENSIONS; template void FEValuesBase:: get_function_laplacians( const VEC &, - const VectorSlice> &, + const ArrayView &, std::vector &) const; template void FEValuesBase:: @@ -450,13 +447,13 @@ for (VEC : VECTOR_TYPES; deal_II_dimension : DIMENSIONS; template void FEValuesBase:: get_function_laplacians( const VEC &, - const VectorSlice> &, + const ArrayView &, std::vector> &) const; template void FEValuesBase:: get_function_laplacians( const VEC &, - const VectorSlice> &, + const ArrayView &, std::vector> &, bool) const; @@ -468,7 +465,7 @@ for (VEC : VECTOR_TYPES; deal_II_dimension : DIMENSIONS; template void FEValuesBase:: get_function_third_derivatives( const VEC &, - const VectorSlice> &, + const ArrayView &, std::vector> &) const; @@ -481,9 +478,9 @@ for (VEC : VECTOR_TYPES; deal_II_dimension : DIMENSIONS; template void FEValuesBase:: get_function_third_derivatives( const VEC &, - const VectorSlice> &, - VectorSlice>>>, + const ArrayView &, + ArrayView>>, bool) const; #endif @@ -647,7 +644,7 @@ for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : DIMENSIONS) template void FEValuesBase:: get_function_values( const IndexSet &, - const VectorSlice> &, + const ArrayView &, std::vector &) const; template void FEValuesBase:: @@ -658,14 +655,14 @@ for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : DIMENSIONS) template void FEValuesBase:: get_function_values( const IndexSet &, - const VectorSlice> &, + const ArrayView &, std::vector> &) const; template void FEValuesBase:: get_function_values( const IndexSet &, - const VectorSlice> &, - VectorSlice>>, + const ArrayView &, + ArrayView>, bool) const; template void FEValuesBase:: @@ -677,7 +674,7 @@ for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : DIMENSIONS) template void FEValuesBase:: get_function_gradients( const IndexSet &, - const VectorSlice> &, + const ArrayView &, std::vector< dealii::Tensor<1, deal_II_space_dimension, IndexSet::value_type>> &) const; @@ -691,9 +688,9 @@ for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : DIMENSIONS) template void FEValuesBase:: get_function_gradients( const IndexSet &, - const VectorSlice> &, - VectorSlice>>>, + const ArrayView &, + ArrayView>>, bool) const; template void FEValuesBase:: @@ -705,7 +702,7 @@ for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : DIMENSIONS) template void FEValuesBase:: get_function_hessians( const IndexSet &, - const VectorSlice> &, + const ArrayView &, std::vector< dealii::Tensor<2, deal_II_space_dimension, IndexSet::value_type>> &) const; @@ -719,9 +716,9 @@ for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : DIMENSIONS) template void FEValuesBase:: get_function_hessians( const IndexSet &, - const VectorSlice> &, - VectorSlice>>>, + const ArrayView &, + ArrayView>>, bool) const; template void FEValuesBase:: @@ -731,7 +728,7 @@ for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : DIMENSIONS) template void FEValuesBase:: get_function_laplacians( const IndexSet &, - const VectorSlice> &, + const ArrayView &, std::vector &) const; template void FEValuesBase:: @@ -741,13 +738,13 @@ for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : DIMENSIONS) template void FEValuesBase:: get_function_laplacians( const IndexSet &, - const VectorSlice> &, + const ArrayView &, std::vector> &) const; template void FEValuesBase:: get_function_laplacians( const IndexSet &, - const VectorSlice> &, + const ArrayView &, std::vector> &, bool) const; @@ -760,7 +757,7 @@ for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : DIMENSIONS) template void FEValuesBase:: get_function_third_derivatives( const IndexSet &, - const VectorSlice> &, + const ArrayView &, std::vector< dealii::Tensor<3, deal_II_space_dimension, IndexSet::value_type>> &) const; @@ -774,9 +771,9 @@ for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : DIMENSIONS) template void FEValuesBase:: get_function_third_derivatives( const IndexSet &, - const VectorSlice> &, - VectorSlice>>>, + const ArrayView &, + ArrayView>>, bool) const; #endif } diff --git a/source/lac/block_sparsity_pattern.cc b/source/lac/block_sparsity_pattern.cc index 1383f68a53..6da10105aa 100644 --- a/source/lac/block_sparsity_pattern.cc +++ b/source/lac/block_sparsity_pattern.cc @@ -356,8 +356,12 @@ BlockSparsityPattern::reinit( row_lengths[j][0]); else { - VectorSlice> block_rows( - row_lengths[j], start, length); + Assert(row_lengths[j].begin() + start + length <= + row_lengths[j].end(), + ExcInternalError()); + ArrayView block_rows(row_lengths[j].data() + + start, + length); block(i, j).reinit(rows.block_size(i), cols.block_size(j), block_rows); diff --git a/source/lac/chunk_sparsity_pattern.cc b/source/lac/chunk_sparsity_pattern.cc index 98df3a2d71..60b4167a53 100644 --- a/source/lac/chunk_sparsity_pattern.cc +++ b/source/lac/chunk_sparsity_pattern.cc @@ -128,11 +128,10 @@ ChunkSparsityPattern::reinit(const size_type m, void -ChunkSparsityPattern::reinit( - const size_type m, - const size_type n, - const VectorSlice> &row_lengths, - const size_type chunk_size) +ChunkSparsityPattern::reinit(const size_type m, + const size_type n, + const ArrayView &row_lengths, + const size_type chunk_size) { Assert(row_lengths.size() == m, ExcInvalidNumber(m)); Assert(chunk_size > 0, ExcInvalidNumber(chunk_size)); diff --git a/source/lac/sparsity_pattern.cc b/source/lac/sparsity_pattern.cc index 0fea8a96d7..80e071960d 100644 --- a/source/lac/sparsity_pattern.cc +++ b/source/lac/sparsity_pattern.cc @@ -240,10 +240,9 @@ SparsityPattern::reinit(const size_type m, void -SparsityPattern::reinit( - const size_type m, - const size_type n, - const VectorSlice> &row_lengths) +SparsityPattern::reinit(const size_type m, + const size_type n, + const ArrayView &row_lengths) { AssertDimension(row_lengths.size(), m);