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)
30 , IsComputed_(false) {
51 #ifdef HAVE_IFPACK2_DEBUG
57 LO row = blockRows[j];
63 !rowMap.isNodeLocalElement(row),
64 std::invalid_argument,
65 "Ifpack2::Container: "
67 << rowMap.getComm()->getRank() <<
" of "
68 << rowMap.getComm()->getSize() <<
", in the given set of local row "
69 "indices blockRows = "
71 "entries is not valid local row index on the calling process: "
78 template <
class MatrixType>
82 template <
class MatrixType>
88 template <
class MatrixType>
92 LO totalBlockRows = 0;
93 numBlocks_ = partitions.size();
94 blockSizes_.resize(numBlocks_);
95 blockOffsets_.resize(numBlocks_);
97 for (
int i = 0; i < numBlocks_; i++) {
98 LO rowsInBlock = partitions[i].size();
99 blockSizes_[i] = rowsInBlock;
100 blockOffsets_[i] = totalBlockRows;
101 totalBlockRows += rowsInBlock;
102 maxBlockSize_ = std::max(maxBlockSize_, rowsInBlock * scalarsPerRow_);
104 blockRows_.resize(totalBlockRows);
107 for (
int i = 0; i < numBlocks_; i++) {
108 for (
int j = 0; j < blockSizes_[i]; j++) {
109 blockRows_[iter++] = partitions[i][j];
114 template <
class MatrixType>
116 if (Diag_.is_null()) {
117 Diag_ =
rcp(
new vector_type(inputMatrix_->getDomainMap()));
118 inputMatrix_->getLocalDiagCopy(*Diag_);
122 template <
class MatrixType>
124 return IsInitialized_;
127 template <
class MatrixType>
132 template <
class MatrixType>
138 template <
class MatrixType>
144 template <
class MatrixType>
150 template <
class MatrixType>
152 SC dampingFactor, LO i)
const {
156 template <
class MatrixType>
159 const ISC one = STS::one();
161 size_t numVecs = X.extent(1);
163 for (LO i = 0; i < numBlocks_; i++) {
165 if (blockSizes_[i] != 1 || hasBlockCrs_) {
166 if (blockSizes_[i] == 0)
171 LO LRID = blockRows_[blockOffsets_[i]];
173 auto diagView = Diag_->getLocalViewHost(Tpetra::Access::ReadOnly);
174 ISC d = one * (
static_cast<ISC
>(dampingFactor)) / diagView(LRID, 0);
175 for (
size_t nv = 0; nv < numVecs; nv++) {
177 Y(LRID, nv) += x * d;
183 template <
class MatrixType>
184 void Container<MatrixType>::DoOverlappingJacobi(ConstHostView X, HostView Y, ConstHostView W, SC dampingFactor,
bool nonsymScaling)
const {
187 for (LO i = 0; i < numBlocks_; i++) {
189 if (blockSizes_[i] == 0)
191 if (blockSizes_[i] != 1) {
200 HostView tempo(
"", X.extent(0), X.extent(1));
201 size_t numVecs = X.extent(1);
202 LO bOffset = blockOffsets_[i];
203 for (LO ii = 0; ii < blockSizes_[i]; ii++) {
204 LO LRID = blockRows_[bOffset++];
205 for (
size_t jj = 0; jj < numVecs; jj++) tempo(LRID, jj) = X(LRID, jj) / W(LRID, 0);
211 const ISC one = STS::one();
212 size_t numVecs = X.extent(1);
213 LO LRID = blockRows_[blockOffsets_[i]];
215 auto diagView = Diag_->getLocalViewHost(Tpetra::Access::ReadOnly);
216 ISC recip = one / diagView(LRID, 0);
217 ISC wval = W(LRID, 0);
218 ISC combo = wval * recip;
219 ISC d = combo * (
static_cast<ISC
>(dampingFactor));
220 for (
size_t nv = 0; nv < numVecs; nv++) {
222 Y(LRID, nv) = x * d + Y(LRID, nv);
230 template <
class MatrixType,
typename LocalScalarType>
233 SC dampingFactor, LO i)
const {
236 size_t numVecs = X.extent(1);
237 const ISC one = STS::one();
238 if (this->blockSizes_[i] == 0)
240 if (this->hasBlockCrs_ && !this->pointIndexed_) {
242 ArrayView<const LO> blockRows = this->getBlockRows(i);
243 const size_t localNumRows = this->blockSizes_[i];
244 using inds_type =
typename block_crs_matrix_type::local_inds_host_view_type;
245 using vals_type =
typename block_crs_matrix_type::values_host_view_type;
246 for (
size_t j = 0; j < localNumRows; j++) {
247 LO row = blockRows[j];
250 this->inputBlockMatrix_->getLocalRowView(row, colinds, values);
251 LO numEntries = (LO)colinds.size();
252 for (
size_t m = 0; m < numVecs; m++) {
253 for (
int localR = 0; localR < this->bcrsBlockSize_; localR++)
254 Resid(row * this->bcrsBlockSize_ + localR, m) = X(row * this->bcrsBlockSize_ + localR, m);
255 for (LO k = 0; k < numEntries; ++k) {
256 const LO col = colinds[k];
257 for (
int localR = 0; localR < this->bcrsBlockSize_; localR++) {
258 for (
int localC = 0; localC < this->bcrsBlockSize_; localC++) {
259 Resid(row * this->bcrsBlockSize_ + localR, m) -=
260 values[k * this->bcrsBlockSize_ * this->bcrsBlockSize_ + localR + localC * this->bcrsBlockSize_] * Y2(col * this->bcrsBlockSize_ + localC, m);
273 }
else if (!this->hasBlockCrs_ && this->blockSizes_[i] == 1) {
276 LO LRID = this->blockOffsets_[i];
280 container_exec_space().fence();
281 auto localA = this->inputCrsMatrix_->getLocalMatrixHost();
282 using size_type =
typename crs_matrix_type::local_matrix_host_type::size_type;
283 const auto& rowmap = localA.graph.row_map;
284 const auto& entries = localA.graph.entries;
285 const auto& values = localA.values;
287 auto diagView = this->Diag_->getLocalViewHost(Tpetra::Access::ReadOnly);
288 ISC d = (
static_cast<ISC>(dampingFactor)) / diagView(LRID, 0);
289 for (
size_t m = 0; m < numVecs; m++) {
292 for (size_type k = rowmap(LRID); k < rowmap(LRID + 1); k++) {
293 const LO col = entries(k);
294 r -= values(k) * Y2(col, m);
300 }
else if (!this->inputCrsMatrix_.is_null() &&
301 std::is_same<typename crs_matrix_type::device_type::memory_space, Kokkos::HostSpace>::value) {
305 container_exec_space().fence();
306 auto localA = this->inputCrsMatrix_->getLocalMatrixHost();
307 using size_type =
typename crs_matrix_type::local_matrix_host_type::size_type;
308 const auto& rowmap = localA.graph.row_map;
309 const auto& entries = localA.graph.entries;
310 const auto& values = localA.values;
311 ArrayView<const LO> blockRows = this->getBlockRows(i);
312 for (
size_t j = 0; j < size_t(blockRows.size()); j++) {
313 const LO row = blockRows[j];
314 for (
size_t m = 0; m < numVecs; m++) {
316 for (size_type k = rowmap(row); k < rowmap(row + 1); k++) {
317 const LO col = entries(k);
318 r -= values(k) * Y2(col, m);
333 ArrayView<const LO> blockRows = this->getBlockRows(i);
334 for (
size_t j = 0; j < size_t(blockRows.size()); j++) {
335 const LO row = blockRows[j];
336 auto rowView = getInputRowView(row);
337 for (
size_t m = 0; m < numVecs; m++) {
338 Resid(row, m) = X(row, m);
339 for (
size_t k = 0; k < rowView.size(); ++k) {
340 const LO col = rowView.ind(k);
341 Resid(row, m) -= rowView.val(k) * Y2(col, m);
355 template <
class MatrixType>
357 DoGaussSeidel(ConstHostView X, HostView Y, HostView Y2, SC dampingFactor)
const {
364 using Teuchos::rcpFromRef;
367 auto numVecs = X.extent(1);
369 HostView Resid(
"", X.extent(0), X.extent(1));
370 for (LO i = 0; i < numBlocks_; i++) {
371 DoGSBlock(X, Y, Y2, Resid, dampingFactor, i);
374 auto numMyRows = inputMatrix_->getLocalNumRows();
375 for (
size_t m = 0; m < numVecs; ++m) {
376 for (
size_t i = 0; i < numMyRows * bcrsBlockSize_; ++i) {
383 template <
class MatrixType>
384 void Container<MatrixType>::
385 DoSGS(ConstHostView X, HostView Y, HostView Y2, SC dampingFactor)
const {
394 using Teuchos::rcpFromRef;
395 auto numVecs = X.extent(1);
396 HostView Resid(
"", X.extent(0), X.extent(1));
398 for (LO i = 0; i < numBlocks_; i++) {
399 DoGSBlock(X, Y, Y2, Resid, dampingFactor, i);
401 static_assert(std::is_signed<LO>::value,
402 "Local ordinal must be signed (unsigned breaks reverse iteration to 0)");
404 for (LO i = numBlocks_ - 1; i >= 0; --i) {
405 DoGSBlock(X, Y, Y2, Resid, dampingFactor, i);
408 auto numMyRows = inputMatrix_->getLocalNumRows();
409 for (
size_t m = 0; m < numVecs; ++m) {
410 for (
size_t i = 0; i < numMyRows * bcrsBlockSize_; ++i) {
417 template <
class MatrixType>
418 void Container<MatrixType>::
423 blockOffsets_.clear();
424 Diag_ = Teuchos::null;
429 template <
class MatrixType,
class LocalScalarType>
430 ContainerImpl<MatrixType, LocalScalarType>::
435 : Container<MatrixType>(matrix, partitions, pointIndexed) {}
437 template <
class MatrixType,
class LocalScalarType>
441 template <
class MatrixType,
class LocalScalarType>
445 template <
class MatrixType,
class LocalScalarType>
454 template <
class MatrixType,
class LocalScalarType>
457 ConstHostView XView = X.getLocalViewHost(Tpetra::Access::ReadOnly);
458 HostView YView = Y.getLocalViewHost(Tpetra::Access::ReadWrite);
459 this->apply(XView, YView, 0);
462 template <
class MatrixType,
class LocalScalarType>
466 vector_type& W)
const {
467 ConstHostView XView = X.getLocalViewHost(Tpetra::Access::ReadOnly);
468 HostView YView = Y.getLocalViewHost(Tpetra::Access::ReadWrite);
469 ConstHostView WView = W.getLocalViewHost(Tpetra::Access::ReadOnly);
470 weightedApply(XView, YView, WView, 0);
473 template <
class MatrixType,
class LocalScalarType>
479 template <
class MatrixType,
class LocalScalarType>
486 const LSC beta)
const {
490 template <
class MatrixType,
class LocalScalarType>
491 typename ContainerImpl<MatrixType, LocalScalarType>::LO
496 const map_type& globalRowMap = *(this->inputMatrix_->getRowMap());
497 const map_type& globalColMap = *(this->inputMatrix_->getColMap());
500 if (this->pointIndexed_) {
501 rowLID = row / this->bcrsBlockSize_;
502 dofOffset = row % this->bcrsBlockSize_;
504 GO diagGID = globalRowMap.getGlobalElement(rowLID);
506 diagGID == GO_INVALID,
508 "Ifpack2::Container::translateRowToCol: "
510 << this->inputMatrix_->getRowMap()->getComm()->getRank() <<
", at least one row index in the set of local "
511 "row indices given to the constructor is not a valid local row index in "
512 "the input matrix's row Map on this process. This should be impossible "
513 "because the constructor checks for this case. Here is the complete set "
514 "of invalid local row indices: "
516 "Please report this bug to the Ifpack2 developers.");
518 LO colLID = globalColMap.getLocalElement(diagGID);
520 colLID == LO_INVALID,
522 "Ifpack2::Container::translateRowToCol: "
524 << this->inputMatrix_->getRowMap()->getComm()->getRank() <<
", "
525 "at least one row index in the set of row indices given to the constructor "
526 "does not have a corresponding column index in the input matrix's column "
527 "Map. This probably means that the column(s) in question is/are empty on "
528 "this process, which would make the submatrix to extract structurally "
529 "singular. The invalid global column index is "
532 if (this->pointIndexed_)
533 return colLID * this->bcrsBlockSize_ + dofOffset;
537 template <
class MatrixType,
class LocalScalarType>
559 !this->IsComputed_, std::runtime_error,
560 "Ifpack2::Container::apply: "
561 "You must have called the compute() method before you may call apply(). "
562 "You may call the apply() method as many times as you want after calling "
563 "compute() once, but you must have called compute() at least once.");
565 const size_t numVecs = X.extent(1);
596 if (X_localBlocks_.size() == 0 || X.extent(1) != X_local_.extent(1)) {
598 X_localBlocks_.clear();
599 Y_localBlocks_.clear();
600 X_localBlocks_.reserve(this->numBlocks_);
601 Y_localBlocks_.reserve(this->numBlocks_);
603 X_local_ = HostViewLocal(
"X_local", this->blockRows_.size() * this->scalarsPerRow_, numVecs);
604 Y_local_ = HostViewLocal(
"Y_local", this->blockRows_.size() * this->scalarsPerRow_, numVecs);
608 for (
int i = 0; i < this->numBlocks_; i++) {
609 auto blockBounds = std::make_pair(this->blockOffsets_[i] * this->scalarsPerRow_,
610 (this->blockOffsets_[i] + this->blockSizes_[i]) * this->scalarsPerRow_);
611 X_localBlocks_.emplace_back(X_local_, blockBounds, Kokkos::ALL());
612 Y_localBlocks_.emplace_back(Y_local_, blockBounds, Kokkos::ALL());
616 const ArrayView<const LO> blockRows = this->getBlockRows(blockIndex);
618 if (this->scalarsPerRow_ == 1)
619 mvgs.gatherViewToView(X_localBlocks_[blockIndex], X, blockRows);
621 mvgs.gatherViewToViewBlock(X_localBlocks_[blockIndex], X, blockRows, this->scalarsPerRow_);
628 if (this->scalarsPerRow_ == 1)
629 mvgs.gatherViewToView(Y_localBlocks_[blockIndex], Y, blockRows);
631 mvgs.gatherViewToViewBlock(Y_localBlocks_[blockIndex], Y, blockRows, this->scalarsPerRow_);
635 this->solveBlock(X_localBlocks_[blockIndex], Y_localBlocks_[blockIndex], blockIndex, mode,
640 if (this->scalarsPerRow_ == 1)
641 mvgs.scatterViewToView(Y, Y_localBlocks_[blockIndex], blockRows);
643 mvgs.scatterViewToViewBlock(Y, Y_localBlocks_[blockIndex], blockRows, this->scalarsPerRow_);
646 template <
class MatrixType,
class LocalScalarType>
663 using Teuchos::rcp_const_cast;
673 const char prefix[] =
"Ifpack2::Container::weightedApply: ";
675 !this->IsComputed_, std::runtime_error, prefix <<
"You must have called the "
676 "compute() method before you may call this method. You may call "
677 "weightedApply() as many times as you want after calling compute() once, "
678 "but you must have called compute() at least once first.");
682 this->scalarsPerRow_ > 1, std::logic_error, prefix <<
"Use of block rows isn't allowed "
683 "in overlapping Jacobi (the only method that uses weightedApply");
685 const size_t numVecs = X.extent(1);
688 X.extent(1) != Y.extent(1), std::runtime_error,
689 prefix <<
"X and Y have different numbers of vectors (columns). X has "
690 << X.extent(1) <<
", but Y has " << Y.extent(1) <<
".");
696 const size_t numRows = this->blockSizes_[blockIndex];
721 if (X_localBlocks_.size() == 0 || X.extent(1) != X_local_.extent(1)) {
723 X_localBlocks_.clear();
724 Y_localBlocks_.clear();
725 X_localBlocks_.reserve(this->numBlocks_);
726 Y_localBlocks_.reserve(this->numBlocks_);
728 X_local_ = HostViewLocal(
"X_local", this->blockRows_.size() * this->scalarsPerRow_, numVecs);
729 Y_local_ = HostViewLocal(
"Y_local", this->blockRows_.size() * this->scalarsPerRow_, numVecs);
733 for (
int i = 0; i < this->numBlocks_; i++) {
734 auto blockBounds = std::make_pair(this->blockOffsets_[i] * this->scalarsPerRow_,
735 (this->blockOffsets_[i] + this->blockSizes_[i]) * this->scalarsPerRow_);
736 X_localBlocks_.emplace_back(X_local_, blockBounds, Kokkos::ALL());
737 Y_localBlocks_.emplace_back(Y_local_, blockBounds, Kokkos::ALL());
740 if (
int(weightedApplyScratch_.extent(0)) != 3 * this->maxBlockSize_ ||
741 weightedApplyScratch_.extent(1) != numVecs) {
742 weightedApplyScratch_ = HostViewLocal(
"weightedApply scratch", 3 * this->maxBlockSize_, numVecs);
745 ArrayView<const LO> blockRows = this->getBlockRows(blockIndex);
750 mvgs.gatherViewToView(X_localBlocks_[blockIndex], X, blockRows);
756 mvgs.gatherViewToView(Y_localBlocks_[blockIndex], Y, blockRows);
767 auto maxBS = this->maxBlockSize_;
768 auto bs = this->blockSizes_[blockIndex] * this->scalarsPerRow_;
770 HostSubviewLocal D_local(weightedApplyScratch_, std::make_pair(0, bs), std::make_pair(0, 1));
771 mvgs.gatherViewToView(D_local, D, blockRows);
772 HostSubviewLocal X_scaled(weightedApplyScratch_, std::make_pair(maxBS, maxBS + bs), Kokkos::ALL());
773 for (
size_t j = 0; j < numVecs; j++)
774 for (
size_t i = 0; i < numRows; i++)
775 X_scaled(i, j) = X_localBlocks_[blockIndex](i, j) * D_local(i, 0);
777 HostSubviewLocal Y_temp(weightedApplyScratch_, std::make_pair(maxBS * 2, maxBS * 2 + bs), Kokkos::ALL());
779 this->solveBlock(X_scaled, Y_temp, blockIndex, mode, STS::one(), STS::zero());
787 for (
size_t j = 0; j < numVecs; j++)
788 for (
size_t i = 0; i < numRows; i++)
789 Y_localBlocks_[blockIndex](i, j) = b * Y_localBlocks_[blockIndex](i, j) + a * Y_temp(i, j) * D_local(i, 0);
793 mvgs.scatterViewToView(Y, Y_localBlocks_[blockIndex], blockRows);
796 template <
class MatrixType,
class LocalScalarType>
798 typename ContainerImpl<MatrixType, LocalScalarType>::SC,
799 typename ContainerImpl<MatrixType, LocalScalarType>::LO,
800 typename ContainerImpl<MatrixType, LocalScalarType>::GO,
801 typename ContainerImpl<MatrixType, LocalScalarType>::NO>
804 typedef typename MatrixType::nonconst_local_inds_host_view_type nonconst_local_inds_host_view_type;
805 typedef typename MatrixType::nonconst_values_host_view_type nonconst_values_host_view_type;
807 typedef typename MatrixType::local_inds_host_view_type local_inds_host_view_type;
808 typedef typename MatrixType::values_host_view_type values_host_view_type;
809 using IST =
typename row_matrix_type::impl_scalar_type;
811 if (this->hasBlockCrs_) {
812 using h_inds_type =
typename block_crs_matrix_type::local_inds_host_view_type;
813 using h_vals_type =
typename block_crs_matrix_type::values_host_view_type;
816 this->inputBlockMatrix_->getLocalRowView(row / this->bcrsBlockSize_, colinds, values);
817 size_t numEntries = colinds.size();
820 h_vals_type subvals = Kokkos::subview(values, std::pair<size_t, size_t>(row % this->bcrsBlockSize_, values.size()));
821 return StridedRowView(subvals, colinds, this->bcrsBlockSize_, numEntries * this->bcrsBlockSize_);
822 }
else if (!this->inputMatrix_->supportsRowViews()) {
823 size_t maxEntries = this->inputMatrix_->getLocalMaxNumRowEntries();
826 nonconst_local_inds_host_view_type inds_v(inds.
data(), maxEntries);
827 nonconst_values_host_view_type vals_v(reinterpret_cast<IST*>(vals.
data()), maxEntries);
829 this->inputMatrix_->getLocalRowCopy(row, inds_v, vals_v, numEntries);
835 local_inds_host_view_type colinds;
836 values_host_view_type values;
837 this->inputMatrix_->getLocalRowView(row, colinds, values);
842 template <
class MatrixType,
class LocalScalarType>
845 X_localBlocks_.clear();
846 Y_localBlocks_.clear();
847 X_local_ = HostViewLocal();
848 Y_local_ = HostViewLocal();
855 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
857 StridedRowView(h_vals_type vals_, h_inds_type inds_,
int blockSize_,
size_t nnz_)
860 , blockSize(blockSize_)
863 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
869 , nnz(vals_.size()) {
870 valsCopy.
swap(vals_);
871 indsCopy.
swap(inds_);
874 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
876 val(
size_t i)
const {
877 #ifdef HAVE_IFPACK2_DEBUG
879 "Out-of-bounds access into Ifpack2::Container::StridedRowView");
881 if (vals.size() > 0) {
885 return vals[i * blockSize];
890 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
891 LocalOrdinal StridedRowView<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
892 ind(
size_t i)
const {
893 #ifdef HAVE_IFPACK2_DEBUG
895 "Out-of-bounds access into Ifpack2::Container::StridedRowView");
898 if (inds.size() > 0) {
902 return inds[i / blockSize] * blockSize + i % blockSize;
907 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
908 size_t StridedRowView<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
916 template <
class MatrixType>
917 std::ostream& operator<<(std::ostream& os, const Ifpack2::Container<MatrixType>& obj) {
918 return obj.print(os);
921 #define IFPACK2_CONTAINER_INSTANT(S, LO, GO, N) \
922 template class Ifpack2::Container<Tpetra::RowMatrix<S, LO, GO, N>>; \
923 template class Ifpack2::ContainerImpl<Tpetra::RowMatrix<S, LO, GO, N>, S>; \
924 template class Ifpack2::Details::StridedRowView<S, LO, GO, N>; \
925 template std::ostream& operator<< <Tpetra::RowMatrix<S, LO, GO, N>>( \
926 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:539
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:464
bool isComputed() const
Whether the container has been successfully computed.
Definition: Ifpack2_Container_def.hpp:128
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:231
void setBlockSizes(const Teuchos::Array< Teuchos::Array< LO > > &partitions)
Initialize arrays with information about block sizes.
Definition: Ifpack2_Container_def.hpp:89
Teuchos::Array< LO > blockSizes_
Number of rows in each block.
Definition: Ifpack2_Container_decl.hpp:261
typename Kokkos::ArithTraits< SC >::val_type ISC
Internal representation of Scalar in Kokkos::View.
Definition: Ifpack2_Container_decl.hpp:101
StridedRowView(h_vals_type vals_, h_inds_type inds_, int blockSize_, size_t nnz_)
Constructor for row views (preferred)
Definition: Ifpack2_Container_def.hpp:857
virtual void applyMV(const mv_type &X, mv_type &Y) const
Wrapper for apply with MultiVector.
Definition: Ifpack2_Container_def.hpp:134
bool pointIndexed_
(If hasBlockCrs_) Whether the blocks are described using sub-block row indices instead of full block ...
Definition: Ifpack2_Container_decl.hpp:279
int numBlocks_
The number of blocks (partitions) in the container.
Definition: Ifpack2_Container_decl.hpp:257
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:307
#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:443
bool isInitialized() const
Whether the container has been successfully initialized.
Definition: Ifpack2_Container_def.hpp:123
LO scalarsPerRow_
Definition: Ifpack2_Container_decl.hpp:282
virtual ~Container()
Destructor.
Definition: Ifpack2_Container_def.hpp:80
bool hasBlockCrs_
Whether the input matrix is a BlockCRS matrix.
Definition: Ifpack2_Container_decl.hpp:275
Details::StridedRowView< SC, LO, GO, NO > getInputRowView(LO row) const
View a row of the input matrix.
Definition: Ifpack2_Container_def.hpp:803
LocalScalarType LSC
The internal representation of LocalScalarType in Kokkos::View.
Definition: Ifpack2_Container_decl.hpp:326
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:277
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:493
Teuchos::RCP< const block_crs_matrix_type > inputBlockMatrix_
The input matrix, dynamic cast to BlockCrsMatrix. May be null.
Definition: Ifpack2_Container_decl.hpp:254
Teuchos::RCP< const row_matrix_type > inputMatrix_
The input matrix to the constructor.
Definition: Ifpack2_Container_decl.hpp:248
virtual void weightedApplyMV(const mv_type &X, mv_type &Y, vector_type &W) const
Wrapper for weightedApply with MultiVector.
Definition: Ifpack2_Container_def.hpp:140
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:456
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:447
typename mv_type::dual_view_type::t_host HostView
Definition: Ifpack2_Container_decl.hpp:105
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:648
void resize(size_type new_size, const value_type &x=value_type())
virtual ~ContainerImpl()
Destructor.
Definition: Ifpack2_Container_def.hpp:439
bool IsParallel_
Whether the problem is distributed across multiple MPI processes.
Definition: Ifpack2_Container_decl.hpp:267
static std::string getName()
Definition: Ifpack2_Container_def.hpp:475
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:84
Structure for read-only views of general matrix rows.
Definition: Ifpack2_Container_decl.hpp:294
static std::string getName()
Definition: Ifpack2_Container_def.hpp:146
GO NumGlobalRows_
Number of global rows in input matrix.
Definition: Ifpack2_Container_decl.hpp:271
GO NumGlobalNonzeros_
Number of nonzeros in input matrix.
Definition: Ifpack2_Container_decl.hpp:273
LO NumLocalRows_
Number of local rows in input matrix.
Definition: Ifpack2_Container_decl.hpp:269
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:481
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:151