Ifpack2 Templated Preconditioning Package Version 1.0
Ifpack2_ReorderFilter_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_REORDERFILTER_DEF_HPP
44#define IFPACK2_REORDERFILTER_DEF_HPP
45#include "Ifpack2_ReorderFilter_decl.hpp"
46#include <vector>
47
48#include "Tpetra_ConfigDefs.hpp"
49#include "Tpetra_RowMatrix.hpp"
50#include "Tpetra_Map.hpp"
51#include "Tpetra_MultiVector.hpp"
52#include "Tpetra_Vector.hpp"
53
54namespace Ifpack2 {
55
56template<class MatrixType>
58ReorderFilter (const Teuchos::RCP<const row_matrix_type>& A,
59 const Teuchos::ArrayRCP<local_ordinal_type>& perm,
60 const Teuchos::ArrayRCP<local_ordinal_type>& reverseperm)
61 : A_ (A),
62 perm_ (perm),
63 reverseperm_ (reverseperm)
64{
65 TEUCHOS_TEST_FOR_EXCEPTION(
66 A_.is_null (), std::invalid_argument,
67 "Ifpack2::ReorderFilter: The input matrix is null.");
68
69 // use this filter only on serial matrices
70 TEUCHOS_TEST_FOR_EXCEPTION(
71 A_->getComm()->getSize() != 1, std::invalid_argument,
72 "Ifpack2::ReorderFilter: This class may only be used if the input matrix's "
73 "communicator has one process. This class is an implementation detail of "
74 "Ifpack2::AdditiveSchwarz, and it is not meant to be used otherwise.");
75
76 TEUCHOS_TEST_FOR_EXCEPTION(
77 A_->getNodeNumRows () != A_->getGlobalNumRows (),
78 std::invalid_argument,
79 "Ifpack2::ReorderFilter: The input matrix is not square.");
80
81 // Temp arrays for apply
82 Kokkos::resize(Indices_,A_->getNodeMaxNumRowEntries ());
83 Kokkos::resize(Values_,A_->getNodeMaxNumRowEntries ());
84}
85
86
87template<class MatrixType>
89
90
91template<class MatrixType>
92Teuchos::RCP<const Teuchos::Comm<int> > ReorderFilter<MatrixType>::getComm() const
93{
94 return A_->getComm();
95}
96
97
98
99
100template<class MatrixType>
101Teuchos::RCP<const typename ReorderFilter<MatrixType>::map_type>
103{
104 TEUCHOS_TEST_FOR_EXCEPTION(
105 A_.is_null (), std::runtime_error, "Ifpack2::ReorderFilter::"
106 "getRowMap: The matrix A is null, so there is no row Map.");
107
108 return A_->getRowMap ();
109}
110
111
112template<class MatrixType>
113Teuchos::RCP<const typename ReorderFilter<MatrixType>::map_type>
115{
116 TEUCHOS_TEST_FOR_EXCEPTION(
117 A_.is_null (), std::runtime_error, "Ifpack2::ReorderFilter::"
118 "getColMap: The matrix A is null, so there is no column Map.");
119
120 return A_->getColMap();
121}
122
123
124template<class MatrixType>
125Teuchos::RCP<const typename ReorderFilter<MatrixType>::map_type>
127{
128 TEUCHOS_TEST_FOR_EXCEPTION(
129 A_.is_null (), std::runtime_error, "Ifpack2::ReorderFilter::"
130 "getDomainMap: The matrix A is null, so there is no domain Map.");
131
132 return A_->getDomainMap();
133}
134
135
136template<class MatrixType>
137Teuchos::RCP<const typename ReorderFilter<MatrixType>::map_type>
139{
140 TEUCHOS_TEST_FOR_EXCEPTION(
141 A_.is_null (), std::runtime_error, "Ifpack2::ReorderFilter::"
142 "getRangeMap: The matrix A is null, so there is no range Map.");
143
144 return A_->getRangeMap();
145}
146
147
148template<class MatrixType>
149Teuchos::RCP<const Tpetra::RowGraph<typename MatrixType::local_ordinal_type,
150 typename MatrixType::global_ordinal_type,
151 typename MatrixType::node_type> >
153{
154 throw std::runtime_error("Ifpack2::ReorderFilter: does not support getGraph.");
155}
156
157
158template<class MatrixType>
160{
161 return A_->getGlobalNumRows();
162}
163
164
165template<class MatrixType>
167{
168 return A_->getGlobalNumCols();
169}
170
171
172template<class MatrixType>
174{
175 return A_->getNodeNumRows();
176}
177
178
179template<class MatrixType>
181{
182 return A_->getNodeNumCols();
183}
184
185
186template<class MatrixType>
187typename MatrixType::global_ordinal_type ReorderFilter<MatrixType>::getIndexBase() const
188{
189 return A_->getIndexBase();
190}
191
192
193template<class MatrixType>
195{
196 return A_->getGlobalNumEntries();
197}
198
199
200template<class MatrixType>
202{
203 return A_->getNodeNumEntries();
204}
205
206
207template<class MatrixType>
209getNumEntriesInGlobalRow (global_ordinal_type globalRow) const
210{
211 if (A_.is_null () || A_->getRowMap ().is_null ()) {
212 return Teuchos::OrdinalTraits<size_t>::invalid ();
213 }
214 else {
215 const local_ordinal_type lclRow =
216 A_->getRowMap ()->getLocalElement (globalRow);
217 if (lclRow == Teuchos::OrdinalTraits<local_ordinal_type>::invalid ()) {
218 // The calling process doesn't own any entries in this row.
219 return static_cast<size_t> (0);
220 } else {
221 const local_ordinal_type origLclRow = reverseperm_[lclRow];
222 return A_->getNumEntriesInLocalRow (origLclRow);
223 }
224 }
225}
226
227
228template<class MatrixType>
230getNumEntriesInLocalRow (local_ordinal_type localRow) const
231{
232 // Make sure that localRow is in bounds before using it to index
233 // into the permutation.
234 if (A_->getRowMap ()->isNodeLocalElement (localRow)) {
235 // localRow is a valid index into reverseperm_.
236 const local_ordinal_type localReorderedRow = reverseperm_[localRow];
237 return A_->getNumEntriesInLocalRow (localReorderedRow);
238 } else {
239 // The calling process doesn't own any entries in this row.
240 return static_cast<size_t> (0);
241 }
242}
243
244
245template<class MatrixType>
247{
248 return A_->getGlobalMaxNumRowEntries();
249}
250
251
252template<class MatrixType>
254{
255 return A_->getNodeMaxNumRowEntries();
256}
257
258
259template<class MatrixType>
261{
262 return true;
263}
264
265
266template<class MatrixType>
268{
269 return A_->isLocallyIndexed();
270}
271
272
273template<class MatrixType>
275{
276 return A_->isGloballyIndexed();
277}
278
279
280template<class MatrixType>
282{
283 return A_->isFillComplete();
284}
285
286
287template<class MatrixType>
289 getGlobalRowCopy (global_ordinal_type globalRow,
290 nonconst_global_inds_host_view_type &globalInd,
291 nonconst_values_host_view_type &val,
292 size_t& numEntries) const
293{
294 using Teuchos::Array;
295 using Teuchos::ArrayView;
296 using Teuchos::av_reinterpret_cast;
297 typedef local_ordinal_type LO;
298 typedef global_ordinal_type GO;
299 typedef Teuchos::OrdinalTraits<LO> OTLO;
300
301 const map_type& rowMap = * (A_->getRowMap ());
302 const local_ordinal_type localRow = rowMap.getLocalElement (globalRow);
303 TEUCHOS_TEST_FOR_EXCEPTION(
304 localRow == OTLO::invalid (), std::invalid_argument, "Ifpack2::Reorder"
305 "Filter::getGlobalRowCopy: The given global row index " << globalRow
306 << " is not owned by the calling process with rank "
307 << rowMap.getComm ()->getRank () << ".");
308
309 // The Indices_ temp array is only used in apply, not getLocalRowCopy, so this is safe
310 numEntries = this->getNumEntriesInLocalRow (localRow);
311 this->getLocalRowCopy (localRow, Indices_, val, numEntries);
312
313 // Convert local indices back to global indices.
314 for (size_t k = 0; k < numEntries; ++k) {
315 globalInd[k] = rowMap.getGlobalElement (Indices_[k]);
316 }
317}
318
319#ifdef TPETRA_ENABLE_DEPRECATED_CODE
320template<class MatrixType>
322getGlobalRowCopy (global_ordinal_type globalRow,
323 const Teuchos::ArrayView<global_ordinal_type>& Indices,
324 const Teuchos::ArrayView<scalar_type>& Values,
325 size_t& numEntries) const
326{
327 using IST = typename row_matrix_type::impl_scalar_type;
328 nonconst_global_inds_host_view_type ind_in(Indices.data(),Indices.size());
329 nonconst_values_host_view_type val_in(reinterpret_cast<IST*>(Values.data()),Values.size());
330 getGlobalRowCopy(globalRow,ind_in,val_in,numEntries);
331}
332#endif
333
334template<class MatrixType>
336getLocalRowCopy (local_ordinal_type LocalRow,
337 nonconst_local_inds_host_view_type &Indices,
338 nonconst_values_host_view_type &Values,
339 size_t& NumEntries) const
340
341{
342 TEUCHOS_TEST_FOR_EXCEPTION(
343 ! A_->getRowMap ()->isNodeLocalElement (LocalRow),
344 std::invalid_argument,
345 "Ifpack2::ReorderFilter::getLocalRowCopy: The given local row index "
346 << LocalRow << " is not a valid local row index on the calling process "
347 "with rank " << A_->getRowMap ()->getComm ()->getRank () << ".");
348
349 // This duplicates code in getNumEntriesInGlobalRow, but avoids an
350 // extra array lookup and some extra tests.
351 const local_ordinal_type origLclRow = reverseperm_[LocalRow];
352 const size_t numEntries = A_->getNumEntriesInLocalRow (origLclRow);
353
354 TEUCHOS_TEST_FOR_EXCEPTION(
355 static_cast<size_t> (Indices.size ()) < numEntries ||
356 static_cast<size_t> (Values.size ()) < numEntries,
357 std::invalid_argument,
358 "Ifpack2::ReorderFilter::getLocalRowCopy: The given array views are not "
359 "long enough to store all the data in the given row " << LocalRow
360 << ". Indices.size() = " << Indices.size () << ", Values.size() = "
361 << Values.size () << ", but the (original) row has " << numEntries
362 << " entry/ies.");
363
364 A_->getLocalRowCopy (origLclRow, Indices, Values, NumEntries);
365 // Do a col reindex via perm
366 //
367 // FIXME (mfh 30 Jan 2014) This assumes that the row and column
368 // indices are the same.
369 for (size_t i = 0; i < NumEntries; ++i) {
370 Indices[i] = perm_[Indices[i]];
371 }
372}
373
374#ifdef TPETRA_ENABLE_DEPRECATED_CODE
375template<class MatrixType>
376void ReorderFilter<MatrixType>::getLocalRowCopy (local_ordinal_type LocalRow,
377 const Teuchos::ArrayView<local_ordinal_type> &Indices,
378 const Teuchos::ArrayView<scalar_type> &Values,
379 size_t &NumEntries) const
380{
381 using IST = typename row_matrix_type::impl_scalar_type;
382 nonconst_local_inds_host_view_type ind_in(Indices.data(),Indices.size());
383 nonconst_values_host_view_type val_in(reinterpret_cast<IST*>(Values.data()),Values.size());
384 getLocalRowCopy(LocalRow,ind_in,val_in,NumEntries);
385}
386#endif
387
388template<class MatrixType>
389void ReorderFilter<MatrixType>::getGlobalRowView(global_ordinal_type /* GlobalRow */,
390 global_inds_host_view_type &/*indices*/,
391 values_host_view_type &/*values*/) const
392{
393 throw std::runtime_error("Ifpack2::ReorderFilter: does not support getGlobalRowView.");
394}
395
396#ifdef TPETRA_ENABLE_DEPRECATED_CODE
397template<class MatrixType>
399getGlobalRowView (global_ordinal_type /* GlobalRow */,
400 Teuchos::ArrayView<const global_ordinal_type> &/* indices */,
401 Teuchos::ArrayView<const scalar_type> &/* values */) const
402{
403 throw std::runtime_error("Ifpack2::ReorderFilter: does not support getGlobalRowView.");
404}
405#endif
406
407
408template<class MatrixType>
409void ReorderFilter<MatrixType>::getLocalRowView(local_ordinal_type /* LocalRow */,
410 local_inds_host_view_type & /*indices*/,
411 values_host_view_type & /*values*/) const
412{
413 throw std::runtime_error("Ifpack2::ReorderFilter: does not support getLocalRowView.");
414}
415
416#ifdef TPETRA_ENABLE_DEPRECATED_CODE
417template<class MatrixType>
419getLocalRowView (local_ordinal_type /* LocalRow */,
420 Teuchos::ArrayView<const local_ordinal_type> &/* indices */,
421 Teuchos::ArrayView<const scalar_type> &/* values */) const
422{
423 throw std::runtime_error("Ifpack2::ReorderFilter: does not support getLocalRowView.");
424}
425#endif
426
427
428template<class MatrixType>
430getLocalDiagCopy (Tpetra::Vector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &diag) const
431{
432 // This is somewhat dubious as to how the maps match.
433 return A_->getLocalDiagCopy(diag);
434}
435
436
437template<class MatrixType>
438void ReorderFilter<MatrixType>::leftScale(const Tpetra::Vector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& /* x */)
439{
440 throw std::runtime_error("Ifpack2::ReorderFilter does not support leftScale.");
441}
442
443
444template<class MatrixType>
445void ReorderFilter<MatrixType>::rightScale(const Tpetra::Vector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& /* x */)
446{
447 throw std::runtime_error("Ifpack2::ReorderFilter does not support rightScale.");
448}
449
450
451template<class MatrixType>
453apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &X,
454 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &Y,
455 Teuchos::ETransp mode,
456 scalar_type alpha,
457 scalar_type beta) const
458{
459 typedef Teuchos::ScalarTraits<scalar_type> STS;
460
461 TEUCHOS_TEST_FOR_EXCEPTION(
462 alpha != STS::one () || beta != STS::zero (), std::logic_error,
463 "Ifpack2::ReorderFilter::apply is only implemented for alpha = 1 and "
464 "beta = 0. You set alpha = " << alpha << " and beta = " << beta << ".");
465
466 // Note: This isn't AztecOO compliant. But neither was Ifpack's version.
467 // Note: The localized maps mean the matvec is trivial (and has no import)
468 TEUCHOS_TEST_FOR_EXCEPTION(
469 X.getNumVectors() != Y.getNumVectors(), std::runtime_error,
470 "Ifpack2::ReorderFilter::apply: X.getNumVectors() != Y.getNumVectors().");
471
472 const scalar_type zero = STS::zero ();
473 Teuchos::ArrayRCP<Teuchos::ArrayRCP<const scalar_type> > x_ptr = X.get2dView();
474 Teuchos::ArrayRCP<Teuchos::ArrayRCP<scalar_type> > y_ptr = Y.get2dViewNonConst();
475
476 Y.putScalar (zero);
477 const size_t NumVectors = Y.getNumVectors ();
478
479 for (size_t i = 0; i < A_->getNodeNumRows (); ++i) {
480 size_t Nnz;
481 // Use this class's getrow to make the below code simpler
482 getLocalRowCopy (i, Indices_ , Values_ , Nnz);
483 scalar_type* Values = reinterpret_cast<scalar_type*>(Values_.data());
484 if (mode == Teuchos::NO_TRANS) {
485 for (size_t j = 0; j < Nnz; ++j) {
486 for (size_t k = 0; k < NumVectors; ++k) {
487 y_ptr[k][i] += Values[j] * x_ptr[k][Indices_[j]];
488 }
489 }
490 }
491 else if (mode == Teuchos::TRANS) {
492 for (size_t j = 0; j < Nnz; ++j) {
493 for (size_t k = 0; k < NumVectors; ++k) {
494 y_ptr[k][Indices_[j]] += Values[j] * x_ptr[k][i];
495 }
496 }
497 }
498 else { //mode==Teuchos::CONJ_TRANS
499 for (size_t j = 0; j < Nnz; ++j) {
500 for (size_t k = 0; k < NumVectors; ++k) {
501 y_ptr[k][Indices_[j]] += STS::conjugate(Values[j]) * x_ptr[k][i];
502 }
503 }
504 }
505 }
506}
507
508
509template<class MatrixType>
511{
512 return true;
513}
514
515
516template<class MatrixType>
518{
519 return false;
520}
521
522
523template<class MatrixType>
524typename ReorderFilter<MatrixType>::mag_type ReorderFilter<MatrixType>::getFrobeniusNorm() const
525{
526 // Reordering doesn't change the Frobenius norm.
527 return A_->getFrobeniusNorm ();
528}
529
530
531template<class MatrixType>
533permuteOriginalToReordered (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &originalX,
534 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &reorderedY) const
535{
536 this->template permuteOriginalToReorderedTempl<scalar_type,scalar_type>(originalX, reorderedY);
537}
538
539
540template<class MatrixType>
541template<class DomainScalar, class RangeScalar>
542void ReorderFilter<MatrixType>::permuteOriginalToReorderedTempl(const Tpetra::MultiVector<DomainScalar,local_ordinal_type,global_ordinal_type,node_type> &originalX,
543 Tpetra::MultiVector<RangeScalar,local_ordinal_type,global_ordinal_type,node_type> &reorderedY) const
544{
545 TEUCHOS_TEST_FOR_EXCEPTION(originalX.getNumVectors() != reorderedY.getNumVectors(), std::runtime_error,
546 "Ifpack2::ReorderFilter::permuteOriginalToReordered ERROR: X.getNumVectors() != Y.getNumVectors().");
547
548 Teuchos::ArrayRCP<Teuchos::ArrayRCP<const DomainScalar> > x_ptr = originalX.get2dView();
549 Teuchos::ArrayRCP<Teuchos::ArrayRCP<RangeScalar> > y_ptr = reorderedY.get2dViewNonConst();
550
551 for(size_t k=0; k < originalX.getNumVectors(); k++)
552 for(local_ordinal_type i=0; (size_t)i< originalX.getLocalLength(); i++)
553 y_ptr[k][perm_[i]] = (RangeScalar)x_ptr[k][i];
554}
555
556
557template<class MatrixType>
558void ReorderFilter<MatrixType>::permuteReorderedToOriginal(const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &reorderedX,
559 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &originalY) const
560{
561 this->template permuteReorderedToOriginalTempl<scalar_type,scalar_type>(reorderedX, originalY);
562}
563
564
565template<class MatrixType>
566template<class DomainScalar, class RangeScalar>
568permuteReorderedToOriginalTempl (const Tpetra::MultiVector<DomainScalar,local_ordinal_type,global_ordinal_type,node_type> &reorderedX,
569 Tpetra::MultiVector<RangeScalar,local_ordinal_type,global_ordinal_type,node_type> &originalY) const
570{
571 TEUCHOS_TEST_FOR_EXCEPTION(
572 reorderedX.getNumVectors() != originalY.getNumVectors(),
573 std::runtime_error,
574 "Ifpack2::ReorderFilter::permuteReorderedToOriginal: "
575 "X.getNumVectors() != Y.getNumVectors().");
576
577#ifdef HAVE_IFPACK2_DEBUG
578 {
579 typedef Teuchos::ScalarTraits<DomainScalar> STS;
580 typedef typename STS::magnitudeType magnitude_type;
581 typedef Teuchos::ScalarTraits<magnitude_type> STM;
582 Teuchos::Array<magnitude_type> norms (reorderedX.getNumVectors ());
583 reorderedX.norm2 (norms ());
584 bool good = true;
585 for (size_t j = 0;
586 j < reorderedX.getNumVectors (); ++j) {
587 if (STM::isnaninf (norms[j])) {
588 good = false;
589 break;
590 }
591 }
592 TEUCHOS_TEST_FOR_EXCEPTION(
593 ! good, std::runtime_error, "Ifpack2::ReorderFilter::"
594 "permuteReorderedToOriginalTempl: The 2-norm of the input reorderedX is "
595 "NaN or Inf.");
596 }
597#endif // HAVE_IFPACK2_DEBUG
598
599 Teuchos::ArrayRCP<Teuchos::ArrayRCP<const DomainScalar> > x_ptr = reorderedX.get2dView();
600 Teuchos::ArrayRCP<Teuchos::ArrayRCP<RangeScalar> > y_ptr = originalY.get2dViewNonConst();
601
602 for (size_t k = 0; k < reorderedX.getNumVectors (); ++k) {
603 for (local_ordinal_type i = 0; (size_t)i < reorderedX.getLocalLength (); ++i) {
604 y_ptr[k][reverseperm_[i]] = (RangeScalar) x_ptr[k][i];
605 }
606 }
607
608#ifdef HAVE_IFPACK2_DEBUG
609 {
610 typedef Teuchos::ScalarTraits<RangeScalar> STS;
611 typedef typename STS::magnitudeType magnitude_type;
612 typedef Teuchos::ScalarTraits<magnitude_type> STM;
613 Teuchos::Array<magnitude_type> norms (originalY.getNumVectors ());
614 originalY.norm2 (norms ());
615 bool good = true;
616 for (size_t j = 0;
617 j < originalY.getNumVectors (); ++j) {
618 if (STM::isnaninf (norms[j])) {
619 good = false;
620 break;
621 }
622 }
623 TEUCHOS_TEST_FOR_EXCEPTION(
624 ! good, std::runtime_error, "Ifpack2::ReorderFilter::"
625 "permuteReorderedToOriginalTempl: The 2-norm of the output originalY is "
626 "NaN or Inf.");
627 }
628#endif // HAVE_IFPACK2_DEBUG
629}
630
631} // namespace Ifpack2
632
633#define IFPACK2_REORDERFILTER_INSTANT(S,LO,GO,N) \
634 template class Ifpack2::ReorderFilter< Tpetra::RowMatrix<S, LO, GO, N> >;
635
636#endif
Wraps a Tpetra::RowMatrix in a filter that reorders local rows and columns.
Definition: Ifpack2_ReorderFilter_decl.hpp:70
virtual size_t getNumEntriesInGlobalRow(global_ordinal_type globalRow) const
The current number of entries in this matrix, stored on the calling process, in the row whose global ...
Definition: Ifpack2_ReorderFilter_def.hpp:209
virtual mag_type getFrobeniusNorm() const
Returns the Frobenius norm of the matrix.
Definition: Ifpack2_ReorderFilter_def.hpp:524
virtual size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
Definition: Ifpack2_ReorderFilter_def.hpp:246
virtual Teuchos::RCP< const map_type > getColMap() const
Returns the Map that describes the column distribution in this matrix.
Definition: Ifpack2_ReorderFilter_def.hpp:114
virtual size_t getNodeNumCols() const
Returns the number of columns needed to apply the forward operator on this node, i....
Definition: Ifpack2_ReorderFilter_def.hpp:180
virtual size_t getNodeNumRows() const
Returns the number of rows owned on the calling node.
Definition: Ifpack2_ReorderFilter_def.hpp:173
virtual void rightScale(const Tpetra::Vector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &x)
Scales the RowMatrix on the right with the Vector x.
Definition: Ifpack2_ReorderFilter_def.hpp:445
virtual bool hasColMap() const
Indicates whether this matrix has a well-defined column map.
Definition: Ifpack2_ReorderFilter_def.hpp:260
virtual void permuteReorderedToOriginal(const Tpetra::MultiVector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &reorderedX, Tpetra::MultiVector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &originalY) const
Permute multivector: reordered-to-original.
Definition: Ifpack2_ReorderFilter_def.hpp:558
virtual void permuteOriginalToReordered(const Tpetra::MultiVector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &originalX, Tpetra::MultiVector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &reorderedY) const
Permute multivector: original-to-reordered.
Definition: Ifpack2_ReorderFilter_def.hpp:533
virtual Teuchos::RCP< const map_type > getDomainMap() const
Returns the Map that describes the domain distribution in this matrix.
Definition: Ifpack2_ReorderFilter_def.hpp:126
virtual bool supportsRowViews() const
Returns true if RowViews are supported.
Definition: Ifpack2_ReorderFilter_def.hpp:517
virtual global_ordinal_type getIndexBase() const
Returns the index base for global indices for this matrix.
Definition: Ifpack2_ReorderFilter_def.hpp:187
virtual void getLocalDiagCopy(Tpetra::Vector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &diag) const
Get a copy of the diagonal entries owned by this node, with local row indices.
Definition: Ifpack2_ReorderFilter_def.hpp:430
virtual bool isGloballyIndexed() const
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
Definition: Ifpack2_ReorderFilter_def.hpp:274
virtual Teuchos::RCP< const map_type > getRowMap() const
Returns the Map that describes the row distribution in this matrix.
Definition: Ifpack2_ReorderFilter_def.hpp:102
virtual Teuchos::RCP< const map_type > getRangeMap() const
Returns the Map that describes the range distribution in this matrix.
Definition: Ifpack2_ReorderFilter_def.hpp:138
virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
The matrix's communicator.
Definition: Ifpack2_ReorderFilter_def.hpp:92
ReorderFilter(const Teuchos::RCP< const row_matrix_type > &A, const Teuchos::ArrayRCP< local_ordinal_type > &perm, const Teuchos::ArrayRCP< local_ordinal_type > &reverseperm)
Constructor.
Definition: Ifpack2_ReorderFilter_def.hpp:58
virtual bool isFillComplete() const
Returns true if fillComplete() has been called.
Definition: Ifpack2_ReorderFilter_def.hpp:281
virtual bool isLocallyIndexed() const
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
Definition: Ifpack2_ReorderFilter_def.hpp:267
virtual size_t getNodeMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
Definition: Ifpack2_ReorderFilter_def.hpp:253
virtual ~ReorderFilter()
Destructor.
Definition: Ifpack2_ReorderFilter_def.hpp:88
virtual void getGlobalRowCopy(global_ordinal_type 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_ReorderFilter_def.hpp:289
virtual void getLocalRowView(local_ordinal_type 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_ReorderFilter_def.hpp:409
virtual size_t getNodeNumEntries() const
Returns the local number of entries in this matrix.
Definition: Ifpack2_ReorderFilter_def.hpp:201
virtual size_t getNumEntriesInLocalRow(local_ordinal_type localRow) const
The current number of entries in this matrix, stored on the calling process, in the row whose local i...
Definition: Ifpack2_ReorderFilter_def.hpp:230
virtual void getLocalRowCopy(local_ordinal_type 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_ReorderFilter_def.hpp:336
virtual Teuchos::RCP< const Tpetra::RowGraph< local_ordinal_type, global_ordinal_type, node_type > > getGraph() const
Returns the RowGraph associated with this matrix.
Definition: Ifpack2_ReorderFilter_def.hpp:152
virtual void apply(const Tpetra::MultiVector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &X, Tpetra::MultiVector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, scalar_type alpha=Teuchos::ScalarTraits< scalar_type >::one(), scalar_type beta=Teuchos::ScalarTraits< scalar_type >::zero()) const
, where Op(A) is either A, , or .
Definition: Ifpack2_ReorderFilter_def.hpp:453
virtual global_size_t getGlobalNumRows() const
Returns the number of global rows in this matrix.
Definition: Ifpack2_ReorderFilter_def.hpp:159
virtual bool hasTransposeApply() const
Whether apply() can apply the transpose or conjugate transpose.
Definition: Ifpack2_ReorderFilter_def.hpp:510
virtual global_size_t getGlobalNumCols() const
Returns the number of global columns in this matrix.
Definition: Ifpack2_ReorderFilter_def.hpp:166
virtual global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
Definition: Ifpack2_ReorderFilter_def.hpp:194
virtual void leftScale(const Tpetra::Vector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &x)
Scales the RowMatrix on the left with the Vector x.
Definition: Ifpack2_ReorderFilter_def.hpp:438
virtual void getGlobalRowView(global_ordinal_type 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_ReorderFilter_def.hpp:389
Preconditioners and smoothers for Tpetra sparse matrices.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:73