Ifpack2 Templated Preconditioning Package  Version 1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Ifpack2_LocalFilter_decl.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_LOCALFILTER_DECL_HPP
44 #define IFPACK2_LOCALFILTER_DECL_HPP
45 
46 #include "Ifpack2_ConfigDefs.hpp"
47 #include "Tpetra_ConfigDefs.hpp"
48 #include "Tpetra_RowMatrix.hpp"
49 #include "Teuchos_RefCountPtr.hpp"
50 #include "Teuchos_ScalarTraits.hpp"
51 
52 
53 namespace Ifpack2 {
54 
99 template<class MatrixType>
100 class LocalFilter :
101  virtual public Tpetra::RowMatrix<typename MatrixType::scalar_type,
102  typename MatrixType::local_ordinal_type,
103  typename MatrixType::global_ordinal_type,
104  typename MatrixType::node_type>
105 {
106 public:
108 
109 
111  typedef typename MatrixType::scalar_type scalar_type;
112 
114  TEUCHOS_DEPRECATED typedef typename MatrixType::scalar_type Scalar;
115 
116 
118  typedef typename MatrixType::local_ordinal_type local_ordinal_type;
119 
121  TEUCHOS_DEPRECATED typedef typename MatrixType::local_ordinal_type LocalOrdinal;
122 
123 
125  typedef typename MatrixType::global_ordinal_type global_ordinal_type;
126 
128  TEUCHOS_DEPRECATED typedef typename MatrixType::global_ordinal_type GlobalOrdinal;
129 
130 
132  typedef typename MatrixType::node_type node_type;
133 
135  TEUCHOS_DEPRECATED typedef typename MatrixType::node_type Node;
136 
137 
140 
143 
145 
147 
155  explicit LocalFilter (const Teuchos::RCP<const Tpetra::RowMatrix<scalar_type, local_ordinal_type, global_ordinal_type, node_type> >& Matrix);
156 
158  virtual ~LocalFilter();
159 
161 
163 
165  virtual const Teuchos::RCP<const Teuchos::Comm<int> > & getComm() const;
166 
168  virtual Teuchos::RCP<node_type> getNode() const;
169 
172 
175 
178 
181 
184 
186  virtual global_size_t getGlobalNumRows() const;
187 
189  virtual global_size_t getGlobalNumCols() const;
190 
192  virtual size_t getNodeNumRows() const;
193 
195  virtual size_t getNodeNumCols() const;
196 
198  virtual global_ordinal_type getIndexBase() const;
199 
201  virtual global_size_t getGlobalNumEntries() const;
202 
204  virtual size_t getNodeNumEntries() const;
205 
211  virtual size_t getNumEntriesInGlobalRow (global_ordinal_type globalRow) const;
212 
218  virtual size_t getNumEntriesInLocalRow (local_ordinal_type localRow) const;
219 
221  virtual global_size_t getGlobalNumDiags() const;
222 
224  virtual size_t getNodeNumDiags() const;
225 
227  virtual size_t getGlobalMaxNumRowEntries() const;
228 
230  virtual size_t getNodeMaxNumRowEntries() const;
231 
233  virtual bool hasColMap() const;
234 
236  virtual bool isLowerTriangular() const;
237 
239  virtual bool isUpperTriangular() const;
240 
242  virtual bool isLocallyIndexed() const;
243 
245  virtual bool isGloballyIndexed() const;
246 
248  virtual bool isFillComplete() const;
249 
251  virtual bool supportsRowViews() const;
252 
254 
256 
257 
259 
269  virtual void
272  const Teuchos::ArrayView<scalar_type> &Values,
273  size_t &NumEntries) const;
274 
276 
286  virtual void
289  const Teuchos::ArrayView<scalar_type> &Values,
290  size_t &NumEntries) const ;
291 
293 
302  virtual void
306 
308 
317  virtual void
321 
323 
325  virtual void
326  getLocalDiagCopy (Tpetra::Vector<scalar_type, local_ordinal_type, global_ordinal_type, node_type> &diag) const;
327 
329 
331 
341  virtual void leftScale(const Tpetra::Vector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& x);
342 
352  virtual void rightScale(const Tpetra::Vector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& x);
353 
362  virtual magnitude_type getFrobeniusNorm() const;
363 
365 
370  virtual void
371  apply (const Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type> &X,
372  Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type> &Y,
376 
378  virtual bool hasTransposeApply() const;
379 
381 
383 
384 
386 
395  TPETRA_DEPRECATED virtual void getGlobalRowView(global_ordinal_type GlobalRow,
398 
400 
409  TPETRA_DEPRECATED virtual void getLocalRowView(local_ordinal_type LocalRow,
413 
414 
415 private:
416 
422  size_t NumRows_;
424  size_t NumNonzeros_;
426  size_t MaxNumEntries_;
428  size_t MaxNumEntriesA_;
430  std::vector<size_t> NumEntries_;
432  mutable Teuchos::Array<local_ordinal_type> Indices_;
434  mutable Teuchos::Array<scalar_type> Values_;
435 
436 };// class LocalFilter
437 
438 }// namespace Ifpack2
439 
440 #endif /* IFPACK2_LOCALFILTER_DECL_HPP */
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_LocalFilter_def.hpp:443
virtual size_t getNodeNumDiags() const
The number of local diagonal entries, based on global row/column index comparisons.
Definition: Ifpack2_LocalFilter_def.hpp:286
virtual magnitude_type getFrobeniusNorm() const
The Frobenius norm of the (locally filtered) matrix.
Definition: Ifpack2_LocalFilter_def.hpp:524
virtual const Teuchos::RCP< const Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > > & getRowMap() const
Returns the Map that describes the row distribution in this matrix.
Definition: Ifpack2_LocalFilter_def.hpp:168
virtual Teuchos::RCP< node_type > getNode() const
Returns the underlying Kokkos Node object.
Definition: Ifpack2_LocalFilter_def.hpp:158
virtual size_t getNodeNumRows() const
The number of rows owned on the calling process.
Definition: Ifpack2_LocalFilter_def.hpp:229
virtual bool isFillComplete() const
Returns true if fillComplete() has been called.
Definition: Ifpack2_LocalFilter_def.hpp:342
TEUCHOS_DEPRECATED typedef MatrixType::global_ordinal_type GlobalOrdinal
Preserved only for backwards compatibility. Please use &quot;global_ordinal_type&quot;.
Definition: Ifpack2_LocalFilter_decl.hpp:128
virtual size_t getNodeMaxNumRowEntries() const
The maximum number of entries across all rows/columns on this process.
Definition: Ifpack2_LocalFilter_def.hpp:300
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
Computes the operator-multivector application.
Definition: Ifpack2_LocalFilter_def.hpp:450
MatrixType::global_ordinal_type global_ordinal_type
The type of global indices in the input MatrixType.
Definition: Ifpack2_LocalFilter_decl.hpp:125
virtual bool hasTransposeApply() const
Indicates whether this operator supports applying the adjoint operator.
Definition: Ifpack2_LocalFilter_def.hpp:510
virtual bool isLocallyIndexed() const
Whether the underlying sparse matrix is locally (opposite of globally) indexed.
Definition: Ifpack2_LocalFilter_def.hpp:328
virtual void getGlobalRowView(global_ordinal_type GlobalRow, Teuchos::ArrayView< const global_ordinal_type > &indices, Teuchos::ArrayView< const scalar_type > &values) const
Extract a const, non-persisting view of global indices in a specified row of the matrix.
Definition: Ifpack2_LocalFilter_def.hpp:405
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_LocalFilter_def.hpp:423
virtual const Teuchos::RCP< const Teuchos::Comm< int > > & getComm() const
Returns the communicator.
Definition: Ifpack2_LocalFilter_def.hpp:151
virtual Teuchos::RCP< const Tpetra::RowGraph< local_ordinal_type, global_ordinal_type, node_type > > getGraph() const
The (locally filtered) matrix&#39;s graph.
Definition: Ifpack2_LocalFilter_def.hpp:208
MatrixType::local_ordinal_type local_ordinal_type
The type of local indices in the input MatrixType.
Definition: Ifpack2_LocalFilter_decl.hpp:118
virtual bool supportsRowViews() const
Returns true if RowViews are supported.
Definition: Ifpack2_LocalFilter_def.hpp:517
virtual global_size_t getGlobalNumDiags() const
The number of global diagonal entries, based on global row/column index comparisons.
Definition: Ifpack2_LocalFilter_def.hpp:279
virtual const Teuchos::RCP< const Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > > & getColMap() const
Returns the Map that describes the column distribution in this matrix.
Definition: Ifpack2_LocalFilter_def.hpp:178
virtual size_t getNumEntriesInGlobalRow(global_ordinal_type globalRow) const
The current number of entries on this node in the specified global row.
Definition: Ifpack2_LocalFilter_def.hpp:265
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_LocalFilter_def.hpp:436
virtual global_ordinal_type getIndexBase() const
Returns the index base for global indices for this matrix.
Definition: Ifpack2_LocalFilter_def.hpp:244
virtual bool isGloballyIndexed() const
Whether the underlying sparse matrix is globally (opposite of locally) indexed.
Definition: Ifpack2_LocalFilter_def.hpp:335
virtual bool isUpperTriangular() const
Whether this matrix is upper triangular.
Definition: Ifpack2_LocalFilter_def.hpp:321
virtual size_t getGlobalMaxNumRowEntries() const
The maximum number of entries across all rows/columns on all processes.
Definition: Ifpack2_LocalFilter_def.hpp:293
virtual void getLocalRowCopy(local_ordinal_type LocalRow, const Teuchos::ArrayView< local_ordinal_type > &Indices, const Teuchos::ArrayView< scalar_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_LocalFilter_def.hpp:359
virtual size_t getNodeNumCols() const
The number of columns in the (locally filtered) matrix.
Definition: Ifpack2_LocalFilter_def.hpp:237
TEUCHOS_DEPRECATED typedef Teuchos::ScalarTraits< scalar_type >::magnitudeType magnitudeType
Preserved only for backwards compatibility. Please use &quot;magnitude_type&quot;.
Definition: Ifpack2_LocalFilter_decl.hpp:142
LocalFilter(const Teuchos::RCP< const Tpetra::RowMatrix< scalar_type, local_ordinal_type, global_ordinal_type, node_type > > &Matrix)
Constructor.
Definition: Ifpack2_LocalFilter_def.hpp:65
virtual ~LocalFilter()
Destructor.
Definition: Ifpack2_LocalFilter_def.hpp:147
virtual global_size_t getGlobalNumRows() const
The number of global rows in this matrix.
Definition: Ifpack2_LocalFilter_def.hpp:215
MatrixType::scalar_type scalar_type
The type of the entries of the input MatrixType.
Definition: Ifpack2_LocalFilter_decl.hpp:111
virtual size_t getNodeNumEntries() const
Returns the local number of entries in this matrix.
Definition: Ifpack2_LocalFilter_def.hpp:258
virtual size_t getNumEntriesInLocalRow(local_ordinal_type localRow) const
The current number of entries on this node in the specified local row.
Definition: Ifpack2_LocalFilter_def.hpp:272
TEUCHOS_DEPRECATED typedef MatrixType::scalar_type Scalar
Preserved only for backwards compatibility. Please use &quot;scalar_type&quot;.
Definition: Ifpack2_LocalFilter_decl.hpp:114
Teuchos::ScalarTraits< scalar_type >::magnitudeType magnitude_type
The type of the magnitude (absolute value) of a matrix entry.
Definition: Ifpack2_LocalFilter_decl.hpp:139
virtual const Teuchos::RCP< const Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > > & getDomainMap() const
Returns the Map that describes the domain distribution in this matrix.
Definition: Ifpack2_LocalFilter_def.hpp:188
virtual global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
Definition: Ifpack2_LocalFilter_def.hpp:251
virtual void getGlobalRowCopy(global_ordinal_type GlobalRow, const Teuchos::ArrayView< global_ordinal_type > &Indices, const Teuchos::ArrayView< scalar_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_LocalFilter_def.hpp:349
Access only local rows and columns of a sparse matrix.
Definition: Ifpack2_LocalFilter_decl.hpp:100
virtual global_size_t getGlobalNumCols() const
The number of global columns in this matrix.
Definition: Ifpack2_LocalFilter_def.hpp:222
virtual bool isLowerTriangular() const
Whether this matrix is lower triangular.
Definition: Ifpack2_LocalFilter_def.hpp:314
virtual void getLocalRowView(local_ordinal_type LocalRow, Teuchos::ArrayView< const local_ordinal_type > &indices, Teuchos::ArrayView< const scalar_type > &values) const
Extract a const, non-persisting view of local indices in a specified row of the matrix.
Definition: Ifpack2_LocalFilter_def.hpp:414
TEUCHOS_DEPRECATED typedef MatrixType::node_type Node
Preserved only for backwards compatibility. Please use &quot;node_type&quot;.
Definition: Ifpack2_LocalFilter_decl.hpp:135
virtual bool hasColMap() const
Whether this matrix has a well-defined column Map.
Definition: Ifpack2_LocalFilter_def.hpp:307
TEUCHOS_DEPRECATED typedef MatrixType::local_ordinal_type LocalOrdinal
Preserved only for backwards compatibility. Please use &quot;local_ordinal_type&quot;.
Definition: Ifpack2_LocalFilter_decl.hpp:121
virtual const Teuchos::RCP< const Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > > & getRangeMap() const
Returns the Map that describes the range distribution in this matrix.
Definition: Ifpack2_LocalFilter_def.hpp:198
MatrixType::node_type node_type
The type of the Kokkos Node used by the input MatrixType.
Definition: Ifpack2_LocalFilter_decl.hpp:132