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,
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>
91template<
class MatrixType>
96 LO totalBlockRows = 0;
103 LO rowsInBlock = partitions[i].size();
106 totalBlockRows += rowsInBlock;
107 maxBlockSize_ = std::max(maxBlockSize_, rowsInBlock *
scalarsPerRow_);
121template<
class MatrixType>
122void Container<MatrixType>::getMatDiag()
const
126 Diag_ = rcp(
new vector_type(inputMatrix_->getDomainMap()));
127 inputMatrix_->getLocalDiagCopy(*Diag_);
131template<
class MatrixType>
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>
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)
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];
276 LO numEntries = (LO) colinds.size();
277 for(
size_t m = 0; m < numVecs; m++)
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)
310 using container_exec_space =
typename ContainerImpl<MatrixType, LocalScalarType>::crs_matrix_type::execution_space;
311 container_exec_space().fence();
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);
334 std::is_same<typename crs_matrix_type::device_type::memory_space, Kokkos::HostSpace>::value)
338 using container_exec_space =
typename ContainerImpl<MatrixType, LocalScalarType>::crs_matrix_type::execution_space;
339 container_exec_space().fence();
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;
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);
373 for(
size_t j = 0; j < size_t(blockRows.size()); j++)
375 const LO row = blockRows[j];
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));
415 DoGSBlock(X, Y, Y2, Resid, dampingFactor, i);
420 for (
size_t m = 0; m < numVecs; ++m)
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));
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)");
455 DoGSBlock(X, Y, Y2, Resid, dampingFactor, i);
460 for (
size_t m = 0; m < numVecs; ++m)
470template<
class MatrixType>
477 blockOffsets_.clear();
478 Diag_ = Teuchos::null;
483template<
class MatrixType,
class 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);
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());
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 <<
".");
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);
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++)
668 (this->
blockOffsets_[i] + this->blockSizes_[i]) * this->scalarsPerRow_);
670 Y_localBlocks_.emplace_back(Y_local_, blockBounds, Kokkos::ALL());
674 const ArrayView<const LO> blockRows = this->
getBlockRows(blockIndex);
699 mvgs.scatterViewToView (Y,
Y_localBlocks_[blockIndex], blockRows);
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];
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++)
796 (this->
blockOffsets_[i] + this->blockSizes_[i]) * this->scalarsPerRow_);
798 Y_localBlocks_.emplace_back(Y_local_, blockBounds, Kokkos::ALL());
807 ArrayView<const LO> blockRows = this->
getBlockRows(blockIndex);
829 auto maxBS = this->maxBlockSize_;
833 mvgs.gatherViewToView (D_local, D, blockRows);
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++)
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;
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;
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_);
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);
898 return StridedRowView(vals, inds);
903 local_inds_host_view_type colinds;
904 values_host_view_type values;
905 this->
inputMatrix_->getLocalRowView(row, colinds, values);
906 return StridedRowView(values, colinds, 1, colinds.size());
910template<
class MatrixType,
class LocalScalarType>
914 X_localBlocks_.clear();
915 Y_localBlocks_.clear();
916 X_local_ = HostViewLocal();
917 Y_local_ = HostViewLocal();
918 Container<MatrixType>::clearBlocks();
924template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
926StridedRowView(h_vals_type vals_, h_inds_type inds_,
int blockSize_,
size_t nnz_)
927 : vals(vals_), inds(inds_), blockSize(blockSize_), nnz(nnz_)
930template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
932StridedRowView(Teuchos::Array<SC>& vals_, Teuchos::Array<LO>& inds_)
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
944 TEUCHOS_TEST_FOR_EXCEPTION(i >= nnz, std::runtime_error,
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>
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
std::vector< HostSubviewLocal > X_localBlocks_
Views for holding pieces of X corresponding to each block.
Definition Ifpack2_Container_decl.hpp:490
HostViewLocal X_local_
Scratch vectors used in apply().
Definition Ifpack2_Container_decl.hpp:474
virtual void setParameters(const Teuchos::ParameterList &List)
Set parameters, if any.
Definition Ifpack2_Container_def.hpp:497
Details::StridedRowView< SC, LO, GO, NO > getInputRowView(LO row) const
Definition Ifpack2_Container_def.hpp:865
std::vector< HostSubviewLocal > Y_localBlocks_
Views for holding pieces of Y corresponding to each block.
Definition Ifpack2_Container_decl.hpp:493
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 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 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
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
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
HostViewLocal weightedApplyScratch_
Definition Ifpack2_Container_decl.hpp:487
static std::string getName()
Definition Ifpack2_Container_def.hpp:532
LO translateRowToCol(LO row)
Definition Ifpack2_Container_def.hpp:552
virtual ~ContainerImpl()
Destructor.
Definition Ifpack2_Container_def.hpp:493
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
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
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
Teuchos::RCP< const crs_matrix_type > inputCrsMatrix_
The input matrix, dynamic cast to CrsMatrix. May be null.
Definition Ifpack2_Container_decl.hpp:253
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
Teuchos::RCP< vector_type > Diag_
Diagonal elements.
Definition Ifpack2_Container_decl.hpp:267
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
bool IsInitialized_
If true, the container has been successfully initialized.
Definition Ifpack2_Container_decl.hpp:287
Teuchos::Array< LO > blockRows_
Local indices of the rows of the input matrix that belong to this block.
Definition Ifpack2_Container_decl.hpp:261
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
Teuchos::Array< LO > blockOffsets_
Starting index in blockRows_ of local row indices for each block.
Definition Ifpack2_Container_decl.hpp:265
bool IsComputed_
If true, the container has been successfully computed.
Definition Ifpack2_Container_decl.hpp:289
Implementation detail of Ifpack2::Container subclasses.
Definition Ifpack2_Details_MultiVectorLocalGatherScatter.hpp:52
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