Ifpack2 Templated Preconditioning Package  Version 1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Ifpack2_Details_FastILU_Base_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Ifpack2: Templated Object-Oriented Algebraic Preconditioner Package
4 //
5 // Copyright 2009 NTESS and the Ifpack2 contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
14 
15 #ifndef __IFPACK2_FASTILU_BASE_DECL_HPP__
16 #define __IFPACK2_FASTILU_BASE_DECL_HPP__
17 
18 #include <Tpetra_RowMatrix.hpp>
19 #include <Tpetra_CrsMatrix.hpp>
20 #include <Tpetra_KokkosCompat_DefaultNode.hpp>
21 #include <KokkosSparse_CrsMatrix.hpp>
24 #include <shylu_fastutil.hpp>
25 
26 #ifdef HAVE_IFPACK2_METIS
27 #include "metis.h"
28 #endif
29 
30 namespace Ifpack2
31 {
32 namespace Details
33 {
34 
37 template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
38  class FastILU_Base : public Ifpack2::Preconditioner<Scalar, LocalOrdinal, GlobalOrdinal, Node>,
40  Tpetra::RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
41 {
42  public:
44  typedef typename Node::device_type device_type;
46  typedef typename device_type::execution_space execution_space;
48  typedef typename Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::impl_scalar_type ImplScalar;
50  typedef Tpetra::RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> TRowMatrix;
52  typedef Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> TCrsMatrix;
54  typedef Tpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> TMultiVec;
56  typedef KokkosSparse::CrsMatrix<Scalar, LocalOrdinal, execution_space> KCrsMatrix;
58  typedef Kokkos::View<LocalOrdinal *, execution_space> OrdinalArray;
60  typedef typename Kokkos::View<LocalOrdinal *, execution_space>::HostMirror OrdinalArrayHost;
62  typedef Kokkos::View< ImplScalar *, execution_space> ImplScalarArray;
63  typedef Kokkos::View< Scalar *, execution_space> ScalarArray;
64  typedef Kokkos::View<const Scalar *, execution_space> ConstScalarArray;
65  #ifdef HAVE_IFPACK2_METIS
66  typedef Kokkos::View<idx_t*, Kokkos::HostSpace> MetisArrayHost;
67  #endif
68 
71 
74  getDomainMap () const;
75 
78  getRangeMap () const;
79 
81  void
82  apply (const TMultiVec& X,
83  TMultiVec& Y,
85  Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
86  Scalar beta = Teuchos::ScalarTraits<Scalar>::zero()) const;
88 
99  void setParameters (const Teuchos::ParameterList& List);
100 
101  bool isBlockCrs() const;
102 
104  void initialize();
105 
107  bool isInitialized() const;
108 
110  void compute();
111 
113  bool isComputed() const;
114 
117 
119  int getNumInitialize() const;
120 
122  int getNumCompute() const;
123 
125  int getNumApply() const;
126 
128  double getInitializeTime() const;
129 
131  double getComputeTime() const;
132 
134  double getApplyTime() const;
135 
137  double getCopyTime() const;
138 
140  virtual int getSweeps() const = 0;
141 
143  virtual std::string getSpTrsvType() const = 0;
144 
146  virtual int getNTrisol() const = 0;
147 
149  virtual void checkLocalILU() const;
150 
152  virtual void checkLocalIC() const;
153 
155  std::string description() const;
156 
161 
162  protected:
164  bool initFlag_;
165  bool computedFlag_;
166  int nInit_;
167  int nComputed_;
168  mutable int nApply_;
169  //store the local CRS components
170  ImplScalarArray localValues_; //set at beginning of compute()
171  OrdinalArray localRowPtrs_; //set in initialize()
172  OrdinalArray localColInds_; //set in initialize()
173  OrdinalArrayHost localRowPtrsHost_; //set in initialize() and used to get localValues_ in compute()
174 
175  double initTime_;
176  double computeTime_;
177  mutable double applyTime_;
178  double crsCopyTime_; //total time spent deep copying values, rowptrs, colinds out of mat
179 
180  //Store validated parameter values (instead of keeping a ParameterList around)
181  struct Params
182  {
183  Params() {}
184  Params(const Teuchos::ParameterList& pL, std::string precType);
185  bool use_metis;
186  FastILU::SpTRSV sptrsv_algo;
187  int nFact;
188  int nTrisol;
189  int level;
190  int blkSize;
191  double omega;
192  double shift;
193  bool guessFlag;
194  int blockSizeILU;
195  int blockSize;
196  bool blockCrs;
197  int blockCrsSize;
198  bool fillBlocks;
199  static Params getDefaults();
200  };
201 
202  Params params_;
203 
204  #ifdef HAVE_IFPACK2_METIS
205  MetisArrayHost metis_perm_;
206  MetisArrayHost metis_iperm_;
207  #endif
208 
210  // \pre !mat_.is_null()
211  virtual void initLocalPrec() = 0;
213  virtual void computeLocalPrec() = 0;
215  virtual void applyLocalPrec(ImplScalarArray x, ImplScalarArray y) const = 0;
217  virtual std::string getName() const = 0;
218 };
219 
220 } //namespace Details
221 } //namespace Ifpack2
222 
223 #endif
224 
virtual std::string getName() const =0
Get the name of the underlying preconditioner (&quot;Filu&quot;, &quot;Fildl&quot; or &quot;Fic&quot;)
Mix-in interface for preconditioners that can change their matrix after construction.
Definition: Ifpack2_Details_CanChangeMatrix.hpp:60
int getNumCompute() const
Get the number of times compute() was called.
Definition: Ifpack2_Details_FastILU_Base_def.hpp:305
virtual void checkLocalIC() const
Verify and print debug information about the underlying IC preconditioner.
Definition: Ifpack2_Details_FastILU_Base_def.hpp:355
double getComputeTime() const
Get the time spent in the last compute() call.
Definition: Ifpack2_Details_FastILU_Base_def.hpp:326
Kokkos::View< LocalOrdinal *, execution_space >::HostMirror OrdinalArrayHost
Array of LocalOrdinal on host.
Definition: Ifpack2_Details_FastILU_Base_decl.hpp:60
virtual int getNTrisol() const =0
Get the &quot;triangular solve iterations&quot; parameter.
virtual void applyLocalPrec(ImplScalarArray x, ImplScalarArray y) const =0
Apply the local preconditioner with 1-D views of the local parts of X and Y (one vector only) ...
device_type::execution_space execution_space
Kokkos execution space.
Definition: Ifpack2_Details_FastILU_Base_decl.hpp:46
double getCopyTime() const
Get the time spent deep copying local 3-array CRS out of the matrix.
Definition: Ifpack2_Details_FastILU_Base_def.hpp:340
virtual int getSweeps() const =0
Get the &quot;sweeps&quot; parameter.
double getInitializeTime() const
Get the time spent in the last initialize() call.
Definition: Ifpack2_Details_FastILU_Base_def.hpp:319
Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const
Get the range map of the matrix.
Definition: Ifpack2_Details_FastILU_Base_def.hpp:55
double getApplyTime() const
Get the time spent in the last apply() call.
Definition: Ifpack2_Details_FastILU_Base_def.hpp:333
Tpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > TCrsMatrix
Tpetra CRS matrix.
Definition: Ifpack2_Details_FastILU_Base_decl.hpp:52
Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getDomainMap() const
Get the domain map of the matrix.
Definition: Ifpack2_Details_FastILU_Base_def.hpp:47
Teuchos::RCP< const TRowMatrix > getMatrix() const
Get the current matrix.
Definition: Ifpack2_Details_FastILU_Base_def.hpp:291
virtual void checkLocalILU() const
Verify and print debug information about the underlying ILU preconditioner (only supported if this is...
Definition: Ifpack2_Details_FastILU_Base_def.hpp:347
Kokkos::View< LocalOrdinal *, execution_space > OrdinalArray
Array of LocalOrdinal on device.
Definition: Ifpack2_Details_FastILU_Base_decl.hpp:58
int getNumApply() const
Get the number of times apply() was called.
Definition: Ifpack2_Details_FastILU_Base_def.hpp:312
The base class of the Ifpack2 FastILU wrappers (Filu, Fildl and Fic)
Definition: Ifpack2_Details_FastILU_Base_decl.hpp:38
void setParameters(const Teuchos::ParameterList &List)
Validate parameters, and set defaults when parameters are not provided.
Definition: Ifpack2_Details_FastILU_Base_def.hpp:120
std::string description() const
Return a brief description of the preconditioner, in YAML format.
Definition: Ifpack2_Details_FastILU_Base_def.hpp:362
void compute()
Compute the preconditioner.
Definition: Ifpack2_Details_FastILU_Base_def.hpp:258
Node::device_type device_type
Kokkos device type.
Definition: Ifpack2_Details_FastILU_Base_decl.hpp:44
Interface for all Ifpack2 preconditioners.
Definition: Ifpack2_Preconditioner.hpp:74
Kokkos::View< ImplScalar *, execution_space > ImplScalarArray
Array of Scalar on device.
Definition: Ifpack2_Details_FastILU_Base_decl.hpp:62
FastILU_Base(Teuchos::RCP< const TRowMatrix > mat_)
Constructor.
Definition: Ifpack2_Details_FastILU_Base_def.hpp:31
bool isComputed() const
Whether compute() has been called since the last time the matrix&#39;s values or structure were changed...
Definition: Ifpack2_Details_FastILU_Base_def.hpp:283
Declaration of interface for preconditioners that can change their matrix after construction.
bool isInitialized() const
Whether initialize() has been called since the last time the matrix&#39;s structure was changed...
Definition: Ifpack2_Details_FastILU_Base_def.hpp:251
KokkosSparse::CrsMatrix< Scalar, LocalOrdinal, execution_space > KCrsMatrix
Kokkos CRS matrix.
Definition: Ifpack2_Details_FastILU_Base_decl.hpp:56
void initialize()
Initialize the preconditioner.
Definition: Ifpack2_Details_FastILU_Base_def.hpp:135
Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > TMultiVec
Tpetra multivector.
Definition: Ifpack2_Details_FastILU_Base_decl.hpp:54
Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::impl_scalar_type ImplScalar
Kokkos scalar type.
Definition: Ifpack2_Details_FastILU_Base_decl.hpp:48
Tpetra::RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > TRowMatrix
Tpetra row matrix.
Definition: Ifpack2_Details_FastILU_Base_decl.hpp:50
void setMatrix(const Teuchos::RCP< const TRowMatrix > &A)
Definition: Ifpack2_Details_FastILU_Base_def.hpp:388
virtual void initLocalPrec()=0
Construct the underlying preconditioner (localPrec_) using given params and then call localPrec_-&gt;ini...
void apply(const TMultiVec &X, TMultiVec &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=Teuchos::ScalarTraits< Scalar >::one(), Scalar beta=Teuchos::ScalarTraits< Scalar >::zero()) const
Apply the preconditioner.
Definition: Ifpack2_Details_FastILU_Base_def.hpp:62
int getNumInitialize() const
Get the number of times initialize() was called.
Definition: Ifpack2_Details_FastILU_Base_def.hpp:298
virtual void computeLocalPrec()=0
Get values array from the matrix and then call compute() on the underlying preconditioner.
virtual std::string getSpTrsvType() const =0
Get the name of triangular solve algorithm.