Ifpack2 Templated Preconditioning Package  Version 1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Ifpack2_ILUT_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 //-----------------------------------------------------
44 // Ifpack2::ILUT is a translation of the Aztec ILUT
45 // implementation. The Aztec ILUT implementation was
46 // written by Ray Tuminaro.
47 // See notes in the Ifpack2::ILUT::Compute method.
48 // ABW.
49 //------------------------------------------------------
50 
51 #ifndef IFPACK2_ILUT_DECL_HPP
52 #define IFPACK2_ILUT_DECL_HPP
53 
54 #include "Ifpack2_ConfigDefs.hpp"
55 #include "Ifpack2_Preconditioner.hpp"
56 #include "Ifpack2_Condest.hpp"
57 #include "Ifpack2_Heap.hpp"
58 #include "Ifpack2_Parameters.hpp"
59 
60 #include <Teuchos_Assert.hpp>
61 #include <Teuchos_RCP.hpp>
62 #include <Teuchos_Time.hpp>
64 #include <Teuchos_ScalarTraits.hpp>
65 
66 #include <string>
67 #include <sstream>
68 #include <iostream>
69 #include <cmath>
70 
71 namespace Teuchos {
72  // forward declaration
73  class ParameterList;
74 }
75 
76 namespace Ifpack2 {
77 
95 template<class MatrixType>
96 class ILUT :
97  virtual public Ifpack2::Preconditioner<typename MatrixType::scalar_type,
98  typename MatrixType::local_ordinal_type,
99  typename MatrixType::global_ordinal_type,
100  typename MatrixType::node_type>
101 {
102 public:
104 
105 
107  typedef typename MatrixType::scalar_type scalar_type;
108 
110  TEUCHOS_DEPRECATED typedef typename MatrixType::scalar_type Scalar;
111 
112 
114  typedef typename MatrixType::local_ordinal_type local_ordinal_type;
115 
117  TEUCHOS_DEPRECATED typedef typename MatrixType::local_ordinal_type LocalOrdinal;
118 
119 
121  typedef typename MatrixType::global_ordinal_type global_ordinal_type;
122 
124  TEUCHOS_DEPRECATED typedef typename MatrixType::global_ordinal_type GlobalOrdinal;
125 
126 
128  typedef typename MatrixType::node_type node_type;
129 
131  TEUCHOS_DEPRECATED typedef typename MatrixType::node_type Node;
132 
133 
136 
139 
141 
143 
153  explicit ILUT(const Teuchos::RCP<const Tpetra::RowMatrix<scalar_type,local_ordinal_type,global_ordinal_type,node_type> > &A);
154 
156  virtual ~ILUT();
157 
159 
161 
163 
172  void setParameters (const Teuchos::ParameterList& params);
173 
181  void initialize ();
182 
184  inline bool isInitialized() const {
185  return(IsInitialized_);
186  }
187 
189 
196  void compute();
197 
199  inline bool isComputed() const {
200  return(IsComputed_);
201  }
202 
204 
206 
207 
209 
215  void apply(
216  const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
217  Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
221 
224 
227 
229  bool hasTransposeApply() const;
230 
232 
234 
237 
243  template<class DomainScalar, class RangeScalar>
244  void applyTempl(
245  const Tpetra::MultiVector<DomainScalar,local_ordinal_type,global_ordinal_type,node_type>& X,
246  Tpetra::MultiVector<RangeScalar,local_ordinal_type,global_ordinal_type,node_type>& Y,
248  RangeScalar alpha = Teuchos::ScalarTraits<scalar_type>::one(),
249  RangeScalar beta = Teuchos::ScalarTraits<scalar_type>::zero()) const;
250 
253  local_ordinal_type MaxIters = 1550,
254  magnitude_type Tol = 1e-9,
255  const Teuchos::Ptr<const Tpetra::RowMatrix<scalar_type,local_ordinal_type,global_ordinal_type,node_type> > &Matrix_in = Teuchos::null);
256 
258  magnitude_type getCondEst() const { return Condest_; }
259 
262 
265 
267  const Teuchos::RCP<const MatrixType> getL() const { return L_; }
268 
270  const Teuchos::RCP<const MatrixType> getU() const { return U_; }
271 
273  int getNumInitialize() const;
274 
276  int getNumCompute() const;
277 
279  int getNumApply() const;
280 
282  double getInitializeTime() const;
283 
285  double getComputeTime() const;
286 
288  double getApplyTime() const;
289 
292  return(LevelOfFill_);
293  }
294 
297  return(Athresh_);
298  }
299 
302  return(Rthresh_);
303  }
304 
306  inline magnitude_type getRelaxValue() const {
307  return(RelaxValue_);
308  }
309 
312  return(DropTolerance_);
313  }
314 
316  global_size_t getGlobalNumEntries() const;
317 
319  size_t getNodeNumEntries() const;
320 
321  // @}
322 
324 
325 
327  std::string description() const;
328 
331 
333 
334 private:
337  typedef typename Teuchos::Array<local_ordinal_type>::size_type size_type;
338 
340 
342  ILUT(const ILUT<MatrixType>& RHS);
343 
345  ILUT<MatrixType>& operator=(const ILUT<MatrixType>& RHS);
346 
348  // \name Internal data
350 
357 
359  // \name Parameters (set by the input ParameterList)
361 
362  magnitude_type Athresh_;
363  magnitude_type Rthresh_;
364  magnitude_type RelaxValue_;
365  magnitude_type LevelOfFill_;
366  magnitude_type DropTolerance_;
369  magnitude_type Condest_;
370 
372  // \name Other internal data
374 
376  double InitializeTime_;
378  double ComputeTime_;
380  mutable double ApplyTime_;
382  int NumInitialize_;
384  int NumCompute_;
386  mutable int NumApply_;
388  bool IsInitialized_;
390  bool IsComputed_;
392 }; // class ILUT
393 
394 } // namespace Ifpack2
395 
396 #endif /* IFPACK2_ILUT_HPP */
magnitude_type getDropTolerance() const
Gets the dropping tolerance.
Definition: Ifpack2_ILUT_decl.hpp:311
CondestType
Ifpack2::CondestType: enum to define the type of condition number estimate.
Definition: Ifpack2_CondestType.hpp:50
bool hasTransposeApply() const
Whether this object&#39;s apply() method can apply the transpose (or conjugate transpose, if applicable).
Definition: Ifpack2_ILUT_def.hpp:277
virtual ~ILUT()
Destructor.
Definition: Ifpack2_ILUT_def.hpp:137
MatrixType::global_ordinal_type global_ordinal_type
The type of global indices in the input MatrixType.
Definition: Ifpack2_ILUT_decl.hpp:121
const Teuchos::RCP< const Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > > & getDomainMap() const
Tpetra::Map representing the domain of this operator.
Definition: Ifpack2_ILUT_def.hpp:262
Teuchos::ScalarTraits< scalar_type >::magnitudeType magnitude_type
The type of the magnitude (absolute value) of a matrix entry.
Definition: Ifpack2_ILUT_decl.hpp:135
global_size_t getGlobalNumEntries() const
Returns the number of nonzero entries in the global graph.
Definition: Ifpack2_ILUT_def.hpp:319
void initialize()
Clear any previously computed factors.
Definition: Ifpack2_ILUT_def.hpp:350
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to an FancyOStream object.
Definition: Ifpack2_ILUT_def.hpp:812
std::string description() const
Return a simple one-line description of this object.
Definition: Ifpack2_ILUT_def.hpp:790
TEUCHOS_DEPRECATED typedef MatrixType::global_ordinal_type GlobalOrdinal
Preserved only for backwards compatibility. Please use &quot;global_ordinal_type&quot;.
Definition: Ifpack2_ILUT_decl.hpp:124
ILUT incomplete factorization of a Tpetra sparse matrix.
Definition: Ifpack2_ILUT_decl.hpp:96
size_t getNodeNumEntries() const
Returns the number of nonzero entries in the local graph.
Definition: Ifpack2_ILUT_def.hpp:325
magnitude_type getCondEst() const
Returns the computed estimated condition number, or -1.0 if no computed.
Definition: Ifpack2_ILUT_decl.hpp:258
magnitude_type getRelaxValue() const
Get the relax value.
Definition: Ifpack2_ILUT_decl.hpp:306
ILUT(const Teuchos::RCP< const Tpetra::RowMatrix< scalar_type, local_ordinal_type, global_ordinal_type, node_type > > &A)
Constructor.
Definition: Ifpack2_ILUT_def.hpp:113
TEUCHOS_DEPRECATED typedef MatrixType::node_type Node
Preserved only for backwards compatibility. Please use &quot;node_type&quot;.
Definition: Ifpack2_ILUT_decl.hpp:131
Ordinal size_type
Teuchos::RCP< const Tpetra::RowMatrix< scalar_type, local_ordinal_type, global_ordinal_type, node_type > > getMatrix() const
Returns a reference to the matrix to be preconditioned.
Definition: Ifpack2_ILUT_def.hpp:255
TEUCHOS_DEPRECATED typedef Teuchos::ScalarTraits< scalar_type >::magnitudeType magnitudeType
Preserved only for backwards compatibility. Please use &quot;magnitude_type&quot;.
Definition: Ifpack2_ILUT_decl.hpp:138
magnitude_type computeCondEst(CondestType CT=Cheap, local_ordinal_type MaxIters=1550, magnitude_type Tol=1e-9, const Teuchos::Ptr< const Tpetra::RowMatrix< scalar_type, local_ordinal_type, global_ordinal_type, node_type > > &Matrix_in=Teuchos::null)
Computes the estimated condition number and returns the value.
Definition: Ifpack2_ILUT_def.hpp:333
magnitude_type getRelativeThreshold() const
Get relative threshold value.
Definition: Ifpack2_ILUT_decl.hpp:301
MatrixType::scalar_type scalar_type
The type of the entries of the input MatrixType.
Definition: Ifpack2_ILUT_decl.hpp:107
const Teuchos::RCP< const Teuchos::Comm< int > > & getComm() const
Returns the Tpetra::BlockMap object associated with the range of this matrix operator.
Definition: Ifpack2_ILUT_def.hpp:248
void applyTempl(const Tpetra::MultiVector< DomainScalar, local_ordinal_type, global_ordinal_type, node_type > &X, Tpetra::MultiVector< RangeScalar, local_ordinal_type, global_ordinal_type, node_type > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, RangeScalar alpha=Teuchos::ScalarTraits< scalar_type >::one(), RangeScalar beta=Teuchos::ScalarTraits< scalar_type >::zero()) const
Returns the result of a ILUT forward/back solve on a Tpetra::MultiVector X in Y.
Base class for all Ifpack2 preconditioners.
Definition: Ifpack2_Preconditioner.hpp:130
const Teuchos::RCP< const Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > > & getRangeMap() const
Tpetra::Map representing the range of this operator.
Definition: Ifpack2_ILUT_def.hpp:270
magnitude_type getAbsoluteThreshold() const
Get absolute threshold value.
Definition: Ifpack2_ILUT_decl.hpp:296
magnitude_type getLevelOfFill() const
The level of fill.
Definition: Ifpack2_ILUT_decl.hpp:291
const Teuchos::RCP< const MatrixType > getL() const
Returns a reference to the L factor.
Definition: Ifpack2_ILUT_decl.hpp:267
void compute()
Compute factors L and U using the specified diagonal perturbation thresholds and relaxation parameter...
Definition: Ifpack2_ILUT_def.hpp:380
static const EVerbosityLevel verbLevel_default
int getNumInitialize() const
Returns the number of calls to Initialize().
Definition: Ifpack2_ILUT_def.hpp:283
double getApplyTime() const
Returns the time spent in apply().
Definition: Ifpack2_ILUT_def.hpp:313
TEUCHOS_DEPRECATED typedef MatrixType::scalar_type Scalar
Preserved only for backwards compatibility. Please use &quot;scalar_type&quot;.
Definition: Ifpack2_ILUT_decl.hpp:110
bool isComputed() const
If compute() is completed, this query returns true, otherwise it returns false.
Definition: Ifpack2_ILUT_decl.hpp:199
const Teuchos::RCP< const MatrixType > getU() const
Returns a reference to the U factor.
Definition: Ifpack2_ILUT_decl.hpp:270
double getInitializeTime() const
Returns the time spent in Initialize().
Definition: Ifpack2_ILUT_def.hpp:301
bool isInitialized() const
Returns true if the preconditioner has been successfully initialized.
Definition: Ifpack2_ILUT_decl.hpp:184
TEUCHOS_DEPRECATED typedef MatrixType::local_ordinal_type LocalOrdinal
Preserved only for backwards compatibility. Please use &quot;local_ordinal_type&quot;.
Definition: Ifpack2_ILUT_decl.hpp:117
int getNumApply() const
Returns the number of calls to apply().
Definition: Ifpack2_ILUT_def.hpp:295
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
Returns the result of a ILUT forward/back solve on a Tpetra::MultiVector X in Y.
Definition: Ifpack2_ILUT_def.hpp:718
cheap estimate
Definition: Ifpack2_CondestType.hpp:51
double getComputeTime() const
Returns the time spent in Compute().
Definition: Ifpack2_ILUT_def.hpp:307
void setParameters(const Teuchos::ParameterList &params)
Set parameters for the preconditioner.
Definition: Ifpack2_ILUT_def.hpp:142
int getNumCompute() const
Returns the number of calls to Compute().
Definition: Ifpack2_ILUT_def.hpp:289
MatrixType::node_type node_type
The type of the Kokkos Node used by the input MatrixType.
Definition: Ifpack2_ILUT_decl.hpp:128
MatrixType::local_ordinal_type local_ordinal_type
The type of local indices in the input MatrixType.
Definition: Ifpack2_ILUT_decl.hpp:114