@@ -80,8 +80,8 @@ namespace LinearAlgebra
8080 * @see
8181 * @ref GlossBlockLA "Block (linear algebra)"
8282 */
83- template <typename Number>
84- class BlockVector : public BlockVectorBase <Vector<Number>>
83+ template <typename Number, typename MemorySpace = MemorySpace::Host >
84+ class BlockVector : public BlockVectorBase <Vector<Number, MemorySpace >>
8585 {
8686 public:
8787 /* *
@@ -101,7 +101,7 @@ namespace LinearAlgebra
101101 /* *
102102 * Typedef the base class for simpler access to its own alias.
103103 */
104- using BaseClass = BlockVectorBase<Vector<Number>>;
104+ using BaseClass = BlockVectorBase<Vector<Number, MemorySpace >>;
105105
106106 /* *
107107 * Typedef the type of the underlying vector.
@@ -143,7 +143,7 @@ namespace LinearAlgebra
143143 * Copy-Constructor. Dimension set to that of V, all components are
144144 * copied from V
145145 */
146- BlockVector (const BlockVector<Number> &V);
146+ BlockVector (const BlockVector<Number, MemorySpace > &V);
147147
148148 /* *
149149 * Copy constructor taking a BlockVector of another data type. This will
@@ -152,7 +152,7 @@ namespace LinearAlgebra
152152 * BlockVector with data elements with less accuracy.
153153 */
154154 template <typename OtherNumber>
155- explicit BlockVector (const BlockVector<OtherNumber> &v);
155+ explicit BlockVector (const BlockVector<OtherNumber, MemorySpace > &v);
156156
157157 /* *
158158 * Constructor. Set the number of blocks to <tt>block_sizes.size()</tt>
@@ -232,13 +232,13 @@ namespace LinearAlgebra
232232 */
233233 template <class Number2 >
234234 BlockVector &
235- operator =(const BlockVector<Number2> &V);
235+ operator =(const BlockVector<Number2, MemorySpace > &V);
236236
237237 /* *
238238 * Copy a regular vector into a block vector.
239239 */
240240 BlockVector &
241- operator =(const Vector<Number> &V);
241+ operator =(const Vector<Number, MemorySpace > &V);
242242
243243#ifdef DEAL_II_WITH_PETSC
244244 /* *
@@ -248,7 +248,7 @@ namespace LinearAlgebra
248248 *
249249 * This operator is only available if deal.II was configured with PETSc.
250250 */
251- BlockVector<Number> &
251+ BlockVector<Number, MemorySpace > &
252252 operator =(const PETScWrappers::MPI::BlockVector &petsc_vec);
253253#endif
254254
@@ -261,7 +261,7 @@ namespace LinearAlgebra
261261 * This operator is only available if deal.II was configured with
262262 * Trilinos.
263263 */
264- BlockVector<Number> &
264+ BlockVector<Number, MemorySpace > &
265265 operator =(const TrilinosWrappers::MPI::BlockVector &trilinos_vec);
266266#endif
267267
@@ -322,8 +322,8 @@ namespace LinearAlgebra
322322 */
323323 template <typename Number2>
324324 void
325- reinit (const BlockVector<Number2> &V,
326- const bool omit_zeroing_entries = false );
325+ reinit (const BlockVector<Number2, MemorySpace > &V,
326+ const bool omit_zeroing_entries = false );
327327
328328 /* *
329329 * Initialize the block vector. For each block, the local range is
@@ -336,8 +336,8 @@ namespace LinearAlgebra
336336 *
337337 * This function involves global communication, so it should only be
338338 * called once for a given layout. Use the @p reinit function with
339- * BlockVector<Number> argument to create additional vectors with the same
340- * parallel layout.
339+ * BlockVector<Number, MemorySpace > argument to create additional vectors
340+ * with the same parallel layout.
341341 *
342342 * @see
343343 * @ref GlossGhostedVector "vectors with ghost elements"
@@ -462,7 +462,8 @@ namespace LinearAlgebra
462462 */
463463 template <typename Number2>
464464 void
465- copy_locally_owned_data_from (const BlockVector<Number2> &src);
465+ copy_locally_owned_data_from (
466+ const BlockVector<Number2, MemorySpace> &src);
466467
467468 /* *
468469 * This is a collective add operation that adds a whole set of values
@@ -478,7 +479,7 @@ namespace LinearAlgebra
478479 * s*(*this)+V</tt>.
479480 */
480481 void
481- sadd (const Number s, const BlockVector<Number> &V);
482+ sadd (const Number s, const BlockVector<Number, MemorySpace > &V);
482483
483484 /* *
484485 * Return whether the vector contains only elements with value zero.
@@ -519,7 +520,7 @@ namespace LinearAlgebra
519520 * functions.
520521 */
521522 void
522- swap (BlockVector<Number> &v) noexcept ;
523+ swap (BlockVector<Number, MemorySpace > &v) noexcept ;
523524 /* * @} */
524525
525526 /* *
@@ -530,26 +531,26 @@ namespace LinearAlgebra
530531 /* *
531532 * Multiply the entire vector by a fixed factor.
532533 */
533- BlockVector<Number> &
534+ BlockVector<Number, MemorySpace > &
534535 operator *=(const Number factor);
535536
536537 /* *
537538 * Divide the entire vector by a fixed factor.
538539 */
539- BlockVector<Number> &
540+ BlockVector<Number, MemorySpace > &
540541 operator /=(const Number factor);
541542
542543 /* *
543544 * Add the vector @p V to the present one.
544545 */
545- BlockVector<Number> &
546- operator +=(const BlockVector<Number> &V);
546+ BlockVector<Number, MemorySpace > &
547+ operator +=(const BlockVector<Number, MemorySpace > &V);
547548
548549 /* *
549550 * Subtract the vector @p V from the present one.
550551 */
551- BlockVector<Number> &
552- operator -=(const BlockVector<Number> &V);
552+ BlockVector<Number, MemorySpace > &
553+ operator -=(const BlockVector<Number, MemorySpace > &V);
553554
554555 /* *
555556 * Import all the elements present in the vector's IndexSet from the input
@@ -582,7 +583,7 @@ namespace LinearAlgebra
582583 * Return the scalar product of two vectors.
583584 */
584585 Number
585- operator *(const BlockVector<Number> &V) const ;
586+ operator *(const BlockVector<Number, MemorySpace > &V) const ;
586587
587588 /* *
588589 * Calculate the scalar product between each block of this vector and @p V
@@ -602,8 +603,8 @@ namespace LinearAlgebra
602603 */
603604 template <typename FullMatrixType>
604605 void
605- multivector_inner_product (FullMatrixType &matrix,
606- const BlockVector<Number> &V,
606+ multivector_inner_product (FullMatrixType &matrix,
607+ const BlockVector<Number, MemorySpace > &V,
607608 const bool symmetric = false ) const ;
608609
609610 /* *
@@ -624,9 +625,10 @@ namespace LinearAlgebra
624625 */
625626 template <typename FullMatrixType>
626627 Number
627- multivector_inner_product_with_metric (const FullMatrixType &matrix,
628- const BlockVector<Number> &V,
629- const bool symmetric = false ) const ;
628+ multivector_inner_product_with_metric (
629+ const FullMatrixType &matrix,
630+ const BlockVector<Number, MemorySpace> &V,
631+ const bool symmetric = false ) const ;
630632
631633 /* *
632634 * Set each block of this vector as follows:
@@ -639,10 +641,10 @@ namespace LinearAlgebra
639641 */
640642 template <typename FullMatrixType>
641643 void
642- mmult (BlockVector<Number> &V,
643- const FullMatrixType &matrix,
644- const Number s = Number(0 .),
645- const Number b = Number(1 .)) const ;
644+ mmult (BlockVector<Number, MemorySpace> &V,
645+ const FullMatrixType &matrix,
646+ const Number s = Number(0 .),
647+ const Number b = Number(1 .)) const ;
646648
647649 /* *
648650 * Add @p a to all components. Note that @p a is a scalar not a vector.
@@ -654,16 +656,16 @@ namespace LinearAlgebra
654656 * Simple addition of a multiple of a vector, i.e. <tt>*this += a*V</tt>.
655657 */
656658 void
657- add (const Number a, const BlockVector<Number> &V);
659+ add (const Number a, const BlockVector<Number, MemorySpace > &V);
658660
659661 /* *
660662 * Multiple addition of scaled vectors, i.e. <tt>*this += a*V+b*W</tt>.
661663 */
662664 void
663- add (const Number a,
664- const BlockVector<Number> &V,
665- const Number b,
666- const BlockVector<Number> &W);
665+ add (const Number a,
666+ const BlockVector<Number, MemorySpace > &V,
667+ const Number b,
668+ const BlockVector<Number, MemorySpace > &W);
667669
668670 /* *
669671 * A collective add operation: This function adds a whole set of values
@@ -678,21 +680,23 @@ namespace LinearAlgebra
678680 * s*(*this)+a*V</tt>.
679681 */
680682 void
681- sadd (const Number s, const Number a, const BlockVector<Number> &V);
683+ sadd (const Number s,
684+ const Number a,
685+ const BlockVector<Number, MemorySpace> &V);
682686
683687 /* *
684688 * Scale each element of this vector by the corresponding element in the
685689 * argument. This function is mostly meant to simulate multiplication (and
686690 * immediate re-assignment) by a diagonal scaling matrix.
687691 */
688692 void
689- scale (const BlockVector<Number> &scaling_factors);
693+ scale (const BlockVector<Number, MemorySpace > &scaling_factors);
690694
691695 /* *
692696 * Assignment <tt>*this = a*V</tt>.
693697 */
694698 void
695- equ (const Number a, const BlockVector<Number> &V);
699+ equ (const Number a, const BlockVector<Number, MemorySpace > &V);
696700
697701 /* *
698702 * Return the l<sub>1</sub> norm of the vector (i.e., the sum of the
@@ -742,9 +746,9 @@ namespace LinearAlgebra
742746 * $\left<v,w\right>=\sum_i v_i \bar{w_i}$.
743747 */
744748 Number
745- add_and_dot (const Number a,
746- const BlockVector<Number> &V,
747- const BlockVector<Number> &W);
749+ add_and_dot (const Number a,
750+ const BlockVector<Number, MemorySpace > &V,
751+ const BlockVector<Number, MemorySpace > &W);
748752
749753 /* *
750754 * Return the global size of the vector, equal to the sum of the number of
@@ -816,10 +820,10 @@ namespace LinearAlgebra
816820 *
817821 * @relatesalso BlockVector
818822 */
819- template <typename Number>
823+ template <typename Number, typename MemorySpace >
820824inline void
821- swap (LinearAlgebra::distributed::BlockVector<Number> &u,
822- LinearAlgebra::distributed::BlockVector<Number> &v) noexcept
825+ swap (LinearAlgebra::distributed::BlockVector<Number, MemorySpace > &u,
826+ LinearAlgebra::distributed::BlockVector<Number, MemorySpace > &v) noexcept
823827{
824828 u.swap (v);
825829}
@@ -829,8 +833,9 @@ swap(LinearAlgebra::distributed::BlockVector<Number> &u,
829833 * Declare dealii::LinearAlgebra::distributed::BlockVector as distributed
830834 * vector.
831835 */
832- template <typename Number>
833- struct is_serial_vector <LinearAlgebra::distributed::BlockVector<Number>>
836+ template <typename Number, typename MemorySpace>
837+ struct is_serial_vector <
838+ LinearAlgebra::distributed::BlockVector<Number, MemorySpace>>
834839 : std::false_type
835840{};
836841
0 commit comments