10#ifndef IFPACK2_CONTAINER_DEF_HPP
11#define IFPACK2_CONTAINER_DEF_HPP
15#include <Teuchos_Time.hpp>
21template <
class MatrixType>
23 const Teuchos::RCP<const row_matrix_type>& matrix,
24 const Teuchos::Array<Teuchos::Array<LO>>& partitions,
33 using Teuchos::ArrayView;
56 Teuchos::ArrayView<const LO> blockRows =
getBlockRows(i);
58 LO row = blockRows[j];
63 TEUCHOS_TEST_FOR_EXCEPTION(
64 !rowMap.isNodeLocalElement(row),
65 std::invalid_argument,
66 "Ifpack2::Container: "
68 << rowMap.getComm()->getRank() <<
" of "
69 << rowMap.getComm()->getSize() <<
", in the given set of local row "
70 "indices blockRows = "
71 << 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>
89template <
class MatrixType>
93 LO totalBlockRows = 0;
99 LO rowsInBlock = partitions[i].size();
102 totalBlockRows += rowsInBlock;
103 maxBlockSize_ = std::max(maxBlockSize_, rowsInBlock *
scalarsPerRow_);
115template <
class MatrixType>
116void Container<MatrixType>::getMatDiag()
const {
117 if (Diag_.is_null()) {
118 Diag_ = rcp(
new vector_type(inputMatrix_->getDomainMap()));
119 inputMatrix_->getLocalDiagCopy(*Diag_);
123template <
class MatrixType>
128template <
class MatrixType>
133template <
class MatrixType>
135 applyMV(
const mv_type& , mv_type& )
const {
136 TEUCHOS_TEST_FOR_EXCEPT_MSG(
true,
"Not implemented.");
139template <
class MatrixType>
142 TEUCHOS_TEST_FOR_EXCEPT_MSG(
true,
"Not implemented.");
145template <
class MatrixType>
151template <
class MatrixType>
154 TEUCHOS_TEST_FOR_EXCEPT_MSG(
true,
"Not implemented.");
157template <
class MatrixType>
159 using STS = Teuchos::ScalarTraits<ISC>;
160 const ISC one = STS::one();
162 size_t numVecs = X.extent(1);
164 for (LO i = 0; i < numBlocks_; i++) {
166 if (blockSizes_[i] != 1 || hasBlockCrs_) {
167 if (blockSizes_[i] == 0)
169 apply(X, Y, i, Teuchos::NO_TRANS, dampingFactor, one);
172 LO LRID = blockRows_[blockOffsets_[i]];
174 auto diagView = Diag_->getLocalViewHost(Tpetra::Access::ReadOnly);
175 ISC d = one * (
static_cast<ISC
>(dampingFactor)) / diagView(LRID, 0);
176 for (
size_t nv = 0; nv < numVecs; nv++) {
178 Y(LRID, nv) += x * d;
184template <
class MatrixType>
186 using STS = Teuchos::ScalarTraits<SC>;
188 for (LO i = 0; i < numBlocks_; i++) {
190 if (blockSizes_[i] == 0)
192 if (blockSizes_[i] != 1) {
194 weightedApply(X, Y, W, i, Teuchos::NO_TRANS, dampingFactor, STS::one());
201 HostView tempo(
"", X.extent(0), X.extent(1));
202 size_t numVecs = X.extent(1);
203 LO bOffset = blockOffsets_[i];
204 for (LO ii = 0; ii < blockSizes_[i]; ii++) {
205 LO LRID = blockRows_[bOffset++];
206 for (
size_t jj = 0; jj < numVecs; jj++) tempo(LRID, jj) = X(LRID, jj) / W(LRID, 0);
208 weightedApply(tempo, Y, W, i, Teuchos::NO_TRANS, dampingFactor, STS::one());
212 const ISC one = STS::one();
213 size_t numVecs = X.extent(1);
214 LO LRID = blockRows_[blockOffsets_[i]];
216 auto diagView = Diag_->getLocalViewHost(Tpetra::Access::ReadOnly);
217 ISC recip = one / diagView(LRID, 0);
218 ISC wval = W(LRID, 0);
219 ISC combo = wval * recip;
220 ISC d = combo * (
static_cast<ISC
>(dampingFactor));
221 for (
size_t nv = 0; nv < numVecs; nv++) {
223 Y(LRID, nv) = x * d + Y(LRID, nv);
231template <
class MatrixType,
typename LocalScalarType>
234 SC dampingFactor, LO i)
const {
235 using Teuchos::ArrayView;
236 using STS = Teuchos::ScalarTraits<ISC>;
237 size_t numVecs = X.extent(1);
238 const ISC one = STS::one();
239 if (this->blockSizes_[i] == 0)
244 const size_t localNumRows = this->blockSizes_[i];
245 using inds_type =
typename block_crs_matrix_type::local_inds_host_view_type;
246 using vals_type =
typename block_crs_matrix_type::values_host_view_type;
247 for (
size_t j = 0; j < localNumRows; j++) {
248 LO row = blockRows[j];
252 LO numEntries = (LO)colinds.size();
253 for (
size_t m = 0; m < numVecs; m++) {
255 Resid(row * this->bcrsBlockSize_ + localR, m) = X(row * this->bcrsBlockSize_ + localR, m);
256 for (LO k = 0; k < numEntries; ++k) {
257 const LO col = colinds[k];
258 for (
int localR = 0; localR < this->bcrsBlockSize_; localR++) {
259 for (
int localC = 0; localC < this->bcrsBlockSize_; localC++) {
260 Resid(row * this->bcrsBlockSize_ + localR, m) -=
261 values[k * this->bcrsBlockSize_ * this->bcrsBlockSize_ + localR + localC * this->bcrsBlockSize_] * Y2(col * this->bcrsBlockSize_ + localC, m);
273 apply(Resid, Y2, i, Teuchos::NO_TRANS, dampingFactor, one);
274 }
else if (!this->
hasBlockCrs_ && this->blockSizes_[i] == 1) {
280 using container_exec_space =
typename ContainerImpl<MatrixType, LocalScalarType>::crs_matrix_type::execution_space;
281 container_exec_space().fence();
283 using size_type =
typename crs_matrix_type::local_matrix_host_type::size_type;
284 const auto& rowmap = localA.graph.row_map;
285 const auto& entries = localA.graph.entries;
286 const auto& values = localA.values;
288 auto diagView = this->
Diag_->getLocalViewHost(Tpetra::Access::ReadOnly);
289 ISC d = (
static_cast<ISC>(dampingFactor)) / diagView(LRID, 0);
290 for (
size_t m = 0; m < numVecs; m++) {
293 for (size_type k = rowmap(LRID); k < rowmap(LRID + 1); k++) {
294 const LO col = entries(k);
295 r -= values(k) * Y2(col, m);
302 std::is_same<typename crs_matrix_type::device_type::memory_space, Kokkos::HostSpace>::value) {
305 using container_exec_space =
typename ContainerImpl<MatrixType, LocalScalarType>::crs_matrix_type::execution_space;
306 container_exec_space().fence();
308 using size_type =
typename crs_matrix_type::local_matrix_host_type::size_type;
309 const auto& rowmap = localA.graph.row_map;
310 const auto& entries = localA.graph.entries;
311 const auto& values = localA.values;
313 for (
size_t j = 0; j < size_t(blockRows.size()); j++) {
314 const LO row = blockRows[j];
315 for (
size_t m = 0; m < numVecs; m++) {
317 for (size_type k = rowmap(row); k < rowmap(row + 1); k++) {
318 const LO col = entries(k);
319 r -= values(k) * Y2(col, m);
330 apply(Resid, Y2, i, Teuchos::NO_TRANS, dampingFactor, one);
335 for (
size_t j = 0; j < size_t(blockRows.size()); j++) {
336 const LO row = blockRows[j];
338 for (
size_t m = 0; m < numVecs; m++) {
339 Resid(row, m) = X(row, m);
340 for (
size_t k = 0; k < rowView.size(); ++k) {
341 const LO col = rowView.ind(k);
342 Resid(row, m) -= rowView.val(k) * Y2(col, m);
352 apply(Resid, Y2, i, Teuchos::NO_TRANS, dampingFactor, one);
356template <
class MatrixType>
357void Container<MatrixType>::
358 DoGaussSeidel(ConstHostView X, HostView Y, HostView Y2, SC dampingFactor)
const {
359 using Teuchos::Array;
360 using Teuchos::ArrayRCP;
361 using Teuchos::ArrayView;
365 using Teuchos::rcpFromRef;
368 auto numVecs = X.extent(1);
370 HostView Resid(
"", X.extent(0), X.extent(1));
372 DoGSBlock(X, Y, Y2, Resid, dampingFactor, i);
375 auto numMyRows = inputMatrix_->getLocalNumRows();
376 for (
size_t m = 0; m < numVecs; ++m) {
377 for (
size_t i = 0; i < numMyRows * bcrsBlockSize_; ++i) {
384template <
class MatrixType>
388 using Teuchos::Array;
389 using Teuchos::ArrayRCP;
390 using Teuchos::ArrayView;
395 using Teuchos::rcpFromRef;
396 auto numVecs = X.extent(1);
397 HostView Resid(
"", X.extent(0), X.extent(1));
400 DoGSBlock(X, Y, Y2, Resid, dampingFactor, i);
402 static_assert(std::is_signed<LO>::value,
403 "Local ordinal must be signed (unsigned breaks reverse iteration to 0)");
406 DoGSBlock(X, Y, Y2, Resid, dampingFactor, i);
409 auto numMyRows = inputMatrix_->getLocalNumRows();
410 for (
size_t m = 0; m < numVecs; ++m) {
418template <
class MatrixType>
424 blockOffsets_.clear();
425 Diag_ = Teuchos::null;
430template <
class MatrixType,
class LocalScalarType>
431ContainerImpl<MatrixType, LocalScalarType>::
433 const Teuchos::RCP<const row_matrix_type>& matrix,
434 const Teuchos::Array<Teuchos::Array<LO>>& partitions,
436 :
Container<MatrixType>(matrix, partitions, pointIndexed) {}
438template <
class MatrixType,
class LocalScalarType>
442template <
class MatrixType,
class LocalScalarType>
446template <
class MatrixType,
class LocalScalarType>
452 TEUCHOS_TEST_FOR_EXCEPT_MSG(
true,
"Not implemented.");
455template <
class MatrixType,
class LocalScalarType>
457 applyMV(
const mv_type& X, mv_type& Y)
const {
458 ConstHostView XView = X.getLocalViewHost(Tpetra::Access::ReadOnly);
459 HostView YView = Y.getLocalViewHost(Tpetra::Access::ReadWrite);
463template <
class MatrixType,
class LocalScalarType>
467 vector_type& W)
const {
468 ConstHostView XView = X.getLocalViewHost(Tpetra::Access::ReadOnly);
469 HostView YView = Y.getLocalViewHost(Tpetra::Access::ReadWrite);
470 ConstHostView WView = W.getLocalViewHost(Tpetra::Access::ReadOnly);
474template <
class MatrixType,
class LocalScalarType>
480template <
class MatrixType,
class LocalScalarType>
488 TEUCHOS_TEST_FOR_EXCEPT_MSG(
true,
"Not implemented.");
491template <
class MatrixType,
class LocalScalarType>
492typename ContainerImpl<MatrixType, LocalScalarType>::LO
495 LO LO_INVALID = Teuchos::OrdinalTraits<LO>::invalid();
496 GO GO_INVALID = Teuchos::OrdinalTraits<GO>::invalid();
497 const map_type& globalRowMap = *(this->
inputMatrix_->getRowMap());
498 const map_type& globalColMap = *(this->
inputMatrix_->getColMap());
505 GO diagGID = globalRowMap.getGlobalElement(rowLID);
506 TEUCHOS_TEST_FOR_EXCEPTION(
507 diagGID == GO_INVALID,
509 "Ifpack2::Container::translateRowToCol: "
511 << this->
inputMatrix_->getRowMap()->getComm()->getRank() <<
", at least one row index in the set of local "
512 "row indices given to the constructor is not a valid local row index in "
513 "the input matrix's row Map on this process. This should be impossible "
514 "because the constructor checks for this case. Here is the complete set "
515 "of invalid local row indices: "
517 "Please report this bug to the Ifpack2 developers.");
519 LO colLID = globalColMap.getLocalElement(diagGID);
520 TEUCHOS_TEST_FOR_EXCEPTION(
521 colLID == LO_INVALID,
523 "Ifpack2::Container::translateRowToCol: "
525 << this->
inputMatrix_->getRowMap()->getComm()->getRank() <<
", "
526 "at least one row index in the set of row indices given to the constructor "
527 "does not have a corresponding column index in the input matrix's column "
528 "Map. This probably means that the column(s) in question is/are empty on "
529 "this process, which would make the submatrix to extract structurally "
530 "singular. The invalid global column index is "
538template <
class MatrixType,
class LocalScalarType>
540 apply(ConstHostView X,
543 Teuchos::ETransp mode,
546 using Teuchos::ArrayView;
559 TEUCHOS_TEST_FOR_EXCEPTION(
561 "Ifpack2::Container::apply: "
562 "You must have called the compute() method before you may call apply(). "
563 "You may call the apply() method as many times as you want after calling "
564 "compute() once, but you must have called compute() at least once.");
566 const size_t numVecs = X.extent(1);
604 X_local_ = HostViewLocal(
"X_local", this->
blockRows_.size() * this->scalarsPerRow_, numVecs);
605 Y_local_ = HostViewLocal(
"Y_local", this->
blockRows_.size() * this->scalarsPerRow_, numVecs);
609 for (
int i = 0; i < this->numBlocks_; i++) {
611 (this->
blockOffsets_[i] + this->blockSizes_[i]) * this->scalarsPerRow_);
613 Y_localBlocks_.emplace_back(Y_local_, blockBounds, Kokkos::ALL());
617 const ArrayView<const LO> blockRows = this->
getBlockRows(blockIndex);
647template <
class MatrixType,
class LocalScalarType>
653 Teuchos::ETransp mode,
657 using Teuchos::ArrayRCP;
658 using Teuchos::ArrayView;
661 using Teuchos::Range1D;
664 using Teuchos::rcp_const_cast;
665 using STS = Teuchos::ScalarTraits<SC>;
674 const char prefix[] =
"Ifpack2::Container::weightedApply: ";
675 TEUCHOS_TEST_FOR_EXCEPTION(
676 !this->
IsComputed_, std::runtime_error, prefix <<
"You must have called the "
677 "compute() method before you may call this method. You may call "
678 "weightedApply() as many times as you want after calling compute() once, "
679 "but you must have called compute() at least once first.");
682 TEUCHOS_TEST_FOR_EXCEPTION(
683 this->
scalarsPerRow_ > 1, std::logic_error, prefix <<
"Use of block rows isn't allowed "
684 "in overlapping Jacobi (the only method that uses weightedApply");
686 const size_t numVecs = X.extent(1);
688 TEUCHOS_TEST_FOR_EXCEPTION(
689 X.extent(1) != Y.extent(1), std::runtime_error,
690 prefix <<
"X and Y have different numbers of vectors (columns). X has "
691 << X.extent(1) <<
", but Y has " << Y.extent(1) <<
".");
697 const size_t numRows = this->blockSizes_[blockIndex];
729 X_local_ = HostViewLocal(
"X_local", this->
blockRows_.size() * this->scalarsPerRow_, numVecs);
730 Y_local_ = HostViewLocal(
"Y_local", this->
blockRows_.size() * this->scalarsPerRow_, numVecs);
734 for (
int i = 0; i < this->numBlocks_; i++) {
736 (this->
blockOffsets_[i] + this->blockSizes_[i]) * this->scalarsPerRow_);
738 Y_localBlocks_.emplace_back(Y_local_, blockBounds, Kokkos::ALL());
746 ArrayView<const LO> blockRows = this->
getBlockRows(blockIndex);
768 auto maxBS = this->maxBlockSize_;
772 mvgs.gatherViewToView(D_local, D, blockRows);
774 for (
size_t j = 0; j < numVecs; j++)
775 for (
size_t i = 0; i < numRows; i++)
776 X_scaled(i, j) =
X_localBlocks_[blockIndex](i, j) * D_local(i, 0);
778 HostSubviewLocal Y_temp(
weightedApplyScratch_, std::make_pair(maxBS * 2, maxBS * 2 + bs), Kokkos::ALL());
780 this->
solveBlock(X_scaled, Y_temp, blockIndex, mode, STS::one(), STS::zero());
788 for (
size_t j = 0; j < numVecs; j++)
789 for (
size_t i = 0; i < numRows; i++)
797template <
class MatrixType,
class LocalScalarType>
799 typename ContainerImpl<MatrixType, LocalScalarType>::SC,
800 typename ContainerImpl<MatrixType, LocalScalarType>::LO,
801 typename ContainerImpl<MatrixType, LocalScalarType>::GO,
802 typename ContainerImpl<MatrixType, LocalScalarType>::NO>
805 typedef typename MatrixType::nonconst_local_inds_host_view_type nonconst_local_inds_host_view_type;
806 typedef typename MatrixType::nonconst_values_host_view_type nonconst_values_host_view_type;
808 typedef typename MatrixType::local_inds_host_view_type local_inds_host_view_type;
809 typedef typename MatrixType::values_host_view_type values_host_view_type;
810 using IST =
typename row_matrix_type::impl_scalar_type;
813 using h_inds_type =
typename block_crs_matrix_type::local_inds_host_view_type;
814 using h_vals_type =
typename block_crs_matrix_type::values_host_view_type;
818 size_t numEntries = colinds.size();
821 h_vals_type subvals = Kokkos::subview(values, std::pair<size_t, size_t>(row % this->
bcrsBlockSize_, values.size()));
822 return StridedRowView(subvals, colinds, this->bcrsBlockSize_, numEntries * this->bcrsBlockSize_);
824 size_t maxEntries = this->
inputMatrix_->getLocalMaxNumRowEntries();
825 Teuchos::Array<LO> inds(maxEntries);
826 Teuchos::Array<SC> vals(maxEntries);
827 nonconst_local_inds_host_view_type inds_v(inds.data(), maxEntries);
828 nonconst_values_host_view_type vals_v(
reinterpret_cast<IST*
>(vals.data()), maxEntries);
830 this->
inputMatrix_->getLocalRowCopy(row, inds_v, vals_v, numEntries);
831 vals.resize(numEntries);
832 inds.resize(numEntries);
833 return StridedRowView(vals, inds);
836 local_inds_host_view_type colinds;
837 values_host_view_type values;
838 this->
inputMatrix_->getLocalRowView(row, colinds, values);
839 return StridedRowView(values, colinds, 1, colinds.size());
843template <
class MatrixType,
class LocalScalarType>
846 X_localBlocks_.clear();
847 Y_localBlocks_.clear();
848 X_local_ = HostViewLocal();
849 Y_local_ = HostViewLocal();
850 Container<MatrixType>::clearBlocks();
856template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
858 StridedRowView(h_vals_type vals_, h_inds_type inds_,
int blockSize_,
size_t nnz_)
861 , blockSize(blockSize_)
864template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
866 StridedRowView(Teuchos::Array<SC>& vals_, Teuchos::Array<LO>& inds_)
870 , nnz(vals_.size()) {
871 valsCopy.swap(vals_);
872 indsCopy.swap(inds_);
875template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
877 val(
size_t i)
const {
879 TEUCHOS_TEST_FOR_EXCEPTION(i >= nnz, std::runtime_error,
880 "Out-of-bounds access into Ifpack2::Container::StridedRowView");
882 if (vals.size() > 0) {
886 return vals[i * blockSize];
891template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
893 ind(
size_t i)
const {
895 TEUCHOS_TEST_FOR_EXCEPTION(i >= nnz, std::runtime_error,
896 "Out-of-bounds access into Ifpack2::Container::StridedRowView");
899 if (inds.size() > 0) {
903 return inds[i / blockSize] * blockSize + i % blockSize;
908template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
917template <
class MatrixType>
919 return obj.
print(os);
922#define IFPACK2_CONTAINER_INSTANT(S, LO, GO, N) \
923 template class Ifpack2::Container<Tpetra::RowMatrix<S, LO, GO, N>>; \
924 template class Ifpack2::ContainerImpl<Tpetra::RowMatrix<S, LO, GO, N>, S>; \
925 template class Ifpack2::Details::StridedRowView<S, LO, GO, N>; \
926 template std::ostream& operator<< <Tpetra::RowMatrix<S, LO, GO, N>>( \
927 std::ostream& os, const Ifpack2::Container<Tpetra::RowMatrix<S, LO, GO, N>>& obj);
std::ostream & operator<<(std::ostream &os, const Ifpack2::Container< MatrixType > &obj)
Print information about the given Container to the output stream os.
Definition Ifpack2_Container_def.hpp:918
Declaration of Ifpack2::Details::Behavior, a class that describes Ifpack2's run-time behavior.
Declaration and definition of the Ifpack2::Details::MultiVectorLocalGatherScatter class.
virtual ~Container()
Destructor.
Definition Ifpack2_Container_def.hpp:81
bool hasBlockCrs_
Whether the input matrix is a BlockCRS matrix.
Definition Ifpack2_Container_decl.hpp:274
Teuchos::RCP< const crs_matrix_type > inputCrsMatrix_
The input matrix, dynamic cast to CrsMatrix. May be null.
Definition Ifpack2_Container_decl.hpp:250
bool IsParallel_
Whether the problem is distributed across multiple MPI processes.
Definition Ifpack2_Container_decl.hpp:266
int numBlocks_
The number of blocks (partitions) in the container.
Definition Ifpack2_Container_decl.hpp:256
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:147
Teuchos::RCP< vector_type > Diag_
Diagonal elements.
Definition Ifpack2_Container_decl.hpp:264
int bcrsBlockSize_
If hasBlockCrs_, the number of DOFs per vertex. Otherwise 1.
Definition Ifpack2_Container_decl.hpp:276
Teuchos::RCP< const block_crs_matrix_type > inputBlockMatrix_
The input matrix, dynamic cast to BlockCrsMatrix. May be null.
Definition Ifpack2_Container_decl.hpp:253
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:152
virtual void applyMV(const mv_type &X, mv_type &Y) const
Wrapper for apply with MultiVector.
Definition Ifpack2_Container_def.hpp:135
LO NumLocalRows_
Number of local rows in input matrix.
Definition Ifpack2_Container_decl.hpp:268
bool isInitialized() const
Whether the container has been successfully initialized.
Definition Ifpack2_Container_def.hpp:124
void setBlockSizes(const Teuchos::Array< Teuchos::Array< LO > > &partitions)
Initialize arrays with information about block sizes.
Definition Ifpack2_Container_def.hpp:90
LO scalarsPerRow_
Definition Ifpack2_Container_decl.hpp:281
Teuchos::Array< LO > blockSizes_
Number of rows in each block.
Definition Ifpack2_Container_decl.hpp:260
GO NumGlobalNonzeros_
Number of nonzeros in input matrix.
Definition Ifpack2_Container_decl.hpp:272
Container(const Teuchos::RCP< const row_matrix_type > &matrix, const Teuchos::Array< Teuchos::Array< LO > > &partitions, bool pointIndexed)
Constructor.
Definition Ifpack2_Container_def.hpp:22
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:141
Teuchos::RCP< const row_matrix_type > inputMatrix_
The input matrix to the constructor.
Definition Ifpack2_Container_decl.hpp:247
bool pointIndexed_
(If hasBlockCrs_) Whether the blocks are described using sub-block row indices instead of full block ...
Definition Ifpack2_Container_decl.hpp:278
bool IsInitialized_
If true, the container has been successfully initialized.
Definition Ifpack2_Container_decl.hpp:284
typename KokkosKernels::ArithTraits< SC >::val_type ISC
Internal representation of Scalar in Kokkos::View.
Definition Ifpack2_Container_decl.hpp:101
Teuchos::Array< LO > blockRows_
Local indices of the rows of the input matrix that belong to this block.
Definition Ifpack2_Container_decl.hpp:258
GO NumGlobalRows_
Number of global rows in input matrix.
Definition Ifpack2_Container_decl.hpp:270
bool isComputed() const
Whether the container has been successfully computed.
Definition Ifpack2_Container_def.hpp:129
typename mv_type::dual_view_type::t_host HostView
Definition Ifpack2_Container_decl.hpp:105
Teuchos::Array< LO > blockOffsets_
Starting index in blockRows_ of local row indices for each block.
Definition Ifpack2_Container_decl.hpp:262
bool IsComputed_
If true, the container has been successfully computed.
Definition Ifpack2_Container_decl.hpp:286
The implementation of the numerical features of Container (Jacobi, Gauss-Seidel, SGS)....
Definition Ifpack2_Container_decl.hpp:306
std::vector< HostSubviewLocal > X_localBlocks_
Views for holding pieces of X corresponding to each block.
Definition Ifpack2_Container_decl.hpp:484
HostViewLocal X_local_
Scratch vectors used in apply().
Definition Ifpack2_Container_decl.hpp:468
virtual void setParameters(const Teuchos::ParameterList &List)
Set parameters, if any.
Definition Ifpack2_Container_def.hpp:444
Details::StridedRowView< SC, LO, GO, NO > getInputRowView(LO row) const
View a row of the input matrix.
Definition Ifpack2_Container_def.hpp:804
std::vector< HostSubviewLocal > Y_localBlocks_
Views for holding pieces of Y corresponding to each block.
Definition Ifpack2_Container_decl.hpp:487
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:649
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:457
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:540
LocalScalarType LSC
The internal representation of LocalScalarType in Kokkos::View.
Definition Ifpack2_Container_decl.hpp:325
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:232
virtual void solveBlock(ConstHostSubviewLocal X, HostSubviewLocal Y, int blockIndex, Teuchos::ETransp mode, const LSC alpha, const LSC beta) const
Definition Ifpack2_Container_def.hpp:482
HostViewLocal weightedApplyScratch_
Definition Ifpack2_Container_decl.hpp:481
static std::string getName()
Definition Ifpack2_Container_def.hpp:476
LO translateRowToCol(LO row)
Definition Ifpack2_Container_def.hpp:494
virtual ~ContainerImpl()
Destructor.
Definition Ifpack2_Container_def.hpp:440
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:465
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:448
static bool debug()
Whether Ifpack2 is in debug mode.
Definition Ifpack2_Details_Behavior.cpp:31
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:40
Structure for read-only views of general matrix rows.
Definition Ifpack2_Container_decl.hpp:497
StridedRowView(h_vals_type vals_, h_inds_type inds_, int blockSize_, size_t nnz_)
Constructor for row views (preferred).
Definition Ifpack2_Container_def.hpp:858