42 #ifndef TPETRA_EXPERIMENTAL_BLOCKMULTIVECTOR_DEF_HPP 43 #define TPETRA_EXPERIMENTAL_BLOCKMULTIVECTOR_DEF_HPP 45 #include "Tpetra_Experimental_BlockMultiVector_decl.hpp" 60 template<
class MultiVectorType>
61 struct RawHostPtrFromMultiVector {
62 typedef typename MultiVectorType::impl_scalar_type impl_scalar_type;
64 static impl_scalar_type* getRawPtr (MultiVectorType& X) {
70 auto X_view_host = X.template getLocalView<Kokkos::HostSpace> ();
71 impl_scalar_type* X_raw = X_view_host.ptr_on_device ();
88 template<
class S,
class LO,
class GO,
class N>
92 return RawHostPtrFromMultiVector<MV>::getRawPtr (X);
98 namespace Experimental {
100 template<
class Scalar,
class LO,
class GO,
class Node>
108 template<
class Scalar,
class LO,
class GO,
class Node>
109 Teuchos::RCP<const BlockMultiVector<Scalar, LO, GO, Node> >
114 const BMV* src_bmv =
dynamic_cast<const BMV*
> (&src);
115 TEUCHOS_TEST_FOR_EXCEPTION(
116 src_bmv == NULL, std::invalid_argument,
"Tpetra::Experimental::" 117 "BlockMultiVector: The source object of an Import or Export to a " 118 "BlockMultiVector, must also be a BlockMultiVector.");
119 return Teuchos::rcp (src_bmv,
false);
122 template<
class Scalar,
class LO,
class GO,
class Node>
129 pointMap_ (makePointMap (meshMap, blockSize)),
130 mv_ (
Teuchos::rcpFromRef (pointMap_), numVecs),
131 mvData_ (getRawHostPtrFromMultiVector (mv_)),
132 blockSize_ (blockSize)
138 template<
class Scalar,
class LO,
class GO,
class Node>
146 pointMap_ (pointMap),
147 mv_ (
Teuchos::rcpFromRef (pointMap_), numVecs),
148 mvData_ (getRawHostPtrFromMultiVector (mv_)),
149 blockSize_ (blockSize)
155 template<
class Scalar,
class LO,
class GO,
class Node>
159 const LO blockSize) :
163 blockSize_ (blockSize)
179 RCP<const mv_type> X_view_const;
182 Teuchos::Array<size_t> cols (0);
183 X_view_const = X_mv.
subView (cols ());
185 X_view_const = X_mv.
subView (Teuchos::Range1D (0, numCols-1));
187 TEUCHOS_TEST_FOR_EXCEPTION(
188 X_view_const.is_null (), std::logic_error,
"Tpetra::Experimental::" 189 "BlockMultiVector constructor: X_mv.subView(...) returned null. This " 190 "should never happen. Please report this bug to the Tpetra developers.");
195 RCP<mv_type> X_view = Teuchos::rcp_const_cast<
mv_type> (X_view_const);
197 TEUCHOS_TEST_FOR_EXCEPTION(
198 X_view->getCopyOrView () != Teuchos::View, std::logic_error,
"Tpetra::" 199 "Experimental::BlockMultiVector constructor: We just set a MultiVector " 200 "to have view semantics, but it claims that it doesn't have view " 201 "semantics. This should never happen. " 202 "Please report this bug to the Tpetra developers.");
207 Teuchos::RCP<const map_type> pointMap =
mv_.
getMap ();
208 if (! pointMap.is_null ()) {
209 pointMap_ = *pointMap;
211 mvData_ = getRawHostPtrFromMultiVector (
mv_);
214 template<
class Scalar,
class LO,
class GO,
class Node>
219 const size_t offset) :
221 meshMap_ (newMeshMap),
222 pointMap_ (newPointMap),
223 mv_ (X.mv_, newPointMap, offset * X.getBlockSize ()),
224 mvData_ (getRawHostPtrFromMultiVector (mv_)),
225 blockSize_ (X.getBlockSize ())
231 template<
class Scalar,
class LO,
class GO,
class Node>
235 const size_t offset) :
237 meshMap_ (newMeshMap),
238 pointMap_ (makePointMap (newMeshMap, X.getBlockSize ())),
239 mv_ (X.mv_, pointMap_, offset * X.getBlockSize ()),
240 mvData_ (getRawHostPtrFromMultiVector (mv_)),
241 blockSize_ (X.getBlockSize ())
247 template<
class Scalar,
class LO,
class GO,
class Node>
258 template<
class Scalar,
class LO,
class GO,
class Node>
264 typedef typename Teuchos::ArrayView<const GO>::size_type size_type;
266 const GST gblNumMeshMapInds =
268 const size_t lclNumMeshMapIndices =
270 const GST gblNumPointMapInds =
271 gblNumMeshMapInds *
static_cast<GST
> (blockSize);
272 const size_t lclNumPointMapInds =
273 lclNumMeshMapIndices *
static_cast<size_t> (blockSize);
277 return map_type (gblNumPointMapInds, lclNumPointMapInds, indexBase,
285 const size_type lclNumMeshGblInds = lclMeshGblInds.size ();
286 Teuchos::Array<GO> lclPointGblInds (lclNumPointMapInds);
287 for (size_type g = 0; g < lclNumMeshGblInds; ++g) {
288 const GO meshGid = lclMeshGblInds[g];
289 const GO pointGidStart = indexBase +
290 (meshGid - indexBase) * static_cast<GO> (blockSize);
291 const size_type offset = g *
static_cast<size_type
> (blockSize);
292 for (LO k = 0; k < blockSize; ++k) {
293 const GO pointGid = pointGidStart +
static_cast<GO
> (k);
294 lclPointGblInds[offset +
static_cast<size_type
> (k)] = pointGid;
297 return map_type (gblNumPointMapInds, lclPointGblInds (), indexBase,
303 template<
class Scalar,
class LO,
class GO,
class Node>
308 const Scalar vals[])
const 310 auto X_dst = getLocalBlock (localRowIndex, colIndex);
311 typename const_little_vec_type::HostMirror::const_type X_src (reinterpret_cast<const impl_scalar_type*> (vals),
317 template<
class Scalar,
class LO,
class GO,
class Node>
322 const Scalar vals[])
const 324 if (! meshMap_.isNodeLocalElement (localRowIndex)) {
327 replaceLocalValuesImpl (localRowIndex, colIndex, vals);
332 template<
class Scalar,
class LO,
class GO,
class Node>
337 const Scalar vals[])
const 339 const LO localRowIndex = meshMap_.getLocalElement (globalRowIndex);
340 if (localRowIndex == Teuchos::OrdinalTraits<LO>::invalid ()) {
343 replaceLocalValuesImpl (localRowIndex, colIndex, vals);
348 template<
class Scalar,
class LO,
class GO,
class Node>
353 const Scalar vals[])
const 355 auto X_dst = getLocalBlock (localRowIndex, colIndex);
356 typename const_little_vec_type::HostMirror::const_type X_src (reinterpret_cast<const impl_scalar_type*> (vals),
358 AXPY (STS::one (), X_src, X_dst);
361 template<
class Scalar,
class LO,
class GO,
class Node>
366 const Scalar vals[])
const 368 if (! meshMap_.isNodeLocalElement (localRowIndex)) {
371 sumIntoLocalValuesImpl (localRowIndex, colIndex, vals);
376 template<
class Scalar,
class LO,
class GO,
class Node>
381 const Scalar vals[])
const 383 const LO localRowIndex = meshMap_.getLocalElement (globalRowIndex);
384 if (localRowIndex == Teuchos::OrdinalTraits<LO>::invalid ()) {
387 sumIntoLocalValuesImpl (localRowIndex, colIndex, vals);
392 template<
class Scalar,
class LO,
class GO,
class Node>
397 if (! meshMap_.isNodeLocalElement (localRowIndex)) {
400 auto X_ij = getLocalBlock (localRowIndex, colIndex);
401 vals =
reinterpret_cast<Scalar*
> (X_ij.ptr_on_device ());
406 template<
class Scalar,
class LO,
class GO,
class Node>
411 const LO localRowIndex = meshMap_.getLocalElement (globalRowIndex);
412 if (localRowIndex == Teuchos::OrdinalTraits<LO>::invalid ()) {
415 auto X_ij = getLocalBlock (localRowIndex, colIndex);
416 vals =
reinterpret_cast<Scalar*
> (X_ij.ptr_on_device ());
421 template<
class Scalar,
class LO,
class GO,
class Node>
425 const LO colIndex)
const 439 if (! isValidLocalMeshIndex (localRowIndex)) {
440 return typename little_vec_type::HostMirror ();
442 const size_t blockSize = getBlockSize ();
443 const size_t offset = colIndex * this->getStrideY () +
444 localRowIndex * blockSize;
446 return typename little_vec_type::HostMirror (blockRaw, blockSize);
450 template<
class Scalar,
class LO,
class GO,
class Node>
451 Teuchos::RCP<const typename BlockMultiVector<Scalar, LO, GO, Node>::mv_type>
456 using Teuchos::rcpFromRef;
463 const this_type* srcBlkVec =
dynamic_cast<const this_type*
> (&src);
464 if (srcBlkVec == NULL) {
465 const mv_type* srcMultiVec =
dynamic_cast<const mv_type*
> (&src);
466 if (srcMultiVec == NULL) {
470 return rcp (
new mv_type ());
472 return rcp (srcMultiVec,
false);
475 return rcpFromRef (srcBlkVec->mv_);
479 template<
class Scalar,
class LO,
class GO,
class Node>
483 return ! getMultiVectorFromSrcDistObject (src).is_null ();
486 template<
class Scalar,
class LO,
class GO,
class Node>
490 const Teuchos::ArrayView<const LO>& permuteToLIDs,
491 const Teuchos::ArrayView<const LO>& permuteFromLIDs)
493 const char tfecfFuncName[] =
"copyAndPermute: ";
494 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
495 permuteToLIDs.size() != permuteFromLIDs.size(), std::runtime_error,
496 "permuteToLIDs and permuteFromLIDs must have the same size." 497 << std::endl <<
"permuteToLIDs.size() = " << permuteToLIDs.size ()
498 <<
" != permuteFromLIDs.size() = " << permuteFromLIDs.size () <<
".");
501 Teuchos::RCP<const BMV> srcAsBmvPtr = getBlockMultiVectorFromSrcDistObject (src);
502 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
503 srcAsBmvPtr.is_null (), std::invalid_argument,
504 "The source of an Import or Export to a BlockMultiVector " 505 "must also be a BlockMultiVector.");
506 const BMV& srcAsBmv = *srcAsBmvPtr;
511 const LO numVecs = getNumVectors ();
512 const LO numSame =
static_cast<LO
> (numSameIDs);
513 for (LO j = 0; j < numVecs; ++j) {
514 for (LO lclRow = 0; lclRow < numSame; ++lclRow) {
515 deep_copy (getLocalBlock (lclRow, j), srcAsBmv.getLocalBlock (lclRow, j));
522 const LO numPermuteLIDs =
static_cast<LO
> (permuteToLIDs.size ());
523 for (LO j = 0; j < numVecs; ++j) {
524 for (LO k = numSame; k < numPermuteLIDs; ++k) {
525 deep_copy (getLocalBlock (permuteToLIDs[k], j), srcAsBmv.getLocalBlock (permuteFromLIDs[k], j));
530 template<
class Scalar,
class LO,
class GO,
class Node>
533 const Teuchos::ArrayView<const LO>& exportLIDs,
534 Teuchos::Array<impl_scalar_type>& exports,
535 const Teuchos::ArrayView<size_t>& ,
536 size_t& constantNumPackets,
540 typedef typename Teuchos::ArrayView<const LO>::size_type size_type;
541 const char tfecfFuncName[] =
"packAndPrepare: ";
543 Teuchos::RCP<const BMV> srcAsBmvPtr = getBlockMultiVectorFromSrcDistObject (src);
544 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
545 srcAsBmvPtr.is_null (), std::invalid_argument,
546 "The source of an Import or Export to a BlockMultiVector " 547 "must also be a BlockMultiVector.");
548 const BMV& srcAsBmv = *srcAsBmvPtr;
550 const LO numVecs = getNumVectors ();
551 const LO blockSize = getBlockSize ();
557 static_cast<size_t> (blockSize) * static_cast<size_t> (numVecs);
558 const size_type numMeshLIDs = exportLIDs.size ();
560 const size_type requiredExportsSize = numMeshLIDs *
561 static_cast<size_type
> (blockSize) * static_cast<size_type> (numVecs);
562 exports.resize (requiredExportsSize);
565 size_type curExportPos = 0;
566 for (size_type meshLidIndex = 0; meshLidIndex < numMeshLIDs; ++meshLidIndex) {
567 for (LO j = 0; j < numVecs; ++j, curExportPos += blockSize) {
568 const LO meshLid = exportLIDs[meshLidIndex];
570 typename little_vec_type::HostMirror X_dst (curExportPtr, blockSize);
571 auto X_src = srcAsBmv.getLocalBlock (meshLid, j);
576 }
catch (std::exception& e) {
577 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
578 true, std::logic_error,
"Oh no! packAndPrepare on Process " 579 << meshMap_.getComm ()->getRank () <<
" raised the following exception: " 584 template<
class Scalar,
class LO,
class GO,
class Node>
587 const Teuchos::ArrayView<const impl_scalar_type>& imports,
588 const Teuchos::ArrayView<size_t>& numPacketsPerLID,
589 size_t constantNumPackets,
593 typedef typename Teuchos::ArrayView<const LO>::size_type size_type;
594 const char tfecfFuncName[] =
"unpackAndCombine: ";
596 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
598 std::invalid_argument,
"Invalid CombineMode: " << CM <<
". Valid " 599 "CombineMode values are ADD, REPLACE, INSERT, ABSMAX, and ZERO.");
607 const size_type numMeshLIDs = importLIDs.size ();
608 const LO blockSize = getBlockSize ();
609 const LO numVecs = getNumVectors ();
611 const size_type requiredImportsSize = numMeshLIDs *
612 static_cast<size_type
> (blockSize) * static_cast<size_type> (numVecs);
613 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
614 imports.size () < requiredImportsSize, std::logic_error,
615 ": imports.size () = " << imports.size ()
616 <<
" < requiredImportsSize = " << requiredImportsSize <<
".");
618 size_type curImportPos = 0;
619 for (size_type meshLidIndex = 0; meshLidIndex < numMeshLIDs; ++meshLidIndex) {
620 for (LO j = 0; j < numVecs; ++j, curImportPos += blockSize) {
621 const LO meshLid = importLIDs[meshLidIndex];
624 typename const_little_vec_type::HostMirror::const_type X_src (curImportPtr, blockSize);
625 auto X_dst = getLocalBlock (meshLid, j);
629 }
else if (CM ==
ADD) {
630 AXPY (STS::one (), X_src, X_dst);
631 }
else if (CM ==
ABSMAX) {
632 Impl::absMax (X_dst, X_src);
638 template<
class Scalar,
class LO,
class GO,
class Node>
645 template<
class Scalar,
class LO,
class GO,
class Node>
652 template<
class Scalar,
class LO,
class GO,
class Node>
658 mv_.update (alpha, X.
mv_, beta);
663 template <
typename Scalar,
typename ViewY,
typename ViewD,
typename ViewX>
664 struct BlockWiseMultiply {
665 typedef typename ViewD::size_type Size;
668 typedef typename ViewD::device_type Device;
669 typedef typename ViewD::non_const_value_type ImplScalar;
670 typedef Kokkos::MemoryTraits<Kokkos::Unmanaged> Unmanaged;
672 template <
typename View>
673 using UnmanagedView = Kokkos::View<
typename View::data_type,
typename View::array_layout,
674 typename View::device_type, Unmanaged>;
675 typedef UnmanagedView<ViewY> UnMViewY;
676 typedef UnmanagedView<ViewD> UnMViewD;
677 typedef UnmanagedView<ViewX> UnMViewX;
679 const Size block_size_;
686 BlockWiseMultiply (
const Size block_size,
const Scalar& alpha,
687 const ViewY& Y,
const ViewD& D,
const ViewX& X)
688 : block_size_(block_size), alpha_(alpha), Y_(Y), D_(D), X_(X)
691 KOKKOS_INLINE_FUNCTION
692 void operator() (
const Size k)
const {
693 const auto zero = Kokkos::Details::ArithTraits<Scalar>::zero();
694 auto D_curBlk = Kokkos::subview(D_, k, Kokkos::ALL (), Kokkos::ALL ());
695 const auto num_vecs = X_.dimension_1();
696 for (Size i = 0; i < num_vecs; ++i) {
697 Kokkos::pair<Size, Size> kslice(k*block_size_, (k+1)*block_size_);
698 auto X_curBlk = Kokkos::subview(X_, kslice, i);
699 auto Y_curBlk = Kokkos::subview(Y_, kslice, i);
708 template <
typename Scalar,
typename ViewY,
typename ViewD,
typename ViewX>
709 inline BlockWiseMultiply<Scalar, ViewY, ViewD, ViewX>
710 createBlockWiseMultiply (
const int block_size,
const Scalar& alpha,
711 const ViewY& Y,
const ViewD& D,
const ViewX& X) {
712 return BlockWiseMultiply<Scalar, ViewY, ViewD, ViewX>(block_size, alpha, Y, D, X);
715 template <
typename ViewY,
719 typename LO =
typename ViewY::size_type>
720 class BlockJacobiUpdate {
722 typedef typename ViewD::device_type Device;
723 typedef typename ViewD::non_const_value_type ImplScalar;
724 typedef Kokkos::MemoryTraits<Kokkos::Unmanaged> Unmanaged;
726 template <
typename ViewType>
727 using UnmanagedView = Kokkos::View<
typename ViewType::data_type,
728 typename ViewType::array_layout,
729 typename ViewType::device_type,
731 typedef UnmanagedView<ViewY> UnMViewY;
732 typedef UnmanagedView<ViewD> UnMViewD;
733 typedef UnmanagedView<ViewZ> UnMViewZ;
743 BlockJacobiUpdate (
const ViewY& Y,
747 const Scalar& beta) :
748 blockSize_ (D.dimension_1 ()),
756 static_assert (static_cast<int> (ViewY::rank) == 1,
757 "Y must have rank 1.");
758 static_assert (static_cast<int> (ViewD::rank) == 3,
"D must have rank 3.");
759 static_assert (static_cast<int> (ViewZ::rank) == 1,
760 "Z must have rank 1.");
766 KOKKOS_INLINE_FUNCTION
void 767 operator() (
const LO& k)
const 770 using Kokkos::subview;
771 typedef Kokkos::pair<LO, LO> range_type;
772 typedef Kokkos::Details::ArithTraits<Scalar> KAT;
776 auto D_curBlk = subview (D_, k, ALL (), ALL ());
777 const range_type kslice (k*blockSize_, (k+1)*blockSize_);
781 auto Z_curBlk = subview (Z_, kslice);
782 auto Y_curBlk = subview (Y_, kslice);
784 if (beta_ == KAT::zero ()) {
787 else if (beta_ != KAT::one ()) {
794 template<
class ViewY,
798 class LO =
typename ViewD::size_type>
800 blockJacobiUpdate (
const ViewY& Y,
806 static_assert (Kokkos::Impl::is_view<ViewY>::value,
"Y must be a Kokkos::View.");
807 static_assert (Kokkos::Impl::is_view<ViewD>::value,
"D must be a Kokkos::View.");
808 static_assert (Kokkos::Impl::is_view<ViewZ>::value,
"Z must be a Kokkos::View.");
809 static_assert (static_cast<int> (ViewY::rank) == static_cast<int> (ViewZ::rank),
810 "Y and Z must have the same rank.");
811 static_assert (static_cast<int> (ViewD::rank) == 3,
"D must have rank 3.");
813 const auto lclNumMeshRows = D.dimension_0 ();
815 #ifdef HAVE_TPETRA_DEBUG 819 const auto blkSize = D.dimension_1 ();
820 const auto lclNumPtRows = lclNumMeshRows * blkSize;
821 TEUCHOS_TEST_FOR_EXCEPTION
822 (Y.dimension_0 () != lclNumPtRows, std::invalid_argument,
823 "blockJacobiUpdate: Y.dimension_0() = " << Y.dimension_0 () <<
" != " 824 "D.dimension_0()*D.dimension_1() = " << lclNumMeshRows <<
" * " << blkSize
825 <<
" = " << lclNumPtRows <<
".");
826 TEUCHOS_TEST_FOR_EXCEPTION
827 (Y.dimension_0 () != Z.dimension_0 (), std::invalid_argument,
828 "blockJacobiUpdate: Y.dimension_0() = " << Y.dimension_0 () <<
" != " 829 "Z.dimension_0() = " << Z.dimension_0 () <<
".");
830 TEUCHOS_TEST_FOR_EXCEPTION
831 (Y.dimension_1 () != Z.dimension_1 (), std::invalid_argument,
832 "blockJacobiUpdate: Y.dimension_1() = " << Y.dimension_1 () <<
" != " 833 "Z.dimension_1() = " << Z.dimension_1 () <<
".");
834 #endif // HAVE_TPETRA_DEBUG 836 BlockJacobiUpdate<ViewY, Scalar, ViewD, ViewZ, LO> functor (Y, alpha, D, Z, beta);
837 typedef Kokkos::RangePolicy<typename ViewY::execution_space, LO> range_type;
839 range_type range (0, static_cast<LO> (lclNumMeshRows));
840 Kokkos::parallel_for (range, functor);
845 template<
class Scalar,
class LO,
class GO,
class Node>
854 typedef typename device_type::memory_space memory_space;
855 const LO lclNumMeshRows = meshMap_.getNodeNumElements ();
857 if (alpha == STS::zero ()) {
858 this->putScalar (STS::zero ());
861 const LO blockSize = this->getBlockSize ();
863 auto X_lcl = X.
mv_.template getLocalView<memory_space> ();
864 auto Y_lcl = this->mv_.template getLocalView<memory_space> ();
865 auto bwm = Impl::createBlockWiseMultiply (blockSize, alphaImpl, Y_lcl, D, X_lcl);
872 Kokkos::RangePolicy<execution_space, LO> range (0, lclNumMeshRows);
873 Kokkos::parallel_for (range, bwm);
877 template<
class Scalar,
class LO,
class GO,
class Node>
887 using Kokkos::subview;
888 typedef typename device_type::memory_space memory_space;
891 const IST alphaImpl =
static_cast<IST
> (alpha);
892 const IST betaImpl =
static_cast<IST
> (beta);
893 const LO numVecs = mv_.getNumVectors ();
895 auto X_lcl = X.
mv_.template getLocalView<memory_space> ();
896 auto Y_lcl = this->mv_.template getLocalView<memory_space> ();
897 auto Z_lcl = Z.
mv_.template getLocalView<memory_space> ();
899 if (alpha == STS::zero ()) {
903 Z.
update (STS::one (), X, -STS::one ());
904 for (LO j = 0; j < numVecs; ++j) {
905 auto X_lcl_j = subview (X_lcl, ALL (), j);
906 auto Y_lcl_j = subview (Y_lcl, ALL (), j);
907 auto Z_lcl_j = subview (Z_lcl, ALL (), j);
908 Impl::blockJacobiUpdate (Y_lcl_j, alphaImpl, D, Z_lcl_j, betaImpl);
921 #define TPETRA_EXPERIMENTAL_BLOCKMULTIVECTOR_INSTANT(S,LO,GO,NODE) \ 922 template class Experimental::BlockMultiVector< S, LO, GO, NODE >; 924 #endif // TPETRA_EXPERIMENTAL_BLOCKMULTIVECTOR_DEF_HPP Node::device_type device_type
The Kokkos Device type.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
KOKKOS_INLINE_FUNCTION void AXPY(const CoefficientType &alpha, const ViewType1 &x, const ViewType2 &y)
y := y + alpha * x (dense vector or matrix update)
device_type::execution_space execution_space
The Kokkos execution space.
KOKKOS_INLINE_FUNCTION void GEMV(const CoeffType &alpha, const BlkType &A, const VecType1 &x, const VecType2 &y)
y := y + alpha * A * x (dense matrix-vector multiply)
KOKKOS_INLINE_FUNCTION void SCAL(const CoefficientType &alpha, const ViewType &x)
x := alpha*x, where x is either rank 1 (a vector) or rank 2 (a matrix).
mv_type mv_
The Tpetra::MultiVector used to represent the data.
Teuchos::RCP< const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > > subView(const Teuchos::Range1D &colRng) const
Return a const MultiVector with const views of selected columns.
bool replaceGlobalValues(const GO globalRowIndex, const LO colIndex, const Scalar vals[]) const
Replace all values at the given mesh point, using a global index.
bool getGlobalRowView(const GO globalRowIndex, const LO colIndex, Scalar *&vals) const
Get a writeable view of the entries at the given mesh point, using a global index.
void putScalar(const Scalar &val)
Fill all entries with the given value val.
void setCopyOrView(const Teuchos::DataAccess copyOrView)
Set whether this has copy (copyOrView = Teuchos::Copy) or view (copyOrView = Teuchos::View) semantics...
One or more distributed dense vectors.
MultiVector for multiple degrees of freedom per mesh point.
bool isContiguous() const
True if this Map is distributed contiguously, else false.
void deep_copy(MultiVector< DS, DL, DG, DN, dstClassic > &dst, const MultiVector< SS, SL, SG, SN, srcClassic > &src)
Copy the contents of the MultiVector src into dst.
static map_type makePointMap(const map_type &meshMap, const LO blockSize)
Create and return the point Map corresponding to the given mesh Map and block size.
KOKKOS_INLINE_FUNCTION void FILL(const ViewType &x, const InputType &val)
Set every entry of x to val.
virtual void unpackAndCombine(const Teuchos::ArrayView< const LO > &importLIDs, const Teuchos::ArrayView< const impl_scalar_type > &imports, const Teuchos::ArrayView< size_t > &numPacketsPerLID, size_t constantNumPackets, Tpetra::Distributor &distor, Tpetra::CombineMode CM)
Perform any unpacking and combining after communication (old version that uses Teuchos memory managem...
global_size_t getGlobalNumElements() const
The number of elements in this Map.
void scale(const Scalar &val)
Multiply all entries in place by the given value val.
void update(const Scalar &alpha, const BlockMultiVector< Scalar, LO, GO, Node > &X, const Scalar &beta)
Update: this = beta*this + alpha*X.
mv_type::impl_scalar_type impl_scalar_type
The implementation type of entries in the matrix.
bool sumIntoLocalValues(const LO localRowIndex, const LO colIndex, const Scalar vals[]) const
Sum into all values at the given mesh point, using a local index.
size_t getNodeNumElements() const
The number of elements belonging to the calling process.
bool sumIntoGlobalValues(const GO globalRowIndex, const LO colIndex, const Scalar vals[]) const
Sum into all values at the given mesh point, using a global index.
size_t global_size_t
Global size_t object.
bool replaceLocalValues(const LO localRowIndex, const LO colIndex, const Scalar vals[]) const
Replace all values at the given mesh point, using local row and column indices.
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Accessors for the Teuchos::Comm and Kokkos Node objects.
Insert new values that don't currently exist.
Sets up and executes a communication plan for a Tpetra DistObject.
CombineMode
Rule for combining data in an Import or Export.
Sum new values into existing values.
void blockJacobiUpdate(const Scalar &alpha, const Kokkos::View< const impl_scalar_type ***, device_type, Kokkos::MemoryUnmanaged > &D, const BlockMultiVector< Scalar, LO, GO, Node > &X, BlockMultiVector< Scalar, LO, GO, Node > &Z, const Scalar &beta)
Block Jacobi update .
void blockWiseMultiply(const Scalar &alpha, const Kokkos::View< const impl_scalar_type ***, device_type, Kokkos::MemoryUnmanaged > &D, const BlockMultiVector< Scalar, LO, GO, Node > &X)
*this := alpha * D * X, where D is a block diagonal matrix.
virtual Teuchos::RCP< const map_type > getMap() const
The Map describing the parallel distribution of this object.
GlobalOrdinal getIndexBase() const
The index base for this Map.
Replace old value with maximum of magnitudes of old and new values.
Abstract base class for objects that can be the source of an Import or Export operation.
Replace existing values with new values.
Replace old values with zero.
mv_type getMultiVectorView() const
Get a Tpetra::MultiVector that views this BlockMultiVector's data.
Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const
Return a NONOWNING view of the global indices owned by this process.
Kokkos::Details::ArithTraits< Scalar >::val_type impl_scalar_type
The type used internally in place of Scalar.
virtual bool checkSizes(const Tpetra::SrcDistObject &source)
Compare the source and target (this) objects for compatibility.
size_t getNumVectors() const
Number of columns in the multivector.
bool getLocalRowView(const LO localRowIndex, const LO colIndex, Scalar *&vals) const
Get a writeable view of the entries at the given mesh point, using a local index. ...
Teuchos::RCP< Node > getNode() const
Get this Map's Node object.
little_vec_type::HostMirror getLocalBlock(const LO localRowIndex, const LO colIndex) const
Get a host view of the degrees of freedom at the given mesh point.
BlockMultiVector()
Default constructor.
virtual void copyAndPermute(const Tpetra::SrcDistObject &source, size_t numSameIDs, const Teuchos::ArrayView< const LO > &permuteToLIDs, const Teuchos::ArrayView< const LO > &permuteFromLIDs)
Perform copies and permutations that are local to this process.
Teuchos::DataAccess getCopyOrView() const
Get whether this has copy (copyOrView = Teuchos::Copy) or view (copyOrView = Teuchos::View) semantics...
virtual void packAndPrepare(const Tpetra::SrcDistObject &source, const Teuchos::ArrayView< const LO > &exportLIDs, Teuchos::Array< impl_scalar_type > &exports, const Teuchos::ArrayView< size_t > &numPacketsPerLID, size_t &constantNumPackets, Tpetra::Distributor &distor)
Perform any packing or preparation required for communication.
Tpetra::MultiVector< Scalar, LO, GO, Node > mv_type
The specialization of Tpetra::MultiVector that this class uses.