10#ifndef IFPACK2_CONTAINER_DEF_HPP
11#define IFPACK2_CONTAINER_DEF_HPP
14#include <Teuchos_Time.hpp>
20template<
class MatrixType>
22 const Teuchos::RCP<const row_matrix_type>& matrix,
23 const Teuchos::Array<Teuchos::Array<LO> >& partitions,
25 inputMatrix_ (matrix),
26 inputCrsMatrix_ (Teuchos::rcp_dynamic_cast<const crs_matrix_type>(inputMatrix_)),
27 inputBlockMatrix_ (Teuchos::rcp_dynamic_cast<const block_crs_matrix_type>(inputMatrix_)),
28 pointIndexed_(pointIndexed),
29 IsInitialized_(false),
35 using Teuchos::ArrayView;
52 #ifdef HAVE_IFPACK2_DEBUG
57 Teuchos::ArrayView<const LO> blockRows =
getBlockRows(i);
60 LO row = blockRows[j];
66 TEUCHOS_TEST_FOR_EXCEPTION(
67 !rowMap.isNodeLocalElement(row),
68 std::invalid_argument,
"Ifpack2::Container: "
69 "On process " << rowMap.getComm()->getRank() <<
" of "
70 << rowMap.getComm()->getSize() <<
", in the given set of local row "
71 "indices blockRows = " << Teuchos::toString(blockRows) <<
", the following "
72 "entries is not valid local row index on the calling process: "
79template<
class MatrixType>
83template<
class MatrixType>
84Teuchos::ArrayView<const typename MatrixType::local_ordinal_type>
87 return Teuchos::ArrayView<const LO>
88 (&blockRows_[blockOffsets_[blockIndex]], blockSizes_[blockIndex]);
91template<
class MatrixType>
96 LO totalBlockRows = 0;
97 numBlocks_ = partitions.size();
98 blockSizes_.resize(numBlocks_);
99 blockOffsets_.resize(numBlocks_);
101 for(
int i = 0; i < numBlocks_; i++)
103 LO rowsInBlock = partitions[i].size();
104 blockSizes_[i] = rowsInBlock;
105 blockOffsets_[i] = totalBlockRows;
106 totalBlockRows += rowsInBlock;
107 maxBlockSize_ = std::max(maxBlockSize_, rowsInBlock * scalarsPerRow_);
109 blockRows_.resize(totalBlockRows);
112 for(
int i = 0; i < numBlocks_; i++)
114 for(
int j = 0; j < blockSizes_[i]; j++)
116 blockRows_[iter++] = partitions[i][j];
121template<
class MatrixType>
126 Diag_ = rcp(
new vector_type(inputMatrix_->getDomainMap()));
127 inputMatrix_->getLocalDiagCopy(*Diag_);
131template<
class MatrixType>
133 return IsInitialized_;
136template<
class MatrixType>
141template<
class MatrixType>
143applyMV(
const mv_type& X, mv_type& Y)
const
145 TEUCHOS_TEST_FOR_EXCEPT_MSG(
true,
"Not implemented.");
148template<
class MatrixType>
152 TEUCHOS_TEST_FOR_EXCEPT_MSG(
true,
"Not implemented.");
155template<
class MatrixType>
162template<
class MatrixType>
164 SC dampingFactor, LO i)
const
166 TEUCHOS_TEST_FOR_EXCEPT_MSG(
true,
"Not implemented.");
169template <
class MatrixType>
172 using STS = Teuchos::ScalarTraits<ISC>;
173 const ISC one = STS::one();
175 size_t numVecs = X.extent(1);
177 for (LO i = 0; i < numBlocks_; i++)
180 if(blockSizes_[i] != 1 || hasBlockCrs_)
182 if(blockSizes_[i] == 0 )
184 apply(X, Y, i, Teuchos::NO_TRANS, dampingFactor, one);
188 LO LRID = blockRows_[blockOffsets_[i]];
190 auto diagView = Diag_->getLocalViewHost(Tpetra::Access::ReadOnly);
191 ISC d = one * (
static_cast<ISC
> (dampingFactor)) / diagView(LRID, 0);
192 for(
size_t nv = 0; nv < numVecs; nv++)
195 Y(LRID, nv) += x * d;
201template <
class MatrixType>
202void Container<MatrixType>::DoOverlappingJacobi(ConstHostView X, HostView Y, ConstHostView W, SC dampingFactor,
bool nonsymScaling)
const
204 using STS = Teuchos::ScalarTraits<SC>;
206 for(LO i = 0; i < numBlocks_; i++)
209 if(blockSizes_[i] == 0)
211 if(blockSizes_[i] != 1) {
213 weightedApply(X, Y, W, i, Teuchos::NO_TRANS, dampingFactor, STS::one());
220 HostView tempo(
"", X.extent(0), X.extent(1));
221 size_t numVecs = X.extent(1);
222 LO bOffset = blockOffsets_[i];
223 for (LO ii = 0; ii < blockSizes_[i]; ii++) {
224 LO LRID = blockRows_[bOffset++];
225 for (
size_t jj = 0; jj < numVecs; jj++) tempo(LRID,jj)=X(LRID,jj)/ W(LRID,0);
227 weightedApply(tempo, Y, W, i, Teuchos::NO_TRANS, dampingFactor, STS::one());
232 const ISC one = STS::one();
233 size_t numVecs = X.extent(1);
234 LO LRID = blockRows_[blockOffsets_[i]];
236 auto diagView = Diag_->getLocalViewHost(Tpetra::Access::ReadOnly);
237 ISC recip = one / diagView(LRID, 0);
238 ISC wval = W(LRID,0);
239 ISC combo = wval*recip;
240 ISC d = combo*(
static_cast<ISC
> (dampingFactor));
241 for(
size_t nv = 0; nv < numVecs; nv++)
244 Y(LRID, nv) = x * d + Y(LRID, nv);
252template<
class MatrixType,
typename LocalScalarType>
255 SC dampingFactor, LO i)
const
257 using Teuchos::ArrayView;
258 using STS = Teuchos::ScalarTraits<ISC>;
259 size_t numVecs = X.extent(1);
260 const ISC one = STS::one();
261 if(this->blockSizes_[i] == 0)
263 if(this->hasBlockCrs_ && !this->pointIndexed_)
266 ArrayView<const LO> blockRows = this->getBlockRows(i);
267 const size_t localNumRows = this->blockSizes_[i];
268 using inds_type =
typename block_crs_matrix_type::local_inds_host_view_type;
269 using vals_type =
typename block_crs_matrix_type::values_host_view_type;
270 for(
size_t j = 0; j < localNumRows; j++)
272 LO row = blockRows[j];
275 this->inputBlockMatrix_->getLocalRowView(row, colinds, values);
276 LO numEntries = (LO) colinds.size();
277 for(
size_t m = 0; m < numVecs; m++)
279 for (
int localR = 0; localR < this->bcrsBlockSize_; localR++)
280 Resid(row * this->bcrsBlockSize_ + localR, m) = X(row * this->bcrsBlockSize_ + localR, m);
281 for (LO k = 0; k < numEntries; ++k)
283 const LO col = colinds[k];
284 for(
int localR = 0; localR < this->bcrsBlockSize_; localR++)
286 for(
int localC = 0; localC < this->bcrsBlockSize_; localC++)
288 Resid(row * this->bcrsBlockSize_ + localR, m) -=
289 values[k * this->bcrsBlockSize_ * this->bcrsBlockSize_ + localR + localC * this->bcrsBlockSize_]
290 * Y2(col * this->bcrsBlockSize_ + localC, m); }
301 apply(Resid, Y2, i, Teuchos::NO_TRANS, dampingFactor, one);
303 else if(!this->hasBlockCrs_ && this->blockSizes_[i] == 1)
307 LO LRID = this->blockOffsets_[i];
311 container_exec_space().fence();
312 auto localA = this->inputCrsMatrix_->getLocalMatrixHost();
313 using size_type =
typename crs_matrix_type::local_matrix_host_type::size_type;
314 const auto& rowmap = localA.graph.row_map;
315 const auto& entries = localA.graph.entries;
316 const auto& values = localA.values;
318 auto diagView = this->Diag_->getLocalViewHost(Tpetra::Access::ReadOnly);
319 ISC d = (
static_cast<ISC> (dampingFactor)) / diagView(LRID, 0);
320 for(
size_t m = 0; m < numVecs; m++)
324 for(size_type k = rowmap(LRID); k < rowmap(LRID + 1); k++) {
325 const LO col = entries(k);
326 r -= values(k) * Y2(col, m);
333 else if(!this->inputCrsMatrix_.is_null() &&
334 std::is_same<typename crs_matrix_type::device_type::memory_space, Kokkos::HostSpace>::value)
339 container_exec_space().fence();
340 auto localA = this->inputCrsMatrix_->getLocalMatrixHost();
341 using size_type =
typename crs_matrix_type::local_matrix_host_type::size_type;
342 const auto& rowmap = localA.graph.row_map;
343 const auto& entries = localA.graph.entries;
344 const auto& values = localA.values;
345 ArrayView<const LO> blockRows = this->getBlockRows(i);
346 for(
size_t j = 0; j < size_t(blockRows.size()); j++)
348 const LO row = blockRows[j];
349 for(
size_t m = 0; m < numVecs; m++)
352 for(size_type k = rowmap(row); k < rowmap(row + 1); k++)
354 const LO col = entries(k);
355 r -= values(k) * Y2(col, m);
366 apply(Resid, Y2, i, Teuchos::NO_TRANS, dampingFactor, one);
372 ArrayView<const LO> blockRows = this->getBlockRows(i);
373 for(
size_t j = 0; j < size_t(blockRows.size()); j++)
375 const LO row = blockRows[j];
376 auto rowView = getInputRowView(row);
377 for(
size_t m = 0; m < numVecs; m++)
379 Resid(row, m) = X(row, m);
380 for (
size_t k = 0; k < rowView.size(); ++k)
382 const LO col = rowView.ind(k);
383 Resid(row, m) -= rowView.val(k) * Y2(col, m);
393 apply(Resid, Y2, i, Teuchos::NO_TRANS, dampingFactor, one);
397template<
class MatrixType>
398void Container<MatrixType>::
399DoGaussSeidel(ConstHostView X, HostView Y, HostView Y2, SC dampingFactor)
const
401 using Teuchos::Array;
402 using Teuchos::ArrayRCP;
403 using Teuchos::ArrayView;
407 using Teuchos::rcpFromRef;
410 auto numVecs = X.extent(1);
412 HostView Resid(
"", X.extent(0), X.extent(1));
413 for(LO i = 0; i < numBlocks_; i++)
415 DoGSBlock(X, Y, Y2, Resid, dampingFactor, i);
419 auto numMyRows = inputMatrix_->getLocalNumRows();
420 for (
size_t m = 0; m < numVecs; ++m)
422 for (
size_t i = 0; i < numMyRows * bcrsBlockSize_; ++i)
430template<
class MatrixType>
431void Container<MatrixType>::
432DoSGS(ConstHostView X, HostView Y, HostView Y2, SC dampingFactor)
const
435 using Teuchos::Array;
436 using Teuchos::ArrayRCP;
437 using Teuchos::ArrayView;
442 using Teuchos::rcpFromRef;
443 auto numVecs = X.extent(1);
444 HostView Resid(
"", X.extent(0), X.extent(1));
446 for(LO i = 0; i < numBlocks_; i++)
448 DoGSBlock(X, Y, Y2, Resid, dampingFactor, i);
450 static_assert(std::is_signed<LO>::value,
451 "Local ordinal must be signed (unsigned breaks reverse iteration to 0)");
453 for(LO i = numBlocks_ - 1; i >= 0; --i)
455 DoGSBlock(X, Y, Y2, Resid, dampingFactor, i);
459 auto numMyRows = inputMatrix_->getLocalNumRows();
460 for (
size_t m = 0; m < numVecs; ++m)
462 for (
size_t i = 0; i < numMyRows * bcrsBlockSize_; ++i)
470template<
class MatrixType>
471void Container<MatrixType>::
477 blockOffsets_.clear();
478 Diag_ = Teuchos::null;
483template<
class MatrixType,
class LocalScalarType>
484ContainerImpl<MatrixType, LocalScalarType>::
486 const Teuchos::RCP<const row_matrix_type>& matrix,
487 const Teuchos::Array<Teuchos::Array<LO> >& partitions,
489 : Container<MatrixType>(matrix, partitions, pointIndexed) {}
491template<
class MatrixType,
class LocalScalarType>
495template<
class MatrixType,
class LocalScalarType>
499template<
class MatrixType,
class LocalScalarType>
506 TEUCHOS_TEST_FOR_EXCEPT_MSG(
true,
"Not implemented.");
509template<
class MatrixType,
class LocalScalarType>
511applyMV (
const mv_type& X, mv_type& Y)
const
513 ConstHostView XView = X.getLocalViewHost(Tpetra::Access::ReadOnly);
514 HostView YView = Y.getLocalViewHost(Tpetra::Access::ReadWrite);
515 this->apply (XView, YView, 0);
518template<
class MatrixType,
class LocalScalarType>
522 vector_type& W)
const
524 ConstHostView XView = X.getLocalViewHost(Tpetra::Access::ReadOnly);
525 HostView YView = Y.getLocalViewHost(Tpetra::Access::ReadWrite);
526 ConstHostView WView = W.getLocalViewHost(Tpetra::Access::ReadOnly);
527 weightedApply (XView, YView, WView, 0);
530template<
class MatrixType,
class LocalScalarType>
537template<
class MatrixType,
class LocalScalarType>
542 Teuchos::ETransp mode,
544 const LSC beta)
const
546 TEUCHOS_TEST_FOR_EXCEPT_MSG(
true,
"Not implemented.");
549template<
class MatrixType,
class LocalScalarType>
550typename ContainerImpl<MatrixType, LocalScalarType>::LO
554 LO LO_INVALID = Teuchos::OrdinalTraits<LO>::invalid();
555 GO GO_INVALID = Teuchos::OrdinalTraits<GO>::invalid();
556 const map_type& globalRowMap = *(this->inputMatrix_->getRowMap());
557 const map_type& globalColMap = *(this->inputMatrix_->getColMap());
560 if(this->pointIndexed_)
562 rowLID = row / this->bcrsBlockSize_;
563 dofOffset = row % this->bcrsBlockSize_;
565 GO diagGID = globalRowMap.getGlobalElement(rowLID);
566 TEUCHOS_TEST_FOR_EXCEPTION(
567 diagGID == GO_INVALID,
568 std::runtime_error,
"Ifpack2::Container::translateRowToCol: "
569 "On process " << this->inputMatrix_->getRowMap()->getComm()->getRank() <<
570 ", at least one row index in the set of local "
571 "row indices given to the constructor is not a valid local row index in "
572 "the input matrix's row Map on this process. This should be impossible "
573 "because the constructor checks for this case. Here is the complete set "
574 "of invalid local row indices: " << rowLID <<
". "
575 "Please report this bug to the Ifpack2 developers.");
577 LO colLID = globalColMap.getLocalElement(diagGID);
578 TEUCHOS_TEST_FOR_EXCEPTION(
579 colLID == LO_INVALID,
580 std::runtime_error,
"Ifpack2::Container::translateRowToCol: "
581 "On process " << this->inputMatrix_->getRowMap()->getComm()->getRank() <<
", "
582 "at least one row index in the set of row indices given to the constructor "
583 "does not have a corresponding column index in the input matrix's column "
584 "Map. This probably means that the column(s) in question is/are empty on "
585 "this process, which would make the submatrix to extract structurally "
586 "singular. The invalid global column index is " << diagGID <<
".");
588 if(this->pointIndexed_)
589 return colLID * this->bcrsBlockSize_ + dofOffset;
593template<
class MatrixType,
class LocalScalarType>
595apply (ConstHostView X,
598 Teuchos::ETransp mode,
602 using Teuchos::ArrayView;
615 TEUCHOS_TEST_FOR_EXCEPTION(
616 ! this->IsComputed_, std::runtime_error,
"Ifpack2::Container::apply: "
617 "You must have called the compute() method before you may call apply(). "
618 "You may call the apply() method as many times as you want after calling "
619 "compute() once, but you must have called compute() at least once.");
621 const size_t numVecs = X.extent(1);
652 if(X_localBlocks_.size() == 0 || X.extent(1) != X_local_.extent(1))
655 X_localBlocks_.clear();
656 Y_localBlocks_.clear();
657 X_localBlocks_.reserve(this->numBlocks_);
658 Y_localBlocks_.reserve(this->numBlocks_);
660 X_local_ = HostViewLocal(
"X_local", this->blockRows_.size() * this->scalarsPerRow_, numVecs);
661 Y_local_ = HostViewLocal(
"Y_local", this->blockRows_.size() * this->scalarsPerRow_, numVecs);
665 for(
int i = 0; i < this->numBlocks_; i++)
667 auto blockBounds = std::make_pair(this->blockOffsets_[i] * this->scalarsPerRow_,
668 (this->blockOffsets_[i] + this->blockSizes_[i]) * this->scalarsPerRow_);
669 X_localBlocks_.emplace_back(X_local_, blockBounds, Kokkos::ALL());
670 Y_localBlocks_.emplace_back(Y_local_, blockBounds, Kokkos::ALL());
674 const ArrayView<const LO> blockRows = this->getBlockRows(blockIndex);
676 if(this->scalarsPerRow_ == 1)
677 mvgs.gatherViewToView (X_localBlocks_[blockIndex], X, blockRows);
679 mvgs.gatherViewToViewBlock (X_localBlocks_[blockIndex], X, blockRows, this->scalarsPerRow_);
686 if(this->scalarsPerRow_ == 1)
687 mvgs.gatherViewToView (Y_localBlocks_[blockIndex], Y, blockRows);
689 mvgs.gatherViewToViewBlock (Y_localBlocks_[blockIndex], Y, blockRows, this->scalarsPerRow_);
693 this->solveBlock (X_localBlocks_[blockIndex], Y_localBlocks_[blockIndex], blockIndex, mode,
698 if(this->scalarsPerRow_ == 1)
699 mvgs.scatterViewToView (Y, Y_localBlocks_[blockIndex], blockRows);
701 mvgs.scatterViewToViewBlock (Y, Y_localBlocks_[blockIndex], blockRows, this->scalarsPerRow_);
704template<
class MatrixType,
class LocalScalarType>
710 Teuchos::ETransp mode,
714 using Teuchos::ArrayRCP;
715 using Teuchos::ArrayView;
716 using Teuchos::Range1D;
721 using Teuchos::rcp_const_cast;
723 using STS = Teuchos::ScalarTraits<SC>;
732 const char prefix[] =
"Ifpack2::Container::weightedApply: ";
733 TEUCHOS_TEST_FOR_EXCEPTION(
734 ! this->IsComputed_, std::runtime_error, prefix <<
"You must have called the "
735 "compute() method before you may call this method. You may call "
736 "weightedApply() as many times as you want after calling compute() once, "
737 "but you must have called compute() at least once first.");
740 TEUCHOS_TEST_FOR_EXCEPTION(
741 this->scalarsPerRow_ > 1, std::logic_error, prefix <<
"Use of block rows isn't allowed "
742 "in overlapping Jacobi (the only method that uses weightedApply");
744 const size_t numVecs = X.extent(1);
746 TEUCHOS_TEST_FOR_EXCEPTION(
747 X.extent(1) != Y.extent(1), std::runtime_error,
748 prefix <<
"X and Y have different numbers of vectors (columns). X has "
749 << X.extent(1) <<
", but Y has " << Y.extent(1) <<
".");
755 const size_t numRows = this->blockSizes_[blockIndex];
780 if(X_localBlocks_.size() == 0 || X.extent(1) != X_local_.extent(1))
783 X_localBlocks_.clear();
784 Y_localBlocks_.clear();
785 X_localBlocks_.reserve(this->numBlocks_);
786 Y_localBlocks_.reserve(this->numBlocks_);
788 X_local_ = HostViewLocal(
"X_local", this->blockRows_.size() * this->scalarsPerRow_, numVecs);
789 Y_local_ = HostViewLocal(
"Y_local", this->blockRows_.size() * this->scalarsPerRow_, numVecs);
793 for(
int i = 0; i < this->numBlocks_; i++)
795 auto blockBounds = std::make_pair(this->blockOffsets_[i] * this->scalarsPerRow_,
796 (this->blockOffsets_[i] + this->blockSizes_[i]) * this->scalarsPerRow_);
797 X_localBlocks_.emplace_back(X_local_, blockBounds, Kokkos::ALL());
798 Y_localBlocks_.emplace_back(Y_local_, blockBounds, Kokkos::ALL());
801 if(
int(weightedApplyScratch_.extent(0)) != 3 * this->maxBlockSize_ ||
802 weightedApplyScratch_.extent(1) != numVecs)
804 weightedApplyScratch_ = HostViewLocal(
"weightedApply scratch", 3 * this->maxBlockSize_, numVecs);
807 ArrayView<const LO> blockRows = this->getBlockRows(blockIndex);
812 mvgs.gatherViewToView (X_localBlocks_[blockIndex], X, blockRows);
818 mvgs.gatherViewToView (Y_localBlocks_[blockIndex], Y, blockRows);
829 auto maxBS = this->maxBlockSize_;
830 auto bs = this->blockSizes_[blockIndex] * this->scalarsPerRow_;
832 HostSubviewLocal D_local(weightedApplyScratch_, std::make_pair(0, bs), std::make_pair(0, 1));
833 mvgs.gatherViewToView (D_local, D, blockRows);
834 HostSubviewLocal X_scaled(weightedApplyScratch_, std::make_pair(maxBS, maxBS + bs), Kokkos::ALL());
835 for(
size_t j = 0; j < numVecs; j++)
836 for(
size_t i = 0; i < numRows; i++)
837 X_scaled(i, j) = X_localBlocks_[blockIndex](i, j) * D_local(i, 0);
839 HostSubviewLocal Y_temp(weightedApplyScratch_, std::make_pair(maxBS * 2, maxBS * 2 + bs), Kokkos::ALL());
841 this->solveBlock (X_scaled, Y_temp, blockIndex, mode, STS::one(), STS::zero());
849 for(
size_t j = 0; j < numVecs; j++)
850 for(
size_t i = 0; i < numRows; i++)
851 Y_localBlocks_[blockIndex](i, j) = b * Y_localBlocks_[blockIndex](i, j) + a * Y_temp(i, j) * D_local(i, 0);
855 mvgs.scatterViewToView (Y, Y_localBlocks_[blockIndex], blockRows);
858template<
class MatrixType,
class LocalScalarType>
860 typename ContainerImpl<MatrixType, LocalScalarType>::SC,
861 typename ContainerImpl<MatrixType, LocalScalarType>::LO,
862 typename ContainerImpl<MatrixType, LocalScalarType>::GO,
863 typename ContainerImpl<MatrixType, LocalScalarType>::NO>
868 typedef typename MatrixType::nonconst_local_inds_host_view_type nonconst_local_inds_host_view_type;
869 typedef typename MatrixType::nonconst_values_host_view_type nonconst_values_host_view_type;
871 typedef typename MatrixType::local_inds_host_view_type local_inds_host_view_type;
872 typedef typename MatrixType::values_host_view_type values_host_view_type;
873 using IST =
typename row_matrix_type::impl_scalar_type;
875 if(this->hasBlockCrs_)
877 using h_inds_type =
typename block_crs_matrix_type::local_inds_host_view_type;
878 using h_vals_type =
typename block_crs_matrix_type::values_host_view_type;
881 this->inputBlockMatrix_->getLocalRowView(row / this->bcrsBlockSize_, colinds, values);
882 size_t numEntries = colinds.size();
885 h_vals_type subvals = Kokkos::subview(values,std::pair<size_t,size_t>(row % this->bcrsBlockSize_,values.size()));
886 return StridedRowView(subvals, colinds, this->bcrsBlockSize_, numEntries * this->bcrsBlockSize_);
888 else if(!this->inputMatrix_->supportsRowViews())
890 size_t maxEntries = this->inputMatrix_->getLocalMaxNumRowEntries();
891 Teuchos::Array<LO> inds(maxEntries);
892 Teuchos::Array<SC> vals(maxEntries);
893 nonconst_local_inds_host_view_type inds_v(inds.data(),maxEntries);
894 nonconst_values_host_view_type vals_v(
reinterpret_cast<IST*
>(vals.data()),maxEntries);
896 this->inputMatrix_->getLocalRowCopy(row, inds_v, vals_v, numEntries);
897 vals.resize(numEntries); inds.resize(numEntries);
903 local_inds_host_view_type colinds;
904 values_host_view_type values;
905 this->inputMatrix_->getLocalRowView(row, colinds, values);
910template<
class MatrixType,
class LocalScalarType>
914 X_localBlocks_.clear();
915 Y_localBlocks_.clear();
916 X_local_ = HostViewLocal();
917 Y_local_ = HostViewLocal();
924template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
930template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
933 : vals(), inds(), blockSize(1), nnz(
vals_.size())
935 valsCopy.swap(
vals_);
936 indsCopy.swap(
inds_);
939template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
943 #ifdef HAVE_IFPACK2_DEBUG
945 "Out-of-bounds access into Ifpack2::Container::StridedRowView");
952 return vals[
i * blockSize];
958template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
959LocalOrdinal StridedRowView<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
962 #ifdef HAVE_IFPACK2_DEBUG
963 TEUCHOS_TEST_FOR_EXCEPTION(i >= nnz, std::runtime_error,
964 "Out-of-bounds access into Ifpack2::Container::StridedRowView");
972 return inds[i / blockSize] * blockSize + i % blockSize;
978template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
979size_t StridedRowView<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
988template <
class MatrixType>
991 return obj.
print(os);
994#define IFPACK2_CONTAINER_INSTANT(S,LO,GO,N) \
995 template class Ifpack2::Container<Tpetra::RowMatrix<S, LO, GO, N>>; \
996 template class Ifpack2::ContainerImpl<Tpetra::RowMatrix<S, LO, GO, N>, S>; \
997 template class Ifpack2::Details::StridedRowView<S, LO, GO, N>; \
998 template std::ostream& operator<< <Tpetra::RowMatrix<S, LO, GO, N>>( \
999 std::ostream& os, const Ifpack2::Container<Tpetra::RowMatrix<S, LO, GO, N>>& obj);
Declaration and definition of the Ifpack2::Details::MultiVectorLocalGatherScatter class.
The implementation of the numerical features of Container (Jacobi, Gauss-Seidel, SGS)....
Definition Ifpack2_Container_decl.hpp:311
LocalScalarType LSC
The internal representation of LocalScalarType in Kokkos::View.
Definition Ifpack2_Container_decl.hpp:330
void DoGSBlock(ConstHostView X, HostView Y, HostView Y2, HostView Resid, SC dampingFactor, LO i) const
Do one step of Gauss-Seidel on block i (used by DoGaussSeidel and DoSGS)
Definition Ifpack2_Container_def.hpp:253
Interface for creating and solving a set of local linear problems.
Definition Ifpack2_Container_decl.hpp:80
virtual ~Container()
Destructor.
Definition Ifpack2_Container_def.hpp:81
bool hasBlockCrs_
Whether the input matrix is a BlockCRS matrix.
Definition Ifpack2_Container_decl.hpp:277
bool IsParallel_
Whether the problem is distributed across multiple MPI processes.
Definition Ifpack2_Container_decl.hpp:269
int numBlocks_
The number of blocks (partitions) in the container.
Definition Ifpack2_Container_decl.hpp:259
Teuchos::ArrayView< const LO > getBlockRows(int blockIndex) const
Local indices of the rows of the input matrix that belong to this block.
Definition Ifpack2_Container_def.hpp:85
static std::string getName()
Definition Ifpack2_Container_def.hpp:157
typename Kokkos::ArithTraits< SC >::val_type ISC
Internal representation of Scalar in Kokkos::View.
Definition Ifpack2_Container_decl.hpp:102
int bcrsBlockSize_
If hasBlockCrs_, the number of DOFs per vertex. Otherwise 1.
Definition Ifpack2_Container_decl.hpp:279
Teuchos::RCP< const block_crs_matrix_type > inputBlockMatrix_
The input matrix, dynamic cast to BlockCrsMatrix. May be null.
Definition Ifpack2_Container_decl.hpp:256
virtual void DoGSBlock(ConstHostView X, HostView Y, HostView Y2, HostView Resid, SC dampingFactor, LO i) const
Do one step of Gauss-Seidel on block i (used by DoGaussSeidel and DoSGS)
Definition Ifpack2_Container_def.hpp:163
virtual void applyMV(const mv_type &X, mv_type &Y) const
Wrapper for apply with MultiVector.
Definition Ifpack2_Container_def.hpp:143
LO NumLocalRows_
Number of local rows in input matrix.
Definition Ifpack2_Container_decl.hpp:271
bool isInitialized() const
Whether the container has been successfully initialized.
Definition Ifpack2_Container_def.hpp:132
void setBlockSizes(const Teuchos::Array< Teuchos::Array< LO > > &partitions)
Initialize arrays with information about block sizes.
Definition Ifpack2_Container_def.hpp:92
LO scalarsPerRow_
Definition Ifpack2_Container_decl.hpp:284
Teuchos::Array< LO > blockSizes_
Number of rows in each block.
Definition Ifpack2_Container_decl.hpp:263
GO NumGlobalNonzeros_
Number of nonzeros in input matrix.
Definition Ifpack2_Container_decl.hpp:275
Container(const Teuchos::RCP< const row_matrix_type > &matrix, const Teuchos::Array< Teuchos::Array< LO > > &partitions, bool pointIndexed)
Constructor.
Definition Ifpack2_Container_def.hpp:21
virtual std::ostream & print(std::ostream &os) const =0
Print basic information about the container to os.
virtual void weightedApplyMV(const mv_type &X, mv_type &Y, vector_type &W) const
Wrapper for weightedApply with MultiVector.
Definition Ifpack2_Container_def.hpp:150
Teuchos::RCP< const row_matrix_type > inputMatrix_
The input matrix to the constructor.
Definition Ifpack2_Container_decl.hpp:250
bool pointIndexed_
(If hasBlockCrs_) Whether the blocks are described using sub-block row indices instead of full block ...
Definition Ifpack2_Container_decl.hpp:281
GO NumGlobalRows_
Number of global rows in input matrix.
Definition Ifpack2_Container_decl.hpp:273
bool isComputed() const
Whether the container has been successfully computed.
Definition Ifpack2_Container_def.hpp:137
typename mv_type::dual_view_type::t_host HostView
Definition Ifpack2_Container_decl.hpp:106
Ifpack2's implementation of Trilinos::Details::LinearSolver interface.
Definition Ifpack2_Details_LinearSolver_decl.hpp:77
Ifpack2 implementation details.
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:41
Structure for read-only views of general matrix rows.
Definition Ifpack2_Container_decl.hpp:504
StridedRowView(h_vals_type vals_, h_inds_type inds_, int blockSize_, size_t nnz_)
Constructor for row views (preferred)
Definition Ifpack2_Container_def.hpp:926