43 #ifndef IFPACK2_DIAGONALFILTER_DEF_HPP 44 #define IFPACK2_DIAGONALFILTER_DEF_HPP 45 #include "Ifpack2_DiagonalFilter_decl.hpp" 48 #include "Teuchos_Comm.hpp" 49 #include "Tpetra_Map.hpp" 50 #include "Tpetra_MultiVector.hpp" 51 #include "Tpetra_Vector.hpp" 56 template<
class MatrixType>
62 AbsoluteThreshold_(AbsoluteThreshold),
63 RelativeThreshold_(RelativeThreshold)
66 val_=Teuchos::rcp(
new Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node>(A_->getRowMap()));
76 A_->getLocalRowCopy(MyRow,Indices,Values,NumEntries);
78 for (
size_t i = 0 ; i < NumEntries ; ++i) {
79 if ((
size_t)Indices[i] == MyRow) {
87 val_->replaceLocalValue (MyRow, Values[i] * (RelativeThreshold_ - 1) +
88 AbsoluteThreshold_ * mysign);
95 template<
class MatrixType>
98 template<
class MatrixType>
101 return A_->getComm();
104 template<
class MatrixType>
107 return A_->getNode();
110 template<
class MatrixType>
111 Teuchos::RCP<
const Tpetra::Map<
typename MatrixType::local_ordinal_type,
112 typename MatrixType::global_ordinal_type,
113 typename MatrixType::node_type> >
116 return A_->getRowMap();
119 template<
class MatrixType>
120 Teuchos::RCP<
const Tpetra::Map<
typename MatrixType::local_ordinal_type,
121 typename MatrixType::global_ordinal_type,
122 typename MatrixType::node_type> >
125 return A_->getColMap();
128 template<
class MatrixType>
129 Teuchos::RCP<
const Tpetra::Map<
typename MatrixType::local_ordinal_type,
130 typename MatrixType::global_ordinal_type,
131 typename MatrixType::node_type> >
134 return A_->getDomainMap();
137 template<
class MatrixType>
138 Teuchos::RCP<
const Tpetra::Map<
typename MatrixType::local_ordinal_type,
139 typename MatrixType::global_ordinal_type,
140 typename MatrixType::node_type> >
143 return A_->getRangeMap();
146 template<
class MatrixType>
147 Teuchos::RCP<
const Tpetra::RowGraph<
typename MatrixType::local_ordinal_type,
148 typename MatrixType::global_ordinal_type,
149 typename MatrixType::node_type> >
152 return A_->getGraph();
155 template<
class MatrixType>
158 return A_->getGlobalNumRows();
161 template<
class MatrixType>
164 return A_->getGlobalNumCols();
167 template<
class MatrixType>
170 return A_->getNodeNumRows();
173 template<
class MatrixType>
176 return A_->getNodeNumCols();
179 template<
class MatrixType>
182 return A_->getIndexBase();
185 template<
class MatrixType>
188 return A_->getGlobalNumEntries();
191 template<
class MatrixType>
194 return A_->getNodeNumEntries();
197 template<
class MatrixType>
200 return A_->getNumEntriesInGlobalRow(globalRow);
203 template<
class MatrixType>
206 return A_->getNumEntriesInLocalRow(localRow);
209 template<
class MatrixType>
212 return A_->getGlobalNumDiags();
215 template<
class MatrixType>
218 return A_->getNodeNumDiags();
221 template<
class MatrixType>
224 return A_->getGlobalMaxNumRowEntries();
227 template<
class MatrixType>
230 return A_->getNodeMaxNumRowEntries();
233 template<
class MatrixType>
236 return A_->hasColMap();
239 template<
class MatrixType>
242 return A_->isLowerTriangular();
245 template<
class MatrixType>
248 return A_->isUpperTriangular();
251 template<
class MatrixType>
254 return A_->isLocallyIndexed();
257 template<
class MatrixType>
260 return A_->isGloballyIndexed();
263 template<
class MatrixType>
266 return A_->isFillComplete();
269 template<
class MatrixType>
274 size_t &NumEntries)
const 277 LocalOrdinal LocalRow=getRowMap()->getLocalElement(GlobalRow);
279 A_->getGlobalRowCopy(GlobalRow, Indices,Values,NumEntries);
281 if (pos_[LocalRow] != -1)
282 Values[pos_[LocalRow]] += myvals[LocalRow];
285 template<
class MatrixType>
290 size_t &NumEntries)
const 294 A_->getLocalRowCopy(LocalRow, Indices,Values,NumEntries);
296 if (pos_[LocalRow] != -1)
297 Values[pos_[LocalRow]] += myvals[LocalRow];
300 template<
class MatrixType>
306 throw std::runtime_error(
"Ifpack2::DiagonalFilter: does not support getGlobalRowView.");
309 template<
class MatrixType>
315 throw std::runtime_error(
"Ifpack2::DiagonalFilter: does not support getLocalRowView.");
318 template<
class MatrixType>
323 return A_->getLocalDiagCopy(diag);
326 template<
class MatrixType>
329 throw std::runtime_error(
"Ifpack2::DiagonalFilter does not support leftScale.");
332 template<
class MatrixType>
335 throw std::runtime_error(
"Ifpack2::DiagonalFilter does not support rightScale.");
338 template<
class MatrixType>
340 apply (
const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &X,
341 Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &Y,
350 A_->apply(X,Y,mode,alpha,beta);
351 Y.elementWiseMultiply(one,*val_,X,one);
354 template<
class MatrixType>
357 return A_->hasTransposeApply();
360 template<
class MatrixType>
366 template<
class MatrixType>
369 throw std::runtime_error(
"Ifpack2::DiagonalFilter does not implement getFrobeniusNorm.");
374 #define IFPACK2_DIAGONALFILTER_INSTANT(S,LO,GO,N) \ 375 template class Ifpack2::DiagonalFilter< Tpetra::RowMatrix<S, LO, GO, N> >; virtual Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const
Returns the Map that describes the range distribution in this matrix.
Definition: Ifpack2_DiagonalFilter_def.hpp:141
virtual global_size_t getGlobalNumRows() const
Returns the number of global rows in this matrix.
Definition: Ifpack2_DiagonalFilter_def.hpp:156
virtual global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
Definition: Ifpack2_DiagonalFilter_def.hpp:186
virtual bool isLocallyIndexed() const
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
Definition: Ifpack2_DiagonalFilter_def.hpp:252
virtual bool isGloballyIndexed() const
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
Definition: Ifpack2_DiagonalFilter_def.hpp:258
virtual GlobalOrdinal getIndexBase() const
Returns the index base for global indices for this matrix.
Definition: Ifpack2_DiagonalFilter_def.hpp:180
virtual size_t getNodeNumEntries() const
Returns the local number of entries in this matrix.
Definition: Ifpack2_DiagonalFilter_def.hpp:192
virtual ~DiagonalFilter()
Destructor.
Definition: Ifpack2_DiagonalFilter_def.hpp:96
virtual bool hasColMap() const
Indicates whether this matrix has a well-defined column map.
Definition: Ifpack2_DiagonalFilter_def.hpp:234
virtual Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const
Returns the Map that describes the row distribution in this matrix.
Definition: Ifpack2_DiagonalFilter_def.hpp:114
virtual size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
Definition: Ifpack2_DiagonalFilter_def.hpp:222
virtual Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getDomainMap() const
Returns the Map that describes the domain distribution in this matrix.
Definition: Ifpack2_DiagonalFilter_def.hpp:132
virtual bool supportsRowViews() const
Returns true if RowViews are supported.
Definition: Ifpack2_DiagonalFilter_def.hpp:361
virtual void getGlobalRowView(GlobalOrdinal GlobalRow, Teuchos::ArrayView< const GlobalOrdinal > &indices, Teuchos::ArrayView< const Scalar > &values) const
Extract a const, non-persisting view of global indices in a specified row of the matrix.
Definition: Ifpack2_DiagonalFilter_def.hpp:302
virtual mag_type getFrobeniusNorm() const
Returns the Frobenius norm of the matrix.
Definition: Ifpack2_DiagonalFilter_def.hpp:367
virtual Teuchos::RCP< Node > getNode() const
Returns the underlying node.
Definition: Ifpack2_DiagonalFilter_def.hpp:105
virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Returns the communicator.
Definition: Ifpack2_DiagonalFilter_def.hpp:99
virtual void leftScale(const Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
Scales the RowMatrix on the left with the Vector x.
Definition: Ifpack2_DiagonalFilter_def.hpp:327
virtual size_t getNodeMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
Definition: Ifpack2_DiagonalFilter_def.hpp:228
virtual bool hasTransposeApply() const
Indicates whether this operator supports applying the adjoint operator.
Definition: Ifpack2_DiagonalFilter_def.hpp:355
virtual void rightScale(const Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
Scales the RowMatrix on the right with the Vector x.
Definition: Ifpack2_DiagonalFilter_def.hpp:333
virtual void apply(const Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=Teuchos::ScalarTraits< Scalar >::one(), Scalar beta=Teuchos::ScalarTraits< Scalar >::zero()) const
Computes the operator-multivector application.
Definition: Ifpack2_DiagonalFilter_def.hpp:340
virtual Teuchos::RCP< const Tpetra::RowGraph< LocalOrdinal, GlobalOrdinal, Node > > getGraph() const
Returns the RowGraph associated with this matrix.
Definition: Ifpack2_DiagonalFilter_def.hpp:150
virtual global_size_t getGlobalNumCols() const
Returns the number of global columns in this matrix.
Definition: Ifpack2_DiagonalFilter_def.hpp:162
virtual void getLocalRowCopy(LocalOrdinal LocalRow, const Teuchos::ArrayView< LocalOrdinal > &Indices, const Teuchos::ArrayView< Scalar > &Values, size_t &NumEntries) const
Extract a list of entries in a specified local row of the graph. Put into storage allocated by callin...
Definition: Ifpack2_DiagonalFilter_def.hpp:287
DiagonalFilter(const Teuchos::RCP< const Tpetra::RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &Matrix, magnitudeType AbsoluteThreshold, magnitudeType RelativeThreshold)
Constructor.
Definition: Ifpack2_DiagonalFilter_def.hpp:58
virtual size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of entries on this node in the specified local row.
Definition: Ifpack2_DiagonalFilter_def.hpp:204
virtual void getLocalRowView(LocalOrdinal LocalRow, Teuchos::ArrayView< const LocalOrdinal > &indices, Teuchos::ArrayView< const Scalar > &values) const
Extract a const, non-persisting view of local indices in a specified row of the matrix.
Definition: Ifpack2_DiagonalFilter_def.hpp:311
virtual void getLocalDiagCopy(Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const
Get a copy of the diagonal entries owned by this node, with local row indices.
Definition: Ifpack2_DiagonalFilter_def.hpp:319
virtual size_t getNodeNumRows() const
Returns the number of rows owned on the calling node.
Definition: Ifpack2_DiagonalFilter_def.hpp:168
Preconditioners and smoothers for Tpetra sparse matrices.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:72
virtual bool isFillComplete() const
Returns true if fillComplete() has been called.
Definition: Ifpack2_DiagonalFilter_def.hpp:264
virtual Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getColMap() const
Returns the Map that describes the column distribution in this matrix.
Definition: Ifpack2_DiagonalFilter_def.hpp:123
virtual bool isUpperTriangular() const
Indicates whether this matrix is upper triangular.
Definition: Ifpack2_DiagonalFilter_def.hpp:246
virtual void getGlobalRowCopy(GlobalOrdinal GlobalRow, const Teuchos::ArrayView< GlobalOrdinal > &Indices, const Teuchos::ArrayView< Scalar > &Values, size_t &NumEntries) const
Extract a list of entries in a specified global row of this matrix. Put into pre-allocated storage...
Definition: Ifpack2_DiagonalFilter_def.hpp:271
virtual size_t getNodeNumDiags() const
Returns the number of local diagonal entries, based on global row/column index comparisons.
Definition: Ifpack2_DiagonalFilter_def.hpp:216
virtual size_t getNodeNumCols() const
Returns the number of columns needed to apply the forward operator on this node, i.e., the number of elements listed in the column map.
Definition: Ifpack2_DiagonalFilter_def.hpp:174
virtual size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const
Returns the current number of entries on this node in the specified global row.
Definition: Ifpack2_DiagonalFilter_def.hpp:198
virtual bool isLowerTriangular() const
Indicates whether this matrix is lower triangular.
Definition: Ifpack2_DiagonalFilter_def.hpp:240
virtual global_size_t getGlobalNumDiags() const
Returns the number of global diagonal entries, based on global row/column index comparisons.
Definition: Ifpack2_DiagonalFilter_def.hpp:210