Ifpack2 Templated Preconditioning Package  Version 1.0
Ifpack2_SingletonFilter_def.hpp
1 /*@HEADER
2 // ***********************************************************************
3 //
4 // Ifpack2: Templated Object-Oriented Algebraic Preconditioner Package
5 // Copyright (2009) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ***********************************************************************
40 //@HEADER
41 */
42 
43 #ifndef IFPACK2_SINGLETONFILTER_DEF_HPP
44 #define IFPACK2_SINGLETONFILTER_DEF_HPP
45 #include "Ifpack2_SingletonFilter_decl.hpp"
46 
47 #include "Tpetra_ConfigDefs.hpp"
48 #include "Tpetra_RowMatrix.hpp"
49 #include "Tpetra_Map.hpp"
50 #include "Tpetra_MultiVector.hpp"
51 #include "Tpetra_Vector.hpp"
52 
53 namespace Ifpack2 {
54 
55 template<class MatrixType>
56 SingletonFilter<MatrixType>::SingletonFilter(const Teuchos::RCP<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> >& Matrix):
57  A_(Matrix),
58  NumSingletons_(0),
59  NumRows_(0),
60  NumNonzeros_(0),
61  MaxNumEntries_(0),
62  MaxNumEntriesA_(0)
63 {
64 
65  // use this filter only on serial matrices
66  if (A_->getComm()->getSize() != 1 || A_->getNodeNumRows() != A_->getGlobalNumRows()) {
67  throw std::runtime_error("Ifpack2::SingeltonFilter can be used with Comm().getSize() == 1 only. This class is a tool for Ifpack2_AdditiveSchwarz, and it is not meant to be used otherwise.");
68  }
69 
70  // Number of rows in A
71  size_t NumRowsA_ = A_->getNodeNumRows();
72 
73  // tentative value for MaxNumEntries. This is the number of
74  // nonzeros in the local matrix
75  MaxNumEntriesA_ = A_->getNodeMaxNumRowEntries();
76 
77  // ExtractMyRowCopy() will use these vectors
78  Indices_.resize(MaxNumEntriesA_);
79  Values_.resize(MaxNumEntriesA_);
80 
81  // Initialize reordering vector to -1
82  Reorder_.resize(NumRowsA_);
83  Reorder_.assign(Reorder_.size(),-1);
84 
85  // first check how may singletons I do have
86  NumRows_=0;
87  for (size_t i = 0 ; i < NumRowsA_ ; ++i) {
88  size_t Nnz;
89  A_->getLocalRowCopy(i,Indices_,Values_,Nnz);
90  if (Nnz != 1) {
91  Reorder_[i] = NumRows_++;
92  }
93  else {
94  NumSingletons_++;
95  }
96  }
97 
98  // build the inverse reordering
99  InvReorder_.resize(NumRows_);
100  for (size_t i = 0 ; i < NumRowsA_ ; ++i) {
101  if (Reorder_[i] < 0)
102  continue;
103  InvReorder_[Reorder_[i]] = i;
104  }
105  NumEntries_.resize(NumRows_);
106  SingletonIndex_.resize(NumSingletons_);
107 
108 
109  // now compute the nonzeros per row
110  size_t count = 0;
111  for (size_t i = 0 ; i < NumRowsA_ ; ++i) {
112  size_t Nnz;
113  A_->getLocalRowCopy(i,Indices_,Values_,Nnz);
114  LocalOrdinal ii = Reorder_[i];
115  if (ii >= 0) {
116  NumEntries_[ii] = Nnz;
117  NumNonzeros_ += Nnz;
118  if (Nnz > MaxNumEntries_)
119  MaxNumEntries_ = Nnz;
120  }
121  else {
122  SingletonIndex_[count] = i;
123  count++;
124  }
125  }
126 
127  // Build the reduced map. This map should be serial
128  ReducedMap_ = Teuchos::rcp( new Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node>(NumRows_,0,A_->getComm()) );
129 
130  // and finish up with the diagonal entry
131  Diagonal_ = Teuchos::rcp( new Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node>(ReducedMap_) );
132 
133  Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> DiagonalA(A_->getRowMap());
134  A_->getLocalDiagCopy(DiagonalA);
135  const Teuchos::ArrayRCP<const Scalar> & DiagonalAview = DiagonalA.get1dView();
136  for (size_t i = 0 ; i < NumRows_ ; ++i) {
137  LocalOrdinal ii = InvReorder_[i];
138  Diagonal_->replaceLocalValue((LocalOrdinal)i,DiagonalAview[ii]);
139  }
140 }
141 
142 template<class MatrixType>
144 
145 template<class MatrixType>
146 Teuchos::RCP<const Teuchos::Comm<int> >
148 {
149  return A_->getComm();
150 }
151 
152 template<class MatrixType>
153 Teuchos::RCP<typename MatrixType::node_type>
155 {
156  return A_->getNode();
157 }
158 
159 template<class MatrixType>
160 Teuchos::RCP<const Tpetra::Map<typename MatrixType::local_ordinal_type,
161  typename MatrixType::global_ordinal_type,
162  typename MatrixType::node_type> >
164 {
165  return ReducedMap_;
166 }
167 
168 template<class MatrixType>
169 Teuchos::RCP<const Tpetra::Map<typename MatrixType::local_ordinal_type,
170  typename MatrixType::global_ordinal_type,
171  typename MatrixType::node_type> >
173 {
174  return ReducedMap_;
175 }
176 
177 template<class MatrixType>
178 Teuchos::RCP<const Tpetra::Map<typename MatrixType::local_ordinal_type,
179  typename MatrixType::global_ordinal_type,
180  typename MatrixType::node_type> >
182 {
183  return ReducedMap_;
184 }
185 
186 template<class MatrixType>
187 Teuchos::RCP<const Tpetra::Map<typename MatrixType::local_ordinal_type,
188  typename MatrixType::global_ordinal_type,
189  typename MatrixType::node_type> >
191 {
192  return ReducedMap_;
193 }
194 
195 template<class MatrixType>
196 Teuchos::RCP<const Tpetra::RowGraph<typename MatrixType::local_ordinal_type,
197  typename MatrixType::global_ordinal_type,
198  typename MatrixType::node_type> >
200 {
201  throw std::runtime_error("Ifpack2::SingletonFilter: does not support getGraph.");
202 }
203 
204 template<class MatrixType>
206 {
207  return NumRows_;
208 }
209 
210 template<class MatrixType>
212 {
213  return NumRows_;
214 }
215 
216 template<class MatrixType>
218 {
219  return NumRows_;
220 }
221 
222 template<class MatrixType>
224 {
225  return NumRows_;
226 }
227 
228 template<class MatrixType>
229 typename MatrixType::global_ordinal_type SingletonFilter<MatrixType>::getIndexBase() const
230 {
231  return A_->getIndexBase();
232 }
233 
234 template<class MatrixType>
236 {
237  return NumNonzeros_;
238 }
239 
240 template<class MatrixType>
242 {
243  return NumNonzeros_;
244 }
245 
246 template<class MatrixType>
247 size_t SingletonFilter<MatrixType>::getNumEntriesInGlobalRow(GlobalOrdinal /* globalRow */) const
248 {
249  throw std::runtime_error("Ifpack2::SingletonFilter does not implement getNumEntriesInGlobalRow.");
250 }
251 
252 template<class MatrixType>
253 size_t SingletonFilter<MatrixType>::getNumEntriesInLocalRow(LocalOrdinal localRow) const
254 {
255  return NumEntries_[localRow];
256 }
257 
258 template<class MatrixType>
260 {
261  return MaxNumEntries_;
262 }
263 
264 template<class MatrixType>
266 {
267  return MaxNumEntries_;
268 }
269 
270 template<class MatrixType>
272 {
273  return true;
274 }
275 
276 template<class MatrixType>
278 {
279  return A_->isLocallyIndexed();
280 }
281 
282 template<class MatrixType>
284 {
285  return A_->isGloballyIndexed();
286 }
287 
288 template<class MatrixType>
290 {
291  return A_->isFillComplete();
292 }
293 
294 template<class MatrixType>
295 void SingletonFilter<MatrixType>::getGlobalRowCopy(GlobalOrdinal /* GlobalRow */,
296  const Teuchos::ArrayView<GlobalOrdinal> &/* Indices */,
297  const Teuchos::ArrayView<Scalar> &/* Values */,
298  size_t &/* NumEntries */) const
299 {
300  throw std::runtime_error("Ifpack2::SingletonFilter does not implement getGlobalRowCopy.");
301 }
302 
303 template<class MatrixType>
305  const Teuchos::ArrayView<LocalOrdinal> &Indices,
306  const Teuchos::ArrayView<Scalar> &Values,
307  size_t &NumEntries) const
308 {
309  TEUCHOS_TEST_FOR_EXCEPTION((LocalRow < 0 || (size_t) LocalRow >= NumRows_ || (size_t) Indices.size() < NumEntries_[LocalRow]), std::runtime_error, "Ifpack2::SingletonFilter::getLocalRowCopy invalid row or array size.");
310 
311  size_t Nnz;
312  LocalOrdinal ARow = InvReorder_[LocalRow];
313  A_->getLocalRowCopy(ARow,Indices_(),Values_(),Nnz);
314 
315  // populate the user's vectors
316  NumEntries = 0;
317  for (size_t i = 0 ; i < Nnz ; ++i) {
318  LocalOrdinal ii = Reorder_[Indices_[i]];
319  if ( ii >= 0) {
320  Indices[NumEntries] = ii;
321  Values[NumEntries] = Values_[i];
322  NumEntries++;
323  }
324  }
325 
326 }
327 
328 template<class MatrixType>
329 void SingletonFilter<MatrixType>::getGlobalRowView(GlobalOrdinal /* GlobalRow */,
330  Teuchos::ArrayView<const GlobalOrdinal> &/* indices */,
331  Teuchos::ArrayView<const Scalar> &/* values */) const
332 {
333  throw std::runtime_error("Ifpack2::SingletonFilter: does not support getGlobalRowView.");
334 }
335 
336 template<class MatrixType>
337 void SingletonFilter<MatrixType>::getLocalRowView(LocalOrdinal /* LocalRow */,
338  Teuchos::ArrayView<const LocalOrdinal> &/* indices */,
339  Teuchos::ArrayView<const Scalar> &/* values */) const
340 {
341  throw std::runtime_error("Ifpack2::SingletonFilter: does not support getLocalRowView.");
342 }
343 
344 template<class MatrixType>
345 void SingletonFilter<MatrixType>::getLocalDiagCopy(Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &diag) const
346 {
347  // This is somewhat dubious as to how the maps match.
348  return A_->getLocalDiagCopy(diag);
349 }
350 
351 template<class MatrixType>
352 void SingletonFilter<MatrixType>::leftScale(const Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& /* x */)
353 {
354  throw std::runtime_error("Ifpack2::SingletonFilter does not support leftScale.");
355 }
356 
357 template<class MatrixType>
358 void SingletonFilter<MatrixType>::rightScale(const Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& /* x */)
359 {
360  throw std::runtime_error("Ifpack2::SingletonFilter does not support rightScale.");
361 }
362 
363 template<class MatrixType>
364 void SingletonFilter<MatrixType>::apply(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &X,
365  Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &Y,
366  Teuchos::ETransp mode,
367  Scalar /* alpha */,
368  Scalar /* beta */) const
369 {
370  typedef Scalar DomainScalar;
371  typedef Scalar RangeScalar;
372 
373  // Note: This isn't AztecOO compliant. But neither was Ifpack's version.
374 
375  TEUCHOS_TEST_FOR_EXCEPTION(X.getNumVectors() != Y.getNumVectors(), std::runtime_error,
376  "Ifpack2::SingletonFilter::apply ERROR: X.getNumVectors() != Y.getNumVectors().");
377 
378  RangeScalar zero = Teuchos::ScalarTraits<RangeScalar>::zero();
379  Teuchos::ArrayRCP<Teuchos::ArrayRCP<const DomainScalar> > x_ptr = X.get2dView();
380  Teuchos::ArrayRCP<Teuchos::ArrayRCP<RangeScalar> > y_ptr = Y.get2dViewNonConst();
381 
382  Y.putScalar(zero);
383  size_t NumVectors = Y.getNumVectors();
384 
385 
386  for (size_t i = 0 ; i < NumRows_ ; ++i) {
387  size_t Nnz;
388  // Use this class's getrow to make the below code simpler
389  getLocalRowCopy(i,Indices_(),Values_(),Nnz);
390  if (mode==Teuchos::NO_TRANS){
391  for (size_t j = 0 ; j < Nnz ; ++j)
392  for (size_t k = 0 ; k < NumVectors ; ++k)
393  y_ptr[k][i] += (RangeScalar)Values_[j] * (RangeScalar)x_ptr[k][Indices_[j]];
394  }
395  else if (mode==Teuchos::TRANS){
396  for (size_t j = 0 ; j < Nnz ; ++j)
397  for (size_t k = 0 ; k < NumVectors ; ++k)
398  y_ptr[k][Indices_[j]] += (RangeScalar)Values_[j] * (RangeScalar)x_ptr[k][i];
399  }
400  else { //mode==Teuchos::CONJ_TRANS
401  for (size_t j = 0 ; j < Nnz ; ++j)
402  for (size_t k = 0 ; k < NumVectors ; ++k)
403  y_ptr[k][Indices_[j]] += Teuchos::ScalarTraits<RangeScalar>::conjugate((RangeScalar)Values_[j]) * (RangeScalar)x_ptr[k][i];
404  }
405  }
406 }
407 
408 template<class MatrixType>
410 {
411  return true;
412 }
413 
414 template<class MatrixType>
416 {
417  return false;
418 }
419 
420 template<class MatrixType>
421 void SingletonFilter<MatrixType>::SolveSingletons(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& RHS,
422  Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& LHS)
423 {
424  this->template SolveSingletonsTempl<Scalar,Scalar>(RHS, LHS);
425 }
426 
427 template<class MatrixType>
428 template<class DomainScalar, class RangeScalar>
429 void SingletonFilter<MatrixType>::SolveSingletonsTempl(const Tpetra::MultiVector<DomainScalar,LocalOrdinal,GlobalOrdinal,Node>& RHS,
430  Tpetra::MultiVector<RangeScalar,LocalOrdinal,GlobalOrdinal,Node>& LHS)
431 {
432  Teuchos::ArrayRCP<Teuchos::ArrayRCP<const DomainScalar> > RHS_ptr = RHS.get2dView();
433  Teuchos::ArrayRCP<Teuchos::ArrayRCP<RangeScalar> > LHS_ptr = LHS.get2dViewNonConst();
434 
435  for (size_t i = 0 ; i < NumSingletons_ ; ++i) {
436  LocalOrdinal ii = SingletonIndex_[i];
437  // get the diagonal value for the singleton
438  size_t Nnz;
439  A_->getLocalRowCopy(ii,Indices_(),Values_(),Nnz);
440  for (size_t j = 0 ; j < Nnz ; ++j) {
441  if (Indices_[j] == ii) {
442  for (size_t k = 0 ; k < LHS.getNumVectors() ; ++k)
443  LHS_ptr[k][ii] = (RangeScalar)RHS_ptr[k][ii] / (RangeScalar)Values_[j];
444  }
445  }
446  }
447 }
448 
449 template<class MatrixType>
450 void SingletonFilter<MatrixType>::CreateReducedRHS(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& LHS,
451  const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& RHS,
452  Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& ReducedRHS)
453 {
454  this->template CreateReducedRHSTempl<Scalar,Scalar>(LHS, RHS, ReducedRHS);
455 }
456 
457 template<class MatrixType>
458 template<class DomainScalar, class RangeScalar>
459 void SingletonFilter<MatrixType>::CreateReducedRHSTempl(const Tpetra::MultiVector<DomainScalar,LocalOrdinal,GlobalOrdinal,Node>& LHS,
460  const Tpetra::MultiVector<RangeScalar,LocalOrdinal,GlobalOrdinal,Node>& RHS,
461  Tpetra::MultiVector<RangeScalar,LocalOrdinal,GlobalOrdinal,Node>& ReducedRHS)
462 {
463  Teuchos::ArrayRCP<Teuchos::ArrayRCP<const RangeScalar > > RHS_ptr = RHS.get2dView();
464  Teuchos::ArrayRCP<Teuchos::ArrayRCP<const DomainScalar> > LHS_ptr = LHS.get2dView();
465  Teuchos::ArrayRCP<Teuchos::ArrayRCP<RangeScalar> > ReducedRHS_ptr = ReducedRHS.get2dViewNonConst();
466 
467  size_t NumVectors = LHS.getNumVectors();
468 
469  for (size_t i = 0 ; i < NumRows_ ; ++i)
470  for (size_t k = 0 ; k < NumVectors ; ++k)
471  ReducedRHS_ptr[k][i] = RHS_ptr[k][InvReorder_[i]];
472 
473  for (size_t i = 0 ; i < NumRows_ ; ++i) {
474  LocalOrdinal ii = InvReorder_[i];
475  size_t Nnz;
476  A_->getLocalRowCopy(ii,Indices_(),Values_(),Nnz);
477 
478  for (size_t j = 0 ; j < Nnz ; ++j) {
479  if (Reorder_[Indices_[j]] == -1) {
480  for (size_t k = 0 ; k < NumVectors ; ++k)
481  ReducedRHS_ptr[k][i] -= (RangeScalar)Values_[j] * (RangeScalar)LHS_ptr[k][Indices_[j]];
482  }
483  }
484  }
485 }
486 
487 template<class MatrixType>
488 void SingletonFilter<MatrixType>::UpdateLHS(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& ReducedLHS,
489  Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& LHS)
490 {
491  this->template UpdateLHSTempl<Scalar,Scalar>(ReducedLHS, LHS);
492 }
493 
494 template<class MatrixType>
495 template<class DomainScalar, class RangeScalar>
496 void SingletonFilter<MatrixType>::UpdateLHSTempl(const Tpetra::MultiVector<DomainScalar,LocalOrdinal,GlobalOrdinal,Node>& ReducedLHS,
497  Tpetra::MultiVector<RangeScalar,LocalOrdinal,GlobalOrdinal,Node>& LHS)
498 {
499 
500  Teuchos::ArrayRCP<Teuchos::ArrayRCP<RangeScalar> > LHS_ptr = LHS.get2dViewNonConst();
501  Teuchos::ArrayRCP<Teuchos::ArrayRCP<const DomainScalar> > ReducedLHS_ptr = ReducedLHS.get2dView();
502 
503  for (size_t i = 0 ; i < NumRows_ ; ++i)
504  for (size_t k = 0 ; k < LHS.getNumVectors() ; ++k)
505  LHS_ptr[k][InvReorder_[i]] = (RangeScalar)ReducedLHS_ptr[k][i];
506 }
507 
508 template<class MatrixType>
509 typename SingletonFilter<MatrixType>::mag_type SingletonFilter<MatrixType>::getFrobeniusNorm() const
510 {
511  throw std::runtime_error("Ifpack2::SingletonFilter does not implement getFrobeniusNorm.");
512 }
513 
514 } // namespace Ifpack2
515 
516 #define IFPACK2_SINGLETONFILTER_INSTANT(S,LO,GO,N) \
517  template class Ifpack2::SingletonFilter< Tpetra::RowMatrix<S, LO, GO, N> >;
518 
519 #endif
virtual void rightScale(const Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
Scales the RowMatrix on the right with the Vector x.
Definition: Ifpack2_SingletonFilter_def.hpp:358
virtual ~SingletonFilter()
Destructor.
Definition: Ifpack2_SingletonFilter_def.hpp:143
virtual bool isLocallyIndexed() const
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
Definition: Ifpack2_SingletonFilter_def.hpp:277
virtual global_size_t getGlobalNumRows() const
Returns the number of global rows in this matrix.
Definition: Ifpack2_SingletonFilter_def.hpp:205
virtual size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
Definition: Ifpack2_SingletonFilter_def.hpp:259
virtual Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const
Returns the Map that describes the range distribution in this matrix.
Definition: Ifpack2_SingletonFilter_def.hpp:190
virtual void UpdateLHS(const Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &ReducedLHS, Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &LHS)
Updates a full LHS from a reduces LHS.
Definition: Ifpack2_SingletonFilter_def.hpp:488
virtual void CreateReducedRHS(const Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &LHS, const Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &RHS, Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &ReducedRHS)
Creates a RHS for the reduced singleton-free system.
Definition: Ifpack2_SingletonFilter_def.hpp:450
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_SingletonFilter_def.hpp:329
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_SingletonFilter_def.hpp:304
virtual Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getDomainMap() const
Returns the Map that describes the domain distribution in this matrix.
Definition: Ifpack2_SingletonFilter_def.hpp:181
virtual Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const
Returns the Map that describes the row distribution in this matrix.
Definition: Ifpack2_SingletonFilter_def.hpp:163
virtual size_t getNodeNumRows() const
Returns the number of rows owned on the calling node.
Definition: Ifpack2_SingletonFilter_def.hpp:217
virtual bool hasTransposeApply() const
Indicates whether this operator supports applying the adjoint operator.
Definition: Ifpack2_SingletonFilter_def.hpp:409
virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Returns the communicator.
Definition: Ifpack2_SingletonFilter_def.hpp:147
virtual mag_type getFrobeniusNorm() const
Returns the Frobenius norm of the matrix.
Definition: Ifpack2_SingletonFilter_def.hpp:509
virtual size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const
Returns the current number of entries on this node in the specified global row.
Definition: Ifpack2_SingletonFilter_def.hpp:247
virtual size_t getNodeNumEntries() const
Returns the local number of entries in this matrix.
Definition: Ifpack2_SingletonFilter_def.hpp:241
virtual global_size_t getGlobalNumCols() const
Returns the number of global columns in this matrix.
Definition: Ifpack2_SingletonFilter_def.hpp:211
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_SingletonFilter_def.hpp:364
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_SingletonFilter_def.hpp:345
virtual bool hasColMap() const
Indicates whether this matrix has a well-defined column map.
Definition: Ifpack2_SingletonFilter_def.hpp:271
virtual Teuchos::RCP< const Tpetra::RowGraph< LocalOrdinal, GlobalOrdinal, Node > > getGraph() const
Returns the RowGraph associated with this matrix.
Definition: Ifpack2_SingletonFilter_def.hpp:199
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_SingletonFilter_def.hpp:223
SingletonFilter(const Teuchos::RCP< const Tpetra::RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &Matrix)
Constructor.
Definition: Ifpack2_SingletonFilter_def.hpp:56
virtual Teuchos::RCP< Node > getNode() const
Returns the underlying node.
Definition: Ifpack2_SingletonFilter_def.hpp:154
virtual size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of entries on this node in the specified local row.
Definition: Ifpack2_SingletonFilter_def.hpp:253
virtual void SolveSingletons(const Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &RHS, Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &LHS)
Solve the singleton components of the linear system.
Definition: Ifpack2_SingletonFilter_def.hpp:421
virtual bool supportsRowViews() const
Returns true if RowViews are supported.
Definition: Ifpack2_SingletonFilter_def.hpp:415
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_SingletonFilter_def.hpp:337
Preconditioners and smoothers for Tpetra sparse matrices.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:72
virtual Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getColMap() const
Returns the Map that describes the column distribution in this matrix.
Definition: Ifpack2_SingletonFilter_def.hpp:172
Filter based on matrix entries.
Definition: Ifpack2_SingletonFilter_decl.hpp:64
virtual void leftScale(const Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
Scales the RowMatrix on the left with the Vector x.
Definition: Ifpack2_SingletonFilter_def.hpp:352
virtual bool isFillComplete() const
Returns true if fillComplete() has been called.
Definition: Ifpack2_SingletonFilter_def.hpp:289
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_SingletonFilter_def.hpp:295
virtual size_t getNodeMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
Definition: Ifpack2_SingletonFilter_def.hpp:265
virtual global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
Definition: Ifpack2_SingletonFilter_def.hpp:235
virtual GlobalOrdinal getIndexBase() const
Returns the index base for global indices for this matrix.
Definition: Ifpack2_SingletonFilter_def.hpp:229
virtual bool isGloballyIndexed() const
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
Definition: Ifpack2_SingletonFilter_def.hpp:283