10 #ifndef IFPACK2_DIAGONALFILTER_DEF_HPP
11 #define IFPACK2_DIAGONALFILTER_DEF_HPP
12 #include "Ifpack2_DiagonalFilter_decl.hpp"
15 #include "Teuchos_Comm.hpp"
16 #include "Tpetra_Map.hpp"
17 #include "Tpetra_MultiVector.hpp"
18 #include "Tpetra_Vector.hpp"
23 template<
class MatrixType>
29 AbsoluteThreshold_(AbsoluteThreshold),
30 RelativeThreshold_(RelativeThreshold)
33 val_=
Teuchos::rcp(
new Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node>(A_->getRowMap()));
43 A_->getLocalRowCopy(MyRow,Indices,Values,NumEntries);
45 for (
size_t i = 0 ; i < NumEntries ; ++i) {
46 if ((
size_t)Indices[i] == MyRow) {
54 val_->replaceLocalValue (MyRow, Values[i] * (RelativeThreshold_ - 1) +
55 AbsoluteThreshold_ * mysign);
62 template<
class MatrixType>
65 template<
class MatrixType>
72 template<
class MatrixType>
73 Teuchos::RCP<
const Tpetra::Map<
typename MatrixType::local_ordinal_type,
74 typename MatrixType::global_ordinal_type,
75 typename MatrixType::node_type> >
78 return A_->getRowMap();
81 template<
class MatrixType>
82 Teuchos::RCP<
const Tpetra::Map<
typename MatrixType::local_ordinal_type,
83 typename MatrixType::global_ordinal_type,
84 typename MatrixType::node_type> >
87 return A_->getColMap();
90 template<
class MatrixType>
91 Teuchos::RCP<
const Tpetra::Map<
typename MatrixType::local_ordinal_type,
92 typename MatrixType::global_ordinal_type,
93 typename MatrixType::node_type> >
96 return A_->getDomainMap();
99 template<
class MatrixType>
100 Teuchos::RCP<
const Tpetra::Map<
typename MatrixType::local_ordinal_type,
101 typename MatrixType::global_ordinal_type,
102 typename MatrixType::node_type> >
105 return A_->getRangeMap();
108 template<
class MatrixType>
109 Teuchos::RCP<
const Tpetra::RowGraph<
typename MatrixType::local_ordinal_type,
110 typename MatrixType::global_ordinal_type,
111 typename MatrixType::node_type> >
114 return A_->getGraph();
117 template<
class MatrixType>
120 return A_->getGlobalNumRows();
123 template<
class MatrixType>
126 return A_->getGlobalNumCols();
129 template<
class MatrixType>
132 return A_->getLocalNumRows();
135 template<
class MatrixType>
138 return A_->getLocalNumCols();
141 template<
class MatrixType>
144 return A_->getIndexBase();
147 template<
class MatrixType>
150 return A_->getGlobalNumEntries();
153 template<
class MatrixType>
156 return A_->getLocalNumEntries();
159 template<
class MatrixType>
162 return A_->getNumEntriesInGlobalRow(globalRow);
165 template<
class MatrixType>
168 return A_->getNumEntriesInLocalRow(localRow);
171 template<
class MatrixType>
174 return A_->getGlobalMaxNumRowEntries();
177 template<
class MatrixType>
180 return A_->getLocalMaxNumRowEntries();
183 template<
class MatrixType>
186 return A_->getBlockSize();
189 template<
class MatrixType>
192 return A_->hasColMap();
195 template<
class MatrixType>
198 return A_->isLocallyIndexed();
201 template<
class MatrixType>
204 return A_->isGloballyIndexed();
207 template<
class MatrixType>
210 return A_->isFillComplete();
213 template<
class MatrixType>
216 nonconst_global_inds_host_view_type &Indices,
217 nonconst_values_host_view_type &Values,
218 size_t& NumEntries)
const
222 LocalOrdinal LocalRow=getRowMap()->getLocalElement(GlobalRow);
224 A_->getGlobalRowCopy(GlobalRow, Indices,Values,NumEntries);
226 if (pos_[LocalRow] != -1)
227 Values[pos_[LocalRow]] += myvals[LocalRow];
231 template<
class MatrixType>
234 nonconst_local_inds_host_view_type &Indices,
235 nonconst_values_host_view_type &Values,
236 size_t& NumEntries)
const
240 A_->getLocalRowCopy(LocalRow, Indices,Values,NumEntries);
242 if (pos_[LocalRow] != -1)
243 Values[pos_[LocalRow]] += myvals[LocalRow];
247 template<
class MatrixType>
249 global_inds_host_view_type &,
250 values_host_view_type &)
const
252 throw std::runtime_error(
"Ifpack2::DiagonalFilter: does not support getGlobalRowView.");
256 template<
class MatrixType>
258 local_inds_host_view_type & ,
259 values_host_view_type & )
const
261 throw std::runtime_error(
"Ifpack2::DiagonalFilter: does not support getLocalRowView.");
265 template<
class MatrixType>
270 return A_->getLocalDiagCopy(diag);
273 template<
class MatrixType>
276 throw std::runtime_error(
"Ifpack2::DiagonalFilter does not support leftScale.");
279 template<
class MatrixType>
282 throw std::runtime_error(
"Ifpack2::DiagonalFilter does not support rightScale.");
285 template<
class MatrixType>
287 apply (
const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &X,
288 Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &Y,
297 A_->apply(X,Y,mode,alpha,beta);
298 Y.elementWiseMultiply(one,*val_,X,one);
301 template<
class MatrixType>
304 return A_->hasTransposeApply();
307 template<
class MatrixType>
313 template<
class MatrixType>
316 throw std::runtime_error(
"Ifpack2::DiagonalFilter does not implement getFrobeniusNorm.");
321 #define IFPACK2_DIAGONALFILTER_INSTANT(S,LO,GO,N) \
322 template class Ifpack2::DiagonalFilter< Tpetra::RowMatrix<S, LO, GO, N> >;
virtual mag_type getFrobeniusNorm() const
Returns the Frobenius norm of the matrix.
Definition: Ifpack2_DiagonalFilter_def.hpp:314
virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Returns the communicator.
Definition: Ifpack2_DiagonalFilter_def.hpp:66
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:287
virtual global_size_t getGlobalNumRows() const
Returns the number of global rows in this matrix.
Definition: Ifpack2_DiagonalFilter_def.hpp:118
virtual global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
Definition: Ifpack2_DiagonalFilter_def.hpp:148
virtual void getGlobalRowCopy(GlobalOrdinal GlobalRow, nonconst_global_inds_host_view_type &Indices, nonconst_values_host_view_type &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:215
virtual LocalOrdinal getBlockSize() const
The number of degrees of freedom per mesh point.
Definition: Ifpack2_DiagonalFilter_def.hpp:184
virtual ~DiagonalFilter()
Destructor.
Definition: Ifpack2_DiagonalFilter_def.hpp:63
virtual size_t getLocalNumEntries() const
Returns the local number of entries in this matrix.
Definition: Ifpack2_DiagonalFilter_def.hpp:154
virtual size_t getLocalNumCols() 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:136
virtual bool hasTransposeApply() const
Indicates whether this operator supports applying the adjoint operator.
Definition: Ifpack2_DiagonalFilter_def.hpp:302
virtual size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
Definition: Ifpack2_DiagonalFilter_def.hpp:172
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
virtual GlobalOrdinal getIndexBase() const
Returns the index base for global indices for this matrix.
Definition: Ifpack2_DiagonalFilter_def.hpp:142
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:202
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:274
virtual void getLocalRowCopy(LocalOrdinal LocalRow, nonconst_local_inds_host_view_type &Indices, nonconst_values_host_view_type &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:233
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:76
virtual bool hasColMap() const
Indicates whether this matrix has a well-defined column map.
Definition: Ifpack2_DiagonalFilter_def.hpp:190
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:280
virtual size_t getLocalNumRows() const
Returns the number of rows owned on the calling node.
Definition: Ifpack2_DiagonalFilter_def.hpp:130
virtual Teuchos::RCP< const Tpetra::RowGraph< LocalOrdinal, GlobalOrdinal, Node > > getGraph() const
Returns the RowGraph associated with this matrix.
Definition: Ifpack2_DiagonalFilter_def.hpp:112
virtual bool isFillComplete() const
Returns true if fillComplete() has been called.
Definition: Ifpack2_DiagonalFilter_def.hpp:208
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:266
virtual void getGlobalRowView(GlobalOrdinal GlobalRow, global_inds_host_view_type &indices, values_host_view_type &values) const
Extract a const, non-persisting view of global indices in a specified row of the matrix.
Definition: Ifpack2_DiagonalFilter_def.hpp:248
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:196
DiagonalFilter(const Teuchos::RCP< const Tpetra::RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &Matrix, magnitudeType AbsoluteThreshold, magnitudeType RelativeThreshold)
Constructor.
Definition: Ifpack2_DiagonalFilter_def.hpp:25
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:103
virtual global_size_t getGlobalNumCols() const
Returns the number of global columns in this matrix.
Definition: Ifpack2_DiagonalFilter_def.hpp:124
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:94
virtual size_t getLocalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
Definition: Ifpack2_DiagonalFilter_def.hpp:178
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:85
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:160
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:166
virtual bool supportsRowViews() const
Returns true if RowViews are supported.
Definition: Ifpack2_DiagonalFilter_def.hpp:308
virtual void getLocalRowView(LocalOrdinal LocalRow, local_inds_host_view_type &indices, values_host_view_type &values) const
Extract a const, non-persisting view of local indices in a specified row of the matrix.
Definition: Ifpack2_DiagonalFilter_def.hpp:257