10 #ifndef IFPACK2_CONTAINER_DEF_HPP
11 #define IFPACK2_CONTAINER_DEF_HPP
20 template<
class MatrixType>
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),
52 #ifdef HAVE_IFPACK2_DEBUG
60 LO row = blockRows[j];
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 "
72 "entries is not valid local row index on the calling process: "
79 template<
class MatrixType>
83 template<
class MatrixType>
88 (&blockRows_[blockOffsets_[blockIndex]], blockSizes_[blockIndex]);
91 template<
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];
121 template<
class MatrixType>
126 Diag_ =
rcp(
new vector_type(inputMatrix_->getDomainMap()));
127 inputMatrix_->getLocalDiagCopy(*Diag_);
131 template<
class MatrixType>
133 return IsInitialized_;
136 template<
class MatrixType>
141 template<
class MatrixType>
148 template<
class MatrixType>
155 template<
class MatrixType>
162 template<
class MatrixType>
164 SC dampingFactor, LO i)
const
169 template <
class MatrixType>
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 )
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;
201 template <
class MatrixType>
202 void Container<MatrixType>::DoOverlappingJacobi(ConstHostView X, HostView Y, ConstHostView W, SC dampingFactor,
bool nonsymScaling)
const
206 for(LO i = 0; i < numBlocks_; i++)
209 if(blockSizes_[i] == 0)
211 if(blockSizes_[i] != 1) {
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);
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);
252 template<
class MatrixType,
typename LocalScalarType>
255 SC dampingFactor, LO i)
const
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); }
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);
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);
397 template<
class MatrixType>
399 DoGaussSeidel(ConstHostView X, HostView Y, HostView Y2, SC dampingFactor)
const
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)
430 template<
class MatrixType>
431 void Container<MatrixType>::
432 DoSGS(ConstHostView X, HostView Y, HostView Y2, SC dampingFactor)
const
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)
470 template<
class MatrixType>
471 void Container<MatrixType>::
477 blockOffsets_.clear();
478 Diag_ = Teuchos::null;
483 template<
class MatrixType,
class LocalScalarType>
484 ContainerImpl<MatrixType, LocalScalarType>::
489 : Container<MatrixType>(matrix, partitions, pointIndexed) {}
491 template<
class MatrixType,
class LocalScalarType>
495 template<
class MatrixType,
class LocalScalarType>
499 template<
class MatrixType,
class LocalScalarType>
509 template<
class MatrixType,
class LocalScalarType>
513 ConstHostView XView = X.getLocalViewHost(Tpetra::Access::ReadOnly);
514 HostView YView = Y.getLocalViewHost(Tpetra::Access::ReadWrite);
515 this->apply (XView, YView, 0);
518 template<
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);
530 template<
class MatrixType,
class LocalScalarType>
537 template<
class MatrixType,
class LocalScalarType>
544 const LSC beta)
const
549 template<
class MatrixType,
class LocalScalarType>
550 typename ContainerImpl<MatrixType, LocalScalarType>::LO
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);
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);
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;
593 template<
class MatrixType,
class LocalScalarType>
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_);
704 template<
class MatrixType,
class LocalScalarType>
721 using Teuchos::rcp_const_cast;
732 const char prefix[] =
"Ifpack2::Container::weightedApply: ";
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.");
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);
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);
858 template<
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();
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);
903 local_inds_host_view_type colinds;
904 values_host_view_type values;
905 this->inputMatrix_->getLocalRowView(row, colinds, values);
910 template<
class MatrixType,
class LocalScalarType>
914 X_localBlocks_.clear();
915 Y_localBlocks_.clear();
916 X_local_ = HostViewLocal();
917 Y_local_ = HostViewLocal();
924 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
926 StridedRowView(h_vals_type vals_, h_inds_type inds_,
int blockSize_,
size_t nnz_)
927 : vals(vals_), inds(inds_), blockSize(blockSize_), nnz(nnz_)
930 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
933 : vals(), inds(), blockSize(1), nnz(vals_.size())
935 valsCopy.
swap(vals_);
936 indsCopy.
swap(inds_);
939 template<
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];
958 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
959 LocalOrdinal StridedRowView<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
962 #ifdef HAVE_IFPACK2_DEBUG
964 "Out-of-bounds access into Ifpack2::Container::StridedRowView");
972 return inds[i / blockSize] * blockSize + i % blockSize;
978 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
979 size_t StridedRowView<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
988 template <
class MatrixType>
989 std::ostream& operator<<(std::ostream& os, const Ifpack2::Container<MatrixType>& obj)
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);
virtual void apply(ConstHostView X, HostView Y, int blockIndex, Teuchos::ETransp mode=Teuchos::NO_TRANS, SC alpha=Teuchos::ScalarTraits< SC >::one(), SC beta=Teuchos::ScalarTraits< SC >::zero()) const
Compute Y := alpha * M^{-1} X + beta*Y.
Definition: Ifpack2_Container_def.hpp:595
void weightedApplyMV(const mv_type &X, mv_type &Y, vector_type &W) const
Wrapper for weightedApply with MVs, used in unit tests (never called by BlockRelaxation) ...
Definition: Ifpack2_Container_def.hpp:520
bool isComputed() const
Whether the container has been successfully computed.
Definition: Ifpack2_Container_def.hpp:137
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
void setBlockSizes(const Teuchos::Array< Teuchos::Array< LO > > &partitions)
Initialize arrays with information about block sizes.
Definition: Ifpack2_Container_def.hpp:92
Teuchos::Array< LO > blockSizes_
Number of rows in each block.
Definition: Ifpack2_Container_decl.hpp:263
typename Kokkos::ArithTraits< SC >::val_type ISC
Internal representation of Scalar in Kokkos::View.
Definition: Ifpack2_Container_decl.hpp:102
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
virtual void applyMV(const mv_type &X, mv_type &Y) const
Wrapper for apply with MultiVector.
Definition: Ifpack2_Container_def.hpp:143
bool pointIndexed_
(If hasBlockCrs_) Whether the blocks are described using sub-block row indices instead of full block ...
Definition: Ifpack2_Container_decl.hpp:281
int numBlocks_
The number of blocks (partitions) in the container.
Definition: Ifpack2_Container_decl.hpp:259
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:310
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
virtual void setParameters(const Teuchos::ParameterList &List)
Set parameters, if any.
Definition: Ifpack2_Container_def.hpp:497
bool isInitialized() const
Whether the container has been successfully initialized.
Definition: Ifpack2_Container_def.hpp:132
LO scalarsPerRow_
Definition: Ifpack2_Container_decl.hpp:284
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
Details::StridedRowView< SC, LO, GO, NO > getInputRowView(LO row) const
View a row of the input matrix.
Definition: Ifpack2_Container_def.hpp:865
LocalScalarType LSC
The internal representation of LocalScalarType in Kokkos::View.
Definition: Ifpack2_Container_decl.hpp:330
Declaration and definition of the Ifpack2::Details::MultiVectorLocalGatherScatter class...
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
int bcrsBlockSize_
If hasBlockCrs_, the number of DOFs per vertex. Otherwise 1.
Definition: Ifpack2_Container_decl.hpp:279
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
#define TEUCHOS_TEST_FOR_EXCEPT_MSG(throw_exception_test, msg)
LO translateRowToCol(LO row)
Definition: Ifpack2_Container_def.hpp:552
Teuchos::RCP< const block_crs_matrix_type > inputBlockMatrix_
The input matrix, dynamic cast to BlockCrsMatrix. May be null.
Definition: Ifpack2_Container_decl.hpp:256
Teuchos::RCP< const row_matrix_type > inputMatrix_
The input matrix to the constructor.
Definition: Ifpack2_Container_decl.hpp:250
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
void applyMV(const mv_type &X, mv_type &Y) const
Wrapper for apply with MVs, used in unit tests (never called by BlockRelaxation)
Definition: Ifpack2_Container_def.hpp:511
virtual void applyInverseJacobi(const mv_type &, mv_type &, SC dampingFactor, bool, int) const
Compute Y := (1 - a) Y + a D^{-1} (X - R*Y).
Definition: Ifpack2_Container_def.hpp:501
typename mv_type::dual_view_type::t_host HostView
Definition: Ifpack2_Container_decl.hpp:106
virtual void weightedApply(ConstHostView X, HostView Y, ConstHostView D, int blockIndex, Teuchos::ETransp mode=Teuchos::NO_TRANS, SC alpha=Teuchos::ScalarTraits< SC >::one(), SC beta=Teuchos::ScalarTraits< SC >::zero()) const
Compute Y := alpha * diag(D) * M^{-1} (diag(D) * X) + beta*Y.
Definition: Ifpack2_Container_def.hpp:706
void resize(size_type new_size, const value_type &x=value_type())
virtual ~ContainerImpl()
Destructor.
Definition: Ifpack2_Container_def.hpp:493
bool IsParallel_
Whether the problem is distributed across multiple MPI processes.
Definition: Ifpack2_Container_decl.hpp:269
static std::string getName()
Definition: Ifpack2_Container_def.hpp:532
TypeTo as(const TypeFrom &t)
Interface for creating and solving a set of local linear problems.
Definition: Ifpack2_Container_decl.hpp:79
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
Structure for read-only views of general matrix rows.
Definition: Ifpack2_Container_decl.hpp:297
static std::string getName()
Definition: Ifpack2_Container_def.hpp:157
GO NumGlobalRows_
Number of global rows in input matrix.
Definition: Ifpack2_Container_decl.hpp:273
GO NumGlobalNonzeros_
Number of nonzeros in input matrix.
Definition: Ifpack2_Container_decl.hpp:275
LO NumLocalRows_
Number of local rows in input matrix.
Definition: Ifpack2_Container_decl.hpp:271
Implementation detail of Ifpack2::Container subclasses.
Definition: Ifpack2_Details_MultiVectorLocalGatherScatter.hpp:52
virtual void solveBlock(ConstHostSubviewLocal X, HostSubviewLocal Y, int blockIndex, Teuchos::ETransp mode, const LSC alpha, const LSC beta) const
Definition: Ifpack2_Container_def.hpp:539
std::string toString(const T &t)
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