43 #ifndef IFPACK2_CONTAINER_DEF_HPP 44 #define IFPACK2_CONTAINER_DEF_HPP 47 #include <Teuchos_Time.hpp> 53 template<
class MatrixType>
55 const Teuchos::RCP<const row_matrix_type>& matrix,
56 const Teuchos::Array<Teuchos::Array<LO> >& partitions,
58 inputMatrix_ (matrix),
59 inputCrsMatrix_ (
Teuchos::rcp_dynamic_cast<const crs_matrix_type>(inputMatrix_)),
60 inputBlockMatrix_ (
Teuchos::rcp_dynamic_cast<const block_crs_matrix_type>(inputMatrix_)),
61 pointIndexed_(pointIndexed),
62 IsInitialized_(false),
68 using Teuchos::ArrayView;
85 #ifdef HAVE_IFPACK2_DEBUG 90 Teuchos::ArrayView<const LO> blockRows =
getBlockRows(i);
93 LO row = blockRows[j];
99 TEUCHOS_TEST_FOR_EXCEPTION(
100 !rowMap.isNodeLocalElement(row),
101 std::invalid_argument,
"Ifpack2::Container: " 102 "On process " << rowMap.getComm()->getRank() <<
" of " 103 << rowMap.getComm()->getSize() <<
", in the given set of local row " 104 "indices blockRows = " << Teuchos::toString(blockRows) <<
", the following " 105 "entries is not valid local row index on the calling process: " 112 template<
class MatrixType>
116 template<
class MatrixType>
117 Teuchos::ArrayView<const typename MatrixType::local_ordinal_type>
120 return Teuchos::ArrayView<const LO>
121 (&blockRows_[blockOffsets_[blockIndex]], blockSizes_[blockIndex]);
124 template<
class MatrixType>
129 LO totalBlockRows = 0;
130 numBlocks_ = partitions.size();
131 blockSizes_.resize(numBlocks_);
132 blockOffsets_.resize(numBlocks_);
134 for(
int i = 0; i < numBlocks_; i++)
136 LO rowsInBlock = partitions[i].size();
137 blockSizes_[i] = rowsInBlock;
138 blockOffsets_[i] = totalBlockRows;
139 totalBlockRows += rowsInBlock;
140 maxBlockSize_ = std::max(maxBlockSize_, rowsInBlock * scalarsPerRow_);
142 blockRows_.resize(totalBlockRows);
145 for(
int i = 0; i < numBlocks_; i++)
147 for(
int j = 0; j < blockSizes_[i]; j++)
149 blockRows_[iter++] = partitions[i][j];
154 template<
class MatrixType>
159 Diag_ = rcp(
new vector_type(inputMatrix_->getDomainMap()));
160 inputMatrix_->getLocalDiagCopy(*Diag_);
164 template<
class MatrixType>
166 return IsInitialized_;
169 template<
class MatrixType>
174 template<
class MatrixType>
178 TEUCHOS_TEST_FOR_EXCEPT_MSG(
true,
"Not implemented.");
181 template<
class MatrixType>
185 TEUCHOS_TEST_FOR_EXCEPT_MSG(
true,
"Not implemented.");
188 template<
class MatrixType>
195 template<
class MatrixType>
197 SC dampingFactor, LO i)
const 199 TEUCHOS_TEST_FOR_EXCEPT_MSG(
true,
"Not implemented.");
202 template <
class MatrixType>
205 using STS = Teuchos::ScalarTraits<ISC>;
206 const ISC one = STS::one();
208 size_t numVecs = X.extent(1);
210 for (LO i = 0; i < numBlocks_; i++)
213 if(blockSizes_[i] != 1 || hasBlockCrs_)
215 if(blockSizes_[i] == 0 )
217 apply(X, Y, i, Teuchos::NO_TRANS, dampingFactor, one);
221 LO LRID = blockRows_[blockOffsets_[i]];
223 auto diagView = Diag_->getLocalViewHost(Tpetra::Access::ReadOnly);
224 ISC d = one / diagView(LRID, 0);
225 for(
size_t nv = 0; nv < numVecs; nv++)
234 template <
class MatrixType>
235 void Container<MatrixType>::DoOverlappingJacobi(ConstHostView X, HostView Y, ConstHostView W, SC dampingFactor)
const 237 using STS = Teuchos::ScalarTraits<SC>;
239 for(LO i = 0; i < numBlocks_; i++)
242 if(blockSizes_[i] == 0)
244 if(blockSizes_[i] != 1)
245 weightedApply(X, Y, W, i, Teuchos::NO_TRANS, dampingFactor, STS::one());
251 template<
class MatrixType,
typename LocalScalarType>
254 SC dampingFactor, LO i)
const 256 using Teuchos::ArrayView;
257 using STS = Teuchos::ScalarTraits<ISC>;
258 size_t numVecs = X.extent(1);
259 const ISC one = STS::one();
260 if(this->blockSizes_[i] == 0)
262 if(this->hasBlockCrs_ && !this->pointIndexed_)
265 ArrayView<const LO> blockRows = this->getBlockRows(i);
266 const size_t localNumRows = this->blockSizes_[i];
267 using inds_type =
typename block_crs_matrix_type::local_inds_host_view_type;
268 using vals_type =
typename block_crs_matrix_type::values_host_view_type;
269 for(
size_t j = 0; j < localNumRows; j++)
271 LO row = blockRows[j];
274 this->inputBlockMatrix_->getLocalRowView(row, colinds, values);
275 LO numEntries = (LO) colinds.size();
276 for(
size_t m = 0; m < numVecs; m++)
278 for (
int localR = 0; localR < this->bcrsBlockSize_; localR++)
279 Resid(row * this->bcrsBlockSize_ + localR, m) = X(row * this->bcrsBlockSize_ + localR, m);
280 for (LO k = 0; k < numEntries; ++k)
282 const LO col = colinds[k];
283 for(
int localR = 0; localR < this->bcrsBlockSize_; localR++)
285 for(
int localC = 0; localC < this->bcrsBlockSize_; localC++)
287 Resid(row * this->bcrsBlockSize_ + localR, m) -=
288 values[k * this->bcrsBlockSize_ * this->bcrsBlockSize_ + localR + localC * this->bcrsBlockSize_]
289 * Y2(col * this->bcrsBlockSize_ + localC, m); }
300 apply(Resid, Y2, i, Teuchos::NO_TRANS, dampingFactor, one);
302 else if(!this->hasBlockCrs_ && this->blockSizes_[i] == 1)
306 LO LRID = this->blockOffsets_[i];
307 ConstHostView diagView = this->Diag_->getLocalViewHost(Tpetra::Access::ReadOnly);
308 ISC d = one / diagView(LRID, 0);
309 for(
size_t m = 0; m < numVecs; m++)
316 else if(!this->inputCrsMatrix_.is_null() &&
317 std::is_same<typename crs_matrix_type::device_type::memory_space, Kokkos::HostSpace>::value)
322 container_exec_space().fence();
323 auto localA = this->inputCrsMatrix_->getLocalMatrixHost();
324 using size_type =
typename crs_matrix_type::local_matrix_host_type::size_type;
325 const auto& rowmap = localA.graph.row_map;
326 const auto& entries = localA.graph.entries;
327 const auto& values = localA.values;
328 ArrayView<const LO> blockRows = this->getBlockRows(i);
329 for(
size_t j = 0; j < size_t(blockRows.size()); j++)
331 const LO row = blockRows[j];
332 for(
size_t m = 0; m < numVecs; m++)
335 for(size_type k = rowmap(row); k < rowmap(row + 1); k++)
337 const LO col = entries(k);
338 r -= values(k) * Y2(col, m);
349 apply(Resid, Y2, i, Teuchos::NO_TRANS, dampingFactor, one);
355 ArrayView<const LO> blockRows = this->getBlockRows(i);
356 for(
size_t j = 0; j < size_t(blockRows.size()); j++)
358 const LO row = blockRows[j];
359 auto rowView = getInputRowView(row);
360 for(
size_t m = 0; m < numVecs; m++)
362 Resid(row, m) = X(row, m);
363 for (
size_t k = 0; k < rowView.size(); ++k)
365 const LO col = rowView.ind(k);
366 Resid(row, m) -= rowView.val(k) * Y2(col, m);
376 apply(Resid, Y2, i, Teuchos::NO_TRANS, dampingFactor, one);
380 template<
class MatrixType>
382 DoGaussSeidel(ConstHostView X, HostView Y, HostView Y2, SC dampingFactor)
const 384 using Teuchos::Array;
385 using Teuchos::ArrayRCP;
386 using Teuchos::ArrayView;
390 using Teuchos::rcpFromRef;
393 auto numVecs = X.extent(1);
395 HostView Resid(
"", X.extent(0), X.extent(1));
396 for(LO i = 0; i < numBlocks_; i++)
398 DoGSBlock(X, Y, Y2, Resid, dampingFactor, i);
402 auto numMyRows = inputMatrix_->getNodeNumRows();
403 for (
size_t m = 0; m < numVecs; ++m)
405 for (
size_t i = 0; i < numMyRows * bcrsBlockSize_; ++i)
413 template<
class MatrixType>
414 void Container<MatrixType>::
415 DoSGS(ConstHostView X, HostView Y, HostView Y2, SC dampingFactor)
const 418 using Teuchos::Array;
419 using Teuchos::ArrayRCP;
420 using Teuchos::ArrayView;
425 using Teuchos::rcpFromRef;
426 auto numVecs = X.extent(1);
427 HostView Resid(
"", X.extent(0), X.extent(1));
429 for(LO i = 0; i < numBlocks_; i++)
431 DoGSBlock(X, Y, Y2, Resid, dampingFactor, i);
433 static_assert(std::is_signed<LO>::value,
434 "Local ordinal must be signed (unsigned breaks reverse iteration to 0)");
436 for(LO i = numBlocks_ - 1; i >= 0; --i)
438 DoGSBlock(X, Y, Y2, Resid, dampingFactor, i);
442 auto numMyRows = inputMatrix_->getNodeNumRows();
443 for (
size_t m = 0; m < numVecs; ++m)
445 for (
size_t i = 0; i < numMyRows * bcrsBlockSize_; ++i)
453 template<
class MatrixType>
454 void Container<MatrixType>::
460 blockOffsets_.clear();
461 Diag_ = Teuchos::null;
466 template<
class MatrixType,
class LocalScalarType>
467 ContainerImpl<MatrixType, LocalScalarType>::
469 const Teuchos::RCP<const row_matrix_type>& matrix,
470 const Teuchos::Array<Teuchos::Array<LO> >& partitions,
472 : Container<MatrixType>(matrix, partitions, pointIndexed) {}
474 template<
class MatrixType,
class LocalScalarType>
475 ContainerImpl<MatrixType, LocalScalarType>::
478 template<
class MatrixType,
class LocalScalarType>
482 template<
class MatrixType,
class LocalScalarType>
489 TEUCHOS_TEST_FOR_EXCEPT_MSG(
true,
"Not implemented.");
492 template<
class MatrixType,
class LocalScalarType>
496 ConstHostView XView = X.getLocalViewHost(Tpetra::Access::ReadOnly);
497 HostView YView = Y.getLocalViewHost(Tpetra::Access::ReadWrite);
498 this->apply (XView, YView, 0);
501 template<
class MatrixType,
class LocalScalarType>
505 vector_type& W)
const 507 ConstHostView XView = X.getLocalViewHost(Tpetra::Access::ReadOnly);
508 HostView YView = Y.getLocalViewHost(Tpetra::Access::ReadWrite);
509 ConstHostView WView = W.getLocalViewHost(Tpetra::Access::ReadOnly);
510 weightedApply (XView, YView, WView, 0);
513 template<
class MatrixType,
class LocalScalarType>
520 template<
class MatrixType,
class LocalScalarType>
525 Teuchos::ETransp mode,
527 const LSC beta)
const 529 TEUCHOS_TEST_FOR_EXCEPT_MSG(
true,
"Not implemented.");
532 template<
class MatrixType,
class LocalScalarType>
533 typename ContainerImpl<MatrixType, LocalScalarType>::LO
537 LO LO_INVALID = Teuchos::OrdinalTraits<LO>::invalid();
538 GO GO_INVALID = Teuchos::OrdinalTraits<GO>::invalid();
539 const map_type& globalRowMap = *(this->inputMatrix_->getRowMap());
540 const map_type& globalColMap = *(this->inputMatrix_->getColMap());
543 if(this->pointIndexed_)
545 rowLID = row / this->bcrsBlockSize_;
546 dofOffset = row % this->bcrsBlockSize_;
548 GO diagGID = globalRowMap.getGlobalElement(rowLID);
549 TEUCHOS_TEST_FOR_EXCEPTION(
550 diagGID == GO_INVALID,
551 std::runtime_error,
"Ifpack2::Container::translateRowToCol: " 552 "On process " << this->inputMatrix_->getRowMap()->getComm()->getRank() <<
553 ", at least one row index in the set of local " 554 "row indices given to the constructor is not a valid local row index in " 555 "the input matrix's row Map on this process. This should be impossible " 556 "because the constructor checks for this case. Here is the complete set " 557 "of invalid local row indices: " << rowLID <<
". " 558 "Please report this bug to the Ifpack2 developers.");
560 LO colLID = globalColMap.getLocalElement(diagGID);
561 TEUCHOS_TEST_FOR_EXCEPTION(
562 colLID == LO_INVALID,
563 std::runtime_error,
"Ifpack2::Container::translateRowToCol: " 564 "On process " << this->inputMatrix_->getRowMap()->getComm()->getRank() <<
", " 565 "at least one row index in the set of row indices given to the constructor " 566 "does not have a corresponding column index in the input matrix's column " 567 "Map. This probably means that the column(s) in question is/are empty on " 568 "this process, which would make the submatrix to extract structurally " 569 "singular. The invalid global column index is " << diagGID <<
".");
571 if(this->pointIndexed_)
572 return colLID * this->bcrsBlockSize_ + dofOffset;
576 template<
class MatrixType,
class LocalScalarType>
581 Teuchos::ETransp mode,
585 using Teuchos::ArrayView;
598 TEUCHOS_TEST_FOR_EXCEPTION(
599 ! this->IsComputed_, std::runtime_error,
"Ifpack2::Container::apply: " 600 "You must have called the compute() method before you may call apply(). " 601 "You may call the apply() method as many times as you want after calling " 602 "compute() once, but you must have called compute() at least once.");
604 const size_t numVecs = X.extent(1);
635 if(X_localBlocks_.size() == 0 || X.extent(1) != X_local_.extent(1))
638 X_localBlocks_.clear();
639 Y_localBlocks_.clear();
640 X_localBlocks_.reserve(this->numBlocks_);
641 Y_localBlocks_.reserve(this->numBlocks_);
643 X_local_ = HostViewLocal(
"X_local", this->blockRows_.size() * this->scalarsPerRow_, numVecs);
644 Y_local_ = HostViewLocal(
"Y_local", this->blockRows_.size() * this->scalarsPerRow_, numVecs);
648 for(
int i = 0; i < this->numBlocks_; i++)
650 auto blockBounds = std::make_pair(this->blockOffsets_[i] * this->scalarsPerRow_,
651 (this->blockOffsets_[i] + this->blockSizes_[i]) * this->scalarsPerRow_);
652 X_localBlocks_.emplace_back(X_local_, blockBounds, Kokkos::ALL());
653 Y_localBlocks_.emplace_back(Y_local_, blockBounds, Kokkos::ALL());
657 const ArrayView<const LO> blockRows = this->getBlockRows(blockIndex);
659 if(this->scalarsPerRow_ == 1)
660 mvgs.gatherViewToView (X_localBlocks_[blockIndex], X, blockRows);
662 mvgs.gatherViewToViewBlock (X_localBlocks_[blockIndex], X, blockRows, this->scalarsPerRow_);
669 if(this->scalarsPerRow_ == 1)
670 mvgs.gatherViewToView (Y_localBlocks_[blockIndex], Y, blockRows);
672 mvgs.gatherViewToViewBlock (Y_localBlocks_[blockIndex], Y, blockRows, this->scalarsPerRow_);
676 this->solveBlock (X_localBlocks_[blockIndex], Y_localBlocks_[blockIndex], blockIndex, mode,
681 if(this->scalarsPerRow_ == 1)
682 mvgs.scatterViewToView (Y, Y_localBlocks_[blockIndex], blockRows);
684 mvgs.scatterViewToViewBlock (Y, Y_localBlocks_[blockIndex], blockRows, this->scalarsPerRow_);
687 template<
class MatrixType,
class LocalScalarType>
693 Teuchos::ETransp mode,
697 using Teuchos::ArrayRCP;
698 using Teuchos::ArrayView;
699 using Teuchos::Range1D;
704 using Teuchos::rcp_const_cast;
706 using STS = Teuchos::ScalarTraits<SC>;
715 const char prefix[] =
"Ifpack2::Container::weightedApply: ";
716 TEUCHOS_TEST_FOR_EXCEPTION(
717 ! this->IsComputed_, std::runtime_error, prefix <<
"You must have called the " 718 "compute() method before you may call this method. You may call " 719 "weightedApply() as many times as you want after calling compute() once, " 720 "but you must have called compute() at least once first.");
723 TEUCHOS_TEST_FOR_EXCEPTION(
724 this->scalarsPerRow_ > 1, std::logic_error, prefix <<
"Use of block rows isn't allowed " 725 "in overlapping Jacobi (the only method that uses weightedApply");
727 const size_t numVecs = X.extent(1);
729 TEUCHOS_TEST_FOR_EXCEPTION(
730 X.extent(1) != Y.extent(1), std::runtime_error,
731 prefix <<
"X and Y have different numbers of vectors (columns). X has " 732 << X.extent(1) <<
", but Y has " << Y.extent(1) <<
".");
738 const size_t numRows = this->blockSizes_[blockIndex];
763 if(X_localBlocks_.size() == 0 || X.extent(1) != X_local_.extent(1))
766 X_localBlocks_.clear();
767 Y_localBlocks_.clear();
768 X_localBlocks_.reserve(this->numBlocks_);
769 Y_localBlocks_.reserve(this->numBlocks_);
771 X_local_ = HostViewLocal(
"X_local", this->blockRows_.size() * this->scalarsPerRow_, numVecs);
772 Y_local_ = HostViewLocal(
"Y_local", this->blockRows_.size() * this->scalarsPerRow_, numVecs);
776 for(
int i = 0; i < this->numBlocks_; i++)
778 auto blockBounds = std::make_pair(this->blockOffsets_[i] * this->scalarsPerRow_,
779 (this->blockOffsets_[i] + this->blockSizes_[i]) * this->scalarsPerRow_);
780 X_localBlocks_.emplace_back(X_local_, blockBounds, Kokkos::ALL());
781 Y_localBlocks_.emplace_back(Y_local_, blockBounds, Kokkos::ALL());
784 if(
int(weightedApplyScratch_.extent(0)) != 3 * this->maxBlockSize_ ||
785 weightedApplyScratch_.extent(1) != numVecs)
787 weightedApplyScratch_ = HostViewLocal(
"weightedApply scratch", 3 * this->maxBlockSize_, numVecs);
790 ArrayView<const LO> blockRows = this->getBlockRows(blockIndex);
795 mvgs.gatherViewToView (X_localBlocks_[blockIndex], X, blockRows);
801 mvgs.gatherViewToView (Y_localBlocks_[blockIndex], Y, blockRows);
812 auto maxBS = this->maxBlockSize_;
813 auto bs = this->blockSizes_[blockIndex] * this->scalarsPerRow_;
815 HostSubviewLocal D_local(weightedApplyScratch_, std::make_pair(0, bs), std::make_pair(0, 1));
816 mvgs.gatherViewToView (D_local, D, blockRows);
817 HostSubviewLocal X_scaled(weightedApplyScratch_, std::make_pair(maxBS, maxBS + bs), Kokkos::ALL());
818 for(
size_t j = 0; j < numVecs; j++)
819 for(
size_t i = 0; i < numRows; i++)
820 X_scaled(i, j) = X_localBlocks_[blockIndex](i, j) * D_local(i, 0);
822 HostSubviewLocal Y_temp(weightedApplyScratch_, std::make_pair(maxBS * 2, maxBS * 2 + bs), Kokkos::ALL());
824 this->solveBlock (X_scaled, Y_temp, blockIndex, mode, STS::one(), STS::zero());
832 for(
size_t j = 0; j < numVecs; j++)
833 for(
size_t i = 0; i < numRows; i++)
834 Y_localBlocks_[blockIndex](i, j) = b * Y_localBlocks_[blockIndex](i, j) + a * Y_temp(i, j) * D_local(i, 0);
838 mvgs.scatterViewToView (Y, Y_localBlocks_[blockIndex], blockRows);
841 template<
class MatrixType,
class LocalScalarType>
843 typename ContainerImpl<MatrixType, LocalScalarType>::SC,
844 typename ContainerImpl<MatrixType, LocalScalarType>::LO,
845 typename ContainerImpl<MatrixType, LocalScalarType>::GO,
846 typename ContainerImpl<MatrixType, LocalScalarType>::NO>
851 typedef typename MatrixType::nonconst_local_inds_host_view_type nonconst_local_inds_host_view_type;
852 typedef typename MatrixType::nonconst_values_host_view_type nonconst_values_host_view_type;
854 typedef typename MatrixType::local_inds_host_view_type local_inds_host_view_type;
855 typedef typename MatrixType::values_host_view_type values_host_view_type;
856 using IST =
typename row_matrix_type::impl_scalar_type;
858 if(this->hasBlockCrs_)
860 using h_inds_type =
typename block_crs_matrix_type::local_inds_host_view_type;
861 using h_vals_type =
typename block_crs_matrix_type::values_host_view_type;
864 this->inputBlockMatrix_->getLocalRowView(row / this->bcrsBlockSize_, colinds, values);
865 size_t numEntries = colinds.size();
868 h_vals_type subvals = Kokkos::subview(values,std::pair<size_t,size_t>(row % this->bcrsBlockSize_,values.size()));
869 return StridedRowView(subvals, colinds, this->bcrsBlockSize_, numEntries * this->bcrsBlockSize_);
871 else if(!this->inputMatrix_->supportsRowViews())
873 size_t maxEntries = this->inputMatrix_->getNodeMaxNumRowEntries();
874 Teuchos::Array<LO> inds(maxEntries);
875 Teuchos::Array<SC> vals(maxEntries);
876 nonconst_local_inds_host_view_type inds_v(inds.data(),maxEntries);
877 nonconst_values_host_view_type vals_v(reinterpret_cast<IST*>(vals.data()),maxEntries);
879 this->inputMatrix_->getLocalRowCopy(row, inds_v, vals_v, numEntries);
880 vals.resize(numEntries); inds.resize(numEntries);
886 local_inds_host_view_type colinds;
887 values_host_view_type values;
888 this->inputMatrix_->getLocalRowView(row, colinds, values);
893 template<
class MatrixType,
class LocalScalarType>
897 X_localBlocks_.clear();
898 Y_localBlocks_.clear();
899 X_local_ = HostViewLocal();
900 Y_local_ = HostViewLocal();
907 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
908 StridedRowView<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
909 StridedRowView(h_vals_type vals_, h_inds_type inds_,
int blockSize_,
size_t nnz_)
910 : vals(vals_), inds(inds_), blockSize(blockSize_), nnz(nnz_)
913 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
916 : vals(), inds(), blockSize(1), nnz(vals_.size())
918 valsCopy.swap(vals_);
919 indsCopy.swap(inds_);
922 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
926 #ifdef HAVE_IFPACK2_DEBUG 927 TEUCHOS_TEST_FOR_EXCEPTION(i >= nnz, std::runtime_error,
928 "Out-of-bounds access into Ifpack2::Container::StridedRowView");
935 return vals[i * blockSize];
941 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
942 LocalOrdinal StridedRowView<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
945 #ifdef HAVE_IFPACK2_DEBUG 946 TEUCHOS_TEST_FOR_EXCEPTION(i >= nnz, std::runtime_error,
947 "Out-of-bounds access into Ifpack2::Container::StridedRowView");
955 return inds[i / blockSize] * blockSize + i % blockSize;
961 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
962 size_t StridedRowView<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
971 template <
class MatrixType>
972 std::ostream& operator<<(std::ostream& os, const Ifpack2::Container<MatrixType>& obj)
974 return obj.print(os);
977 #define IFPACK2_CONTAINER_INSTANT(S,LO,GO,N) \ 978 template class Ifpack2::Container<Tpetra::RowMatrix<S, LO, GO, N>>; \ 979 template class Ifpack2::ContainerImpl<Tpetra::RowMatrix<S, LO, GO, N>, S>; \ 980 template class Ifpack2::Details::StridedRowView<S, LO, GO, N>; \ 981 template std::ostream& operator<< <Tpetra::RowMatrix<S, LO, GO, N>>( \ 982 std::ostream& os, const Ifpack2::Container<Tpetra::RowMatrix<S, LO, GO, N>>& obj); void setBlockSizes(const Teuchos::Array< Teuchos::Array< LO > > &partitions)
Initialize arrays with information about block sizes.
Definition: Ifpack2_Container_def.hpp:125
Teuchos::Array< LO > blockSizes_
Number of rows in each block.
Definition: Ifpack2_Container_decl.hpp:296
StridedRowView(h_vals_type vals_, h_inds_type inds_, int blockSize_, size_t nnz_)
Constructor for row views (preferred)
Definition: Ifpack2_Container_def.hpp:909
bool pointIndexed_
(If hasBlockCrs_) Whether the blocks are described using sub-block row indices instead of full block ...
Definition: Ifpack2_Container_decl.hpp:314
int numBlocks_
The number of blocks (partitions) in the container.
Definition: Ifpack2_Container_decl.hpp:292
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:118
The implementation of the numerical features of Container (Jacobi, Gauss-Seidel, SGS). This class allows a custom scalar type (LocalScalarType) to be used for storing blocks and solving the block systems. Hiding this template parameter from the Container interface simplifies the BlockRelaxation and ContainerFactory classes.
Definition: Ifpack2_Container_decl.hpp:343
LO scalarsPerRow_
Definition: Ifpack2_Container_decl.hpp:317
virtual ~Container()
Destructor.
Definition: Ifpack2_Container_def.hpp:114
bool hasBlockCrs_
Whether the input matrix is a BlockCRS matrix.
Definition: Ifpack2_Container_decl.hpp:310
InverseType::scalar_type LSC
The internal representation of LocalScalarType in Kokkos::View.
Definition: Ifpack2_Container_decl.hpp:363
Ifpack2 implementation details.
bool isInitialized() const
Whether the container has been successfully initialized.
Definition: Ifpack2_Container_def.hpp:165
Declaration and definition of the Ifpack2::Details::MultiVectorLocalGatherScatter class...
typename Kokkos::Details::ArithTraits< SC >::val_type ISC
Internal representation of Scalar in Kokkos::View.
Definition: Ifpack2_Container_decl.hpp:135
Container(const Teuchos::RCP< const row_matrix_type > &matrix, const Teuchos::Array< Teuchos::Array< LO > > &partitions, bool pointIndexed)
Constructor.
Definition: Ifpack2_Container_def.hpp:54
int bcrsBlockSize_
If hasBlockCrs_, the number of DOFs per vertex. Otherwise 1.
Definition: Ifpack2_Container_decl.hpp:312
Teuchos::RCP< const block_crs_matrix_type > inputBlockMatrix_
The input matrix, dynamic cast to BlockCrsMatrix. May be null.
Definition: Ifpack2_Container_decl.hpp:289
Teuchos::RCP< const row_matrix_type > inputMatrix_
The input matrix to the constructor.
Definition: Ifpack2_Container_decl.hpp:283
typename mv_type::dual_view_type::t_host HostView
Definition: Ifpack2_Container_decl.hpp:139
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:252
bool isComputed() const
Whether the container has been successfully computed.
Definition: Ifpack2_Container_def.hpp:170
bool IsParallel_
Whether the problem is distributed across multiple MPI processes.
Definition: Ifpack2_Container_decl.hpp:302
virtual void weightedApplyMV(const mv_type &X, mv_type &Y, vector_type &W) const
Wrapper for weightedApply with MultiVector.
Definition: Ifpack2_Container_def.hpp:183
Definition: Ifpack2_Container_decl.hpp:576
Interface for creating and solving a set of local linear problems.
Definition: Ifpack2_Container_decl.hpp:112
virtual void applyMV(const mv_type &X, mv_type &Y) const
Wrapper for apply with MultiVector.
Definition: Ifpack2_Container_def.hpp:176
Structure for read-only views of general matrix rows.
Definition: Ifpack2_Container_decl.hpp:330
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:196
static std::string getName()
Definition: Ifpack2_Container_def.hpp:190
GO NumGlobalRows_
Number of global rows in input matrix.
Definition: Ifpack2_Container_decl.hpp:306
Preconditioners and smoothers for Tpetra sparse matrices.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:73
GO NumGlobalNonzeros_
Number of nonzeros in input matrix.
Definition: Ifpack2_Container_decl.hpp:308
LO NumLocalRows_
Number of local rows in input matrix.
Definition: Ifpack2_Container_decl.hpp:304
Implementation detail of Ifpack2::Container subclasses.
Definition: Ifpack2_Details_MultiVectorLocalGatherScatter.hpp:85