Ifpack2 Templated Preconditioning Package  Version 1.0
Ifpack2_SingletonFilter_def.hpp
1 /*@HEADER
2 // ***********************************************************************
3 //
4 // Ifpack2: Tempated 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 //==========================================================================
56 template<class MatrixType>
57 SingletonFilter<MatrixType>::SingletonFilter(const Teuchos::RCP<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> >& Matrix):
58  A_(Matrix),
59  NumSingletons_(0),
60  NumRows_(0),
61  NumNonzeros_(0),
62  MaxNumEntries_(0),
63  MaxNumEntriesA_(0)
64 {
65 
66  // use this filter only on serial matrices
67  if (A_->getComm()->getSize() != 1 || A_->getNodeNumRows() != A_->getGlobalNumRows()) {
68  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.");
69  }
70 
71  // Number of rows in A
72  size_t NumRowsA_ = A_->getNodeNumRows();
73 
74  // tentative value for MaxNumEntries. This is the number of
75  // nonzeros in the local matrix
76  MaxNumEntriesA_ = A_->getNodeMaxNumRowEntries();
77 
78  // ExtractMyRowCopy() will use these vectors
79  Indices_.resize(MaxNumEntriesA_);
80  Values_.resize(MaxNumEntriesA_);
81 
82  // Initialize reordering vector to -1
83  Reorder_.resize(NumRowsA_);
84  Reorder_.assign(Reorder_.size(),-1);
85 
86  // first check how may singletons I do have
87  NumRows_=0;
88  for (size_t i = 0 ; i < NumRowsA_ ; ++i) {
89  size_t Nnz;
90  A_->getLocalRowCopy(i,Indices_,Values_,Nnz);
91  if (Nnz != 1) {
92  Reorder_[i] = NumRows_++;
93  }
94  else {
95  NumSingletons_++;
96  }
97  }
98 
99  // build the inverse reordering
100  InvReorder_.resize(NumRows_);
101  for (size_t i = 0 ; i < NumRowsA_ ; ++i) {
102  if (Reorder_[i] < 0)
103  continue;
104  InvReorder_[Reorder_[i]] = i;
105  }
106  NumEntries_.resize(NumRows_);
107  SingletonIndex_.resize(NumSingletons_);
108 
109 
110  // now compute the nonzeros per row
111  size_t count = 0;
112  for (size_t i = 0 ; i < NumRowsA_ ; ++i) {
113  size_t Nnz;
114  A_->getLocalRowCopy(i,Indices_,Values_,Nnz);
115  LocalOrdinal ii = Reorder_[i];
116  if (ii >= 0) {
117  NumEntries_[ii] = Nnz;
118  NumNonzeros_ += Nnz;
119  if (Nnz > MaxNumEntries_)
120  MaxNumEntries_ = Nnz;
121  }
122  else {
123  SingletonIndex_[count] = i;
124  count++;
125  }
126  }
127 
128  // Build the reduced map. This map should be serial
129  ReducedMap_ = Teuchos::rcp( new Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node>(NumRows_,0,A_->getComm()) );
130 
131  // and finish up with the diagonal entry
132  Diagonal_ = Teuchos::rcp( new Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node>(ReducedMap_) );
133 
134  Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> DiagonalA(A_->getRowMap());
135  A_->getLocalDiagCopy(DiagonalA);
136  const Teuchos::ArrayRCP<const Scalar> & DiagonalAview = DiagonalA.get1dView();
137  for (size_t i = 0 ; i < NumRows_ ; ++i) {
138  LocalOrdinal ii = InvReorder_[i];
139  Diagonal_->replaceLocalValue((LocalOrdinal)i,DiagonalAview[ii]);
140  }
141 }
142 
143 //=========================================================================
144 template<class MatrixType>
146 
147 //==========================================================================
148 template<class MatrixType>
151 {
152  return A_->getComm();
153 }
154 
155 //==========================================================================
156 template<class MatrixType>
159 {
160  return A_->getNode();
161 }
162 
163 //==========================================================================
164 template<class MatrixType>
165 Teuchos::RCP<const Tpetra::Map<typename MatrixType::local_ordinal_type,
166  typename MatrixType::global_ordinal_type,
167  typename MatrixType::node_type> >
169 {
170  return ReducedMap_;
171 }
172 
173 //==========================================================================
174 template<class MatrixType>
175 Teuchos::RCP<const Tpetra::Map<typename MatrixType::local_ordinal_type,
176  typename MatrixType::global_ordinal_type,
177  typename MatrixType::node_type> >
179 {
180  return ReducedMap_;
181 }
182 
183 //==========================================================================
184 template<class MatrixType>
185 Teuchos::RCP<const Tpetra::Map<typename MatrixType::local_ordinal_type,
186  typename MatrixType::global_ordinal_type,
187  typename MatrixType::node_type> >
189 {
190  return ReducedMap_;
191 }
192 
193 //==========================================================================
194 template<class MatrixType>
195 Teuchos::RCP<const Tpetra::Map<typename MatrixType::local_ordinal_type,
196  typename MatrixType::global_ordinal_type,
197  typename MatrixType::node_type> >
199 {
200  return ReducedMap_;
201 }
202 
203 //==========================================================================
204 template<class MatrixType>
205 Teuchos::RCP<const Tpetra::RowGraph<typename MatrixType::local_ordinal_type,
206  typename MatrixType::global_ordinal_type,
207  typename MatrixType::node_type> >
209 {
210  throw std::runtime_error("Ifpack2::SingletonFilter: does not support getGraph.");
211 }
212 
213 //==========================================================================
214 template<class MatrixType>
216 {
217  return NumRows_;
218 }
219 
220 //==========================================================================
221 template<class MatrixType>
223 {
224  return NumRows_;
225 }
226 
227 //==========================================================================
228 template<class MatrixType>
230 {
231  return NumRows_;
232 }
233 
234 //==========================================================================
235 
236 template<class MatrixType>
238 {
239  return NumRows_;
240 }
241 
242 //==========================================================================
243 template<class MatrixType>
244 typename MatrixType::global_ordinal_type SingletonFilter<MatrixType>::getIndexBase() const
245 {
246  return A_->getIndexBase();
247 }
248 
249 //==========================================================================
250 template<class MatrixType>
252 {
253  return NumNonzeros_;
254 }
255 
256 //==========================================================================
257 template<class MatrixType>
259 {
260  return NumNonzeros_;
261 }
262 
263 //==========================================================================
264 template<class MatrixType>
265 size_t SingletonFilter<MatrixType>::getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const
266 {
267  throw std::runtime_error("Ifpack2::SingletonFilter does not implement getNumEntriesInGlobalRow.");
268 }
269 
270 //==========================================================================
271 template<class MatrixType>
272 size_t SingletonFilter<MatrixType>::getNumEntriesInLocalRow(LocalOrdinal localRow) const
273 {
274  return NumEntries_[localRow];
275 }
276 
277 //==========================================================================
278 template<class MatrixType>
280 {
281  return A_->getGlobalNumDiags();
282 }
283 
284 //==========================================================================
285 template<class MatrixType>
287 {
288  return A_->getNodeNumDiags();
289 }
290 
291 //==========================================================================
292 template<class MatrixType>
294 {
295  return MaxNumEntries_;
296 }
297 
298 //==========================================================================
299 template<class MatrixType>
301 {
302  return MaxNumEntries_;
303 }
304 
305 //==========================================================================
306 template<class MatrixType>
308 {
309  return true;
310 }
311 
312 //==========================================================================
313 template<class MatrixType>
315 {
316  return A_->isLowerTriangular();
317 }
318 
319 //==========================================================================
320 template<class MatrixType>
322 {
323  return A_->isUpperTriangular();
324 }
325 
326 //==========================================================================
327 template<class MatrixType>
329 {
330  return A_->isLocallyIndexed();
331 }
332 
333 //==========================================================================
334 template<class MatrixType>
336 {
337  return A_->isGloballyIndexed();
338 }
339 
340 //==========================================================================
341 template<class MatrixType>
343 {
344  return A_->isFillComplete();
345 }
346 
347 //==========================================================================
348 template<class MatrixType>
350  const Teuchos::ArrayView<GlobalOrdinal> &Indices,
351  const Teuchos::ArrayView<Scalar> &Values,
352  size_t &NumEntries) const
353 {
354  throw std::runtime_error("Ifpack2::SingletonFilter does not implement getGlobalRowCopy.");
355 }
356 
357 //==========================================================================
358 template<class MatrixType>
360  const Teuchos::ArrayView<LocalOrdinal> &Indices,
361  const Teuchos::ArrayView<Scalar> &Values,
362  size_t &NumEntries) const
363 {
364  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.");
365 
366  size_t Nnz;
367  LocalOrdinal ARow = InvReorder_[LocalRow];
368  A_->getLocalRowCopy(ARow,Indices_(),Values_(),Nnz);
369 
370  // populate the user's vectors
371  NumEntries = 0;
372  for (size_t i = 0 ; i < Nnz ; ++i) {
373  LocalOrdinal ii = Reorder_[Indices_[i]];
374  if ( ii >= 0) {
375  Indices[NumEntries] = ii;
376  Values[NumEntries] = Values_[i];
377  NumEntries++;
378  }
379  }
380 
381 }
382 
383 //==========================================================================
384 template<class MatrixType>
387  Teuchos::ArrayView<const Scalar> &values) const
388 {
389  throw std::runtime_error("Ifpack2::SingletonFilter: does not support getGlobalRowView.");
390 }
391 
392 //==========================================================================
393 template<class MatrixType>
396  Teuchos::ArrayView<const Scalar> &values) const
397 {
398  throw std::runtime_error("Ifpack2::SingletonFilter: does not support getLocalRowView.");
399 }
400 
401 //==========================================================================
402 template<class MatrixType>
403 void SingletonFilter<MatrixType>::getLocalDiagCopy(Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &diag) const
404 {
405  // This is somewhat dubious as to how the maps match.
406  return A_->getLocalDiagCopy(diag);
407 }
408 
409 //==========================================================================
410 template<class MatrixType>
411 void SingletonFilter<MatrixType>::leftScale(const Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& x)
412 {
413  throw std::runtime_error("Ifpack2::SingletonFilter does not support leftScale.");
414 }
415 
416 //==========================================================================
417 template<class MatrixType>
418 void SingletonFilter<MatrixType>::rightScale(const Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& x)
419 {
420  throw std::runtime_error("Ifpack2::SingletonFilter does not support rightScale.");
421 }
422 
423 //==========================================================================
424 template<class MatrixType>
425 void SingletonFilter<MatrixType>::apply(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &X,
426  Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &Y,
427  Teuchos::ETransp mode,
428  Scalar alpha,
429  Scalar beta) const
430 {
431  typedef Scalar DomainScalar;
432  typedef Scalar RangeScalar;
433 
434  // Note: This isn't AztecOO compliant. But neither was Ifpack's version.
435 
436  TEUCHOS_TEST_FOR_EXCEPTION(X.getNumVectors() != Y.getNumVectors(), std::runtime_error,
437  "Ifpack2::SingletonFilter::apply ERROR: X.getNumVectors() != Y.getNumVectors().");
438 
441  Teuchos::ArrayRCP<Teuchos::ArrayRCP<RangeScalar> > y_ptr = Y.get2dViewNonConst();
442 
443  Y.putScalar(zero);
444  size_t NumVectors = Y.getNumVectors();
445 
446 
447  for (size_t i = 0 ; i < NumRows_ ; ++i) {
448  size_t Nnz;
449  // Use this class's getrow to make the below code simpler
450  getLocalRowCopy(i,Indices_(),Values_(),Nnz);
451  if (mode==Teuchos::NO_TRANS){
452  for (size_t j = 0 ; j < Nnz ; ++j)
453  for (size_t k = 0 ; k < NumVectors ; ++k)
454  y_ptr[k][i] += (RangeScalar)Values_[j] * (RangeScalar)x_ptr[k][Indices_[j]];
455  }
456  else if (mode==Teuchos::TRANS){
457  for (size_t j = 0 ; j < Nnz ; ++j)
458  for (size_t k = 0 ; k < NumVectors ; ++k)
459  y_ptr[k][Indices_[j]] += (RangeScalar)Values_[j] * (RangeScalar)x_ptr[k][i];
460  }
461  else { //mode==Teuchos::CONJ_TRANS
462  for (size_t j = 0 ; j < Nnz ; ++j)
463  for (size_t k = 0 ; k < NumVectors ; ++k)
464  y_ptr[k][Indices_[j]] += Teuchos::ScalarTraits<RangeScalar>::conjugate((RangeScalar)Values_[j]) * (RangeScalar)x_ptr[k][i];
465  }
466  }
467 }
468 
469 
470 //==========================================================================
471 template<class MatrixType>
473 {
474  return true;
475 }
476 
477 //==========================================================================
478 template<class MatrixType>
480 {
481  return false;
482 }
483 
484 //==============================================================================
485 template<class MatrixType>
486 void SingletonFilter<MatrixType>::SolveSingletons(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& RHS,
487  Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& LHS)
488 {
489  this->template SolveSingletonsTempl<Scalar,Scalar>(RHS, LHS);
490 }
491 
492 //==============================================================================
493 template<class MatrixType>
494 template<class DomainScalar, class RangeScalar>
495 void SingletonFilter<MatrixType>::SolveSingletonsTempl(const Tpetra::MultiVector<DomainScalar,LocalOrdinal,GlobalOrdinal,Node>& RHS,
496  Tpetra::MultiVector<RangeScalar,LocalOrdinal,GlobalOrdinal,Node>& LHS)
497 {
499  Teuchos::ArrayRCP<Teuchos::ArrayRCP<RangeScalar> > LHS_ptr = LHS.get2dViewNonConst();
500 
501  for (size_t i = 0 ; i < NumSingletons_ ; ++i) {
502  LocalOrdinal ii = SingletonIndex_[i];
503  // get the diagonal value for the singleton
504  size_t Nnz;
505  A_->getLocalRowCopy(ii,Indices_(),Values_(),Nnz);
506  for (size_t j = 0 ; j < Nnz ; ++j) {
507  if (Indices_[j] == ii) {
508  for (size_t k = 0 ; k < LHS.getNumVectors() ; ++k)
509  LHS_ptr[k][ii] = (RangeScalar)RHS_ptr[k][ii] / (RangeScalar)Values_[j];
510  }
511  }
512  }
513 }
514 
515 //==============================================================================
516 template<class MatrixType>
517 void SingletonFilter<MatrixType>::CreateReducedRHS(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& LHS,
518  const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& RHS,
519  Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& ReducedRHS)
520 {
521  this->template CreateReducedRHSTempl<Scalar,Scalar>(LHS, RHS, ReducedRHS);
522 }
523 
524 //==============================================================================
525 template<class MatrixType>
526 template<class DomainScalar, class RangeScalar>
527 void SingletonFilter<MatrixType>::CreateReducedRHSTempl(const Tpetra::MultiVector<DomainScalar,LocalOrdinal,GlobalOrdinal,Node>& LHS,
528  const Tpetra::MultiVector<RangeScalar,LocalOrdinal,GlobalOrdinal,Node>& RHS,
529  Tpetra::MultiVector<RangeScalar,LocalOrdinal,GlobalOrdinal,Node>& ReducedRHS)
530 {
533  Teuchos::ArrayRCP<Teuchos::ArrayRCP<RangeScalar> > ReducedRHS_ptr = ReducedRHS.get2dViewNonConst();
534 
535  size_t NumVectors = LHS.getNumVectors();
536 
537  for (size_t i = 0 ; i < NumRows_ ; ++i)
538  for (size_t k = 0 ; k < NumVectors ; ++k)
539  ReducedRHS_ptr[k][i] = RHS_ptr[k][InvReorder_[i]];
540 
541  for (size_t i = 0 ; i < NumRows_ ; ++i) {
542  LocalOrdinal ii = InvReorder_[i];
543  size_t Nnz;
544  A_->getLocalRowCopy(ii,Indices_(),Values_(),Nnz);
545 
546  for (size_t j = 0 ; j < Nnz ; ++j) {
547  if (Reorder_[Indices_[j]] == -1) {
548  for (size_t k = 0 ; k < NumVectors ; ++k)
549  ReducedRHS_ptr[k][i] -= (RangeScalar)Values_[j] * (RangeScalar)LHS_ptr[k][Indices_[j]];
550  }
551  }
552  }
553 }
554 
555 //==============================================================================
556 template<class MatrixType>
557 void SingletonFilter<MatrixType>::UpdateLHS(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& ReducedLHS,
558  Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& LHS)
559 {
560  this->template UpdateLHSTempl<Scalar,Scalar>(ReducedLHS, LHS);
561 }
562 
563 //==============================================================================
564 template<class MatrixType>
565 template<class DomainScalar, class RangeScalar>
566 void SingletonFilter<MatrixType>::UpdateLHSTempl(const Tpetra::MultiVector<DomainScalar,LocalOrdinal,GlobalOrdinal,Node>& ReducedLHS,
567  Tpetra::MultiVector<RangeScalar,LocalOrdinal,GlobalOrdinal,Node>& LHS)
568 {
569 
570  Teuchos::ArrayRCP<Teuchos::ArrayRCP<RangeScalar> > LHS_ptr = LHS.get2dViewNonConst();
571  Teuchos::ArrayRCP<Teuchos::ArrayRCP<const DomainScalar> > ReducedLHS_ptr = ReducedLHS.get2dView();
572 
573  for (size_t i = 0 ; i < NumRows_ ; ++i)
574  for (size_t k = 0 ; k < LHS.getNumVectors() ; ++k)
575  LHS_ptr[k][InvReorder_[i]] = (RangeScalar)ReducedLHS_ptr[k][i];
576 }
577 
578 //==========================================================================
579 template<class MatrixType>
580 typename SingletonFilter<MatrixType>::mag_type SingletonFilter<MatrixType>::getFrobeniusNorm() const
581 {
582  throw std::runtime_error("Ifpack2::SingletonFilter does not implement getFrobeniusNorm.");
583 }
584 
585 } // namespace Ifpack2
586 
587 #define IFPACK2_SINGLETONFILTER_INSTANT(S,LO,GO,N) \
588  template class Ifpack2::SingletonFilter< Tpetra::RowMatrix<S, LO, GO, N> >;
589 
590 #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:418
virtual ~SingletonFilter()
Destructor.
Definition: Ifpack2_SingletonFilter_def.hpp:145
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:328
virtual global_size_t getGlobalNumRows() const
Returns the number of global rows in this matrix.
Definition: Ifpack2_SingletonFilter_def.hpp:215
virtual size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
Definition: Ifpack2_SingletonFilter_def.hpp:293
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:198
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:557
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:517
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:385
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
size_type size() const
virtual size_t getNodeNumDiags() const
Returns the number of local diagonal entries, based on global row/column index comparisons.
Definition: Ifpack2_SingletonFilter_def.hpp:286
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:359
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:188
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:168
virtual size_t getNodeNumRows() const
Returns the number of rows owned on the calling node.
Definition: Ifpack2_SingletonFilter_def.hpp:229
virtual bool hasTransposeApply() const
Indicates whether this operator supports applying the adjoint operator.
Definition: Ifpack2_SingletonFilter_def.hpp:472
virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Returns the communicator.
Definition: Ifpack2_SingletonFilter_def.hpp:150
virtual mag_type getFrobeniusNorm() const
Returns the Frobenius norm of the matrix.
Definition: Ifpack2_SingletonFilter_def.hpp:580
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:265
virtual size_t getNodeNumEntries() const
Returns the local number of entries in this matrix.
Definition: Ifpack2_SingletonFilter_def.hpp:258
virtual global_size_t getGlobalNumCols() const
Returns the number of global columns in this matrix.
Definition: Ifpack2_SingletonFilter_def.hpp:222
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:425
LinearOp zero(const VectorSpace &vs)
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:403
void resize(size_type new_size, const value_type &x=value_type())
virtual bool isLowerTriangular() const
Indicates whether this matrix is lower triangular.
Definition: Ifpack2_SingletonFilter_def.hpp:314
virtual bool hasColMap() const
Indicates whether this matrix has a well-defined column map.
Definition: Ifpack2_SingletonFilter_def.hpp:307
virtual Teuchos::RCP< const Tpetra::RowGraph< LocalOrdinal, GlobalOrdinal, Node > > getGraph() const
Returns the RowGraph associated with this matrix.
Definition: Ifpack2_SingletonFilter_def.hpp:208
virtual bool isUpperTriangular() const
Indicates whether this matrix is upper triangular.
Definition: Ifpack2_SingletonFilter_def.hpp:321
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:237
virtual global_size_t getGlobalNumDiags() const
Returns the number of global diagonal entries, based on global row/column index comparisons.
Definition: Ifpack2_SingletonFilter_def.hpp:279
SingletonFilter(const Teuchos::RCP< const Tpetra::RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &Matrix)
Constructor.
Definition: Ifpack2_SingletonFilter_def.hpp:57
virtual Teuchos::RCP< Node > getNode() const
Returns the underlying node.
Definition: Ifpack2_SingletonFilter_def.hpp:158
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:272
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:486
virtual bool supportsRowViews() const
Returns true if RowViews are supported.
Definition: Ifpack2_SingletonFilter_def.hpp:479
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:394
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:178
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:411
virtual bool isFillComplete() const
Returns true if fillComplete() has been called.
Definition: Ifpack2_SingletonFilter_def.hpp:342
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:349
virtual size_t getNodeMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
Definition: Ifpack2_SingletonFilter_def.hpp:300
virtual global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
Definition: Ifpack2_SingletonFilter_def.hpp:251
virtual GlobalOrdinal getIndexBase() const
Returns the index base for global indices for this matrix.
Definition: Ifpack2_SingletonFilter_def.hpp:244
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:335