IFPACK  Development
 All Classes Namespaces Files Functions Variables Enumerations Friends Pages
Ifpack_CrsRiluk.h
1 /*@HEADER
2 // ***********************************************************************
3 //
4 // Ifpack: Object-Oriented Algebraic Preconditioner Package
5 // Copyright (2002) 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 _IFPACK_CRSRILUK_H_
44 #define _IFPACK_CRSRILUK_H_
45 
46 #if defined(Ifpack_SHOW_DEPRECATED_WARNINGS)
47 #ifdef __GNUC__
48 #warning "The Ifpack package is deprecated"
49 #endif
50 #endif
51 
52 #include "Ifpack_ConfigDefs.h"
53 #include "Ifpack_ScalingType.h"
54 #include "Ifpack_IlukGraph.h"
55 #include "Epetra_ConfigDefs.h"
56 #include "Epetra_CompObject.h"
57 #include "Epetra_Operator.h"
58 #include "Epetra_CrsMatrix.h"
59 #include "Epetra_Object.h"
60 #include "Epetra_MultiVector.h"
61 #include "Epetra_Vector.h"
62 #include "Epetra_Map.h"
63 class Epetra_Comm;
64 class Epetra_VbrMatrix;
65 class Epetra_RowMatrix;
66 
67 #include "Teuchos_RefCountPtr.hpp"
68 
69 namespace Teuchos {
70  class ParameterList;
71 }
72 
74 
216 class Ifpack_CrsRiluk: public Epetra_Object, public Epetra_CompObject, public virtual Epetra_Operator {
217 
218  // Give ostream << function some access to private and protected data/functions.
219 
220  friend std::ostream& operator << (std::ostream& os, const Ifpack_CrsRiluk& A);
221 
222  public:
224 
229  Ifpack_CrsRiluk(const Ifpack_IlukGraph & Graph_in);
230 
232  Ifpack_CrsRiluk(const Ifpack_CrsRiluk & Matrix);
233 
235  virtual ~Ifpack_CrsRiluk();
236 
238 
244  int InitValues(const Epetra_CrsMatrix &A);
245 
247 
253 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES // FIXME LONG LONG
254  int InitValues(const Epetra_VbrMatrix &A);
255 #endif
256 
258  bool ValuesInitialized() const {return(ValuesInitialized_);};
259 
261  void SetRelaxValue( double RelaxValue) {RelaxValue_ = RelaxValue; return;}
262 
264  void SetAbsoluteThreshold( double Athresh) {Athresh_ = Athresh; return;}
265 
267  void SetRelativeThreshold( double Rthresh) {Rthresh_ = Rthresh; return;}
268 
270  void SetOverlapMode( Epetra_CombineMode OverlapMode) {OverlapMode_ = OverlapMode; return;}
271 
273  /* This method is only available if the Teuchos package is enabled.
274  This method recognizes four parameter names: relax_value,
275  absolute_threshold, relative_threshold and overlap_mode. These names are
276  case insensitive, and in each case except overlap_mode, the ParameterEntry
277  must have type double. For overlap_mode, the ParameterEntry must have
278  type Epetra_CombineMode.
279  */
280  int SetParameters(const Teuchos::ParameterList& parameterlist,
281  bool cerr_warning_if_unused=false);
282 
284 
292  int Factor();
293 
295  bool Factored() const {return(Factored_);};
296 
297 
298  // Mathematical functions.
299 
300 
302 
312  int Solve(bool Trans, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
313 
315 
325  int Multiply(bool Trans, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
326 
328 
336  int Condest(bool Trans, double & ConditionNumberEstimate) const;
337  // Attribute access functions
338 
340  double GetRelaxValue() {return RelaxValue_;}
341 
343  double GetAbsoluteThreshold() {return Athresh_;}
344 
346  double GetRelativeThreshold() {return Rthresh_;}
347 
349  Epetra_CombineMode GetOverlapMode() {return OverlapMode_;}
350 
351 
352 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
353  int NumGlobalRows() const {return(Graph().NumGlobalRows());};
355 
357  int NumGlobalCols() const {return(Graph().NumGlobalCols());};
358 
360  int NumGlobalNonzeros() const {return(L().NumGlobalNonzeros()+U().NumGlobalNonzeros());};
361 
363  virtual int NumGlobalBlockDiagonals() const {return(Graph().NumGlobalBlockDiagonals());};
364 #endif
365 
366  long long NumGlobalRows64() const {return(Graph().NumGlobalRows64());};
367  long long NumGlobalCols64() const {return(Graph().NumGlobalCols64());};
368  long long NumGlobalNonzeros64() const {return(L().NumGlobalNonzeros64()+U().NumGlobalNonzeros64());};
369  virtual long long NumGlobalBlockDiagonals64() const {return(Graph().NumGlobalBlockDiagonals64());};
370 
372  int NumMyRows() const {return(Graph().NumMyRows());};
373 
375  int NumMyCols() const {return(Graph().NumMyCols());};
376 
378  int NumMyNonzeros() const {return(L().NumMyNonzeros()+U().NumMyNonzeros());};
379 
381  virtual int NumMyBlockDiagonals() const {return(Graph().NumMyBlockDiagonals());};
382 
384  virtual int NumMyDiagonals() const {return(NumMyDiagonals_);};
385 
387 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
388  int IndexBase() const {return(Graph().IndexBase());};
389 #endif
390  long long IndexBase64() const {return(Graph().IndexBase64());};
391 
393  const Ifpack_IlukGraph & Graph() const {return(Graph_);};
394 
396  const Epetra_CrsMatrix & L() const {return(*L_);};
397 
399  const Epetra_Vector & D() const {return(*D_);};
400 
402  const Epetra_CrsMatrix & U() const {return(*U_);};
403 
405 
407  const char * Label() const {return(Epetra_Object::Label());};
408 
410 
419  int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
420 
422 
433  int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const {
434  return(Multiply(Ifpack_CrsRiluk::UseTranspose(), X, Y));};
435 
437 
451  return(Solve(Ifpack_CrsRiluk::UseTranspose(), X, Y));};
452 
454  double NormInf() const {return(0.0);};
455 
457  bool HasNormInf() const {return(false);};
458 
460  bool UseTranspose() const {return(UseTranspose_);};
461 
463  const Epetra_Map & OperatorDomainMap() const {return(U_->OperatorDomainMap());};
464 
466  const Epetra_Map & OperatorRangeMap() const{return(L_->OperatorRangeMap());};
467 
469  const Epetra_Comm & Comm() const{return(Comm_);};
471 
472  protected:
473  void SetFactored(bool Flag) {Factored_ = Flag;};
474  void SetValuesInitialized(bool Flag) {ValuesInitialized_ = Flag;};
475  bool Allocated() const {return(Allocated_);};
476  int SetAllocated(bool Flag) {Allocated_ = Flag; return(0);};
477  int BlockGraph2PointGraph(const Epetra_CrsGraph & BG, Epetra_CrsGraph & PG, bool Upper);
478 
479  private:
480 
481 
482  int AllocateCrs();
483  int AllocateVbr();
484  int InitAllValues(const Epetra_RowMatrix & A, int MaxNumEntries);
485  int BlockMap2PointMap(const Epetra_BlockMap & BlockMap, Teuchos::RefCountPtr<Epetra_Map>* PointMap);
486  int GenerateXY(bool Trans,
487  const Epetra_MultiVector& Xin, const Epetra_MultiVector& Yin,
488  Teuchos::RefCountPtr<Epetra_MultiVector>* Xout,
489  Teuchos::RefCountPtr<Epetra_MultiVector>* Yout) const;
490  bool UserMatrixIsVbr_;
491  bool UserMatrixIsCrs_;
492  bool IsOverlapped_;
493  const Ifpack_IlukGraph & Graph_;
494  Teuchos::RefCountPtr<Epetra_Map> IlukRowMap_;
495  Teuchos::RefCountPtr<Epetra_Map> IlukDomainMap_;
496  Teuchos::RefCountPtr<Epetra_Map> IlukRangeMap_;
497  Teuchos::RefCountPtr<const Epetra_Map> U_DomainMap_;
498  Teuchos::RefCountPtr<const Epetra_Map> L_RangeMap_;
499  const Epetra_Comm & Comm_;
500  Teuchos::RefCountPtr<Epetra_CrsMatrix> L_;
501  Teuchos::RefCountPtr<Epetra_CrsMatrix> U_;
502  Teuchos::RefCountPtr<Epetra_CrsGraph> L_Graph_;
503  Teuchos::RefCountPtr<Epetra_CrsGraph> U_Graph_;
504  Teuchos::RefCountPtr<Epetra_Vector> D_;
505  bool UseTranspose_;
506 
507  int NumMyDiagonals_;
508  bool Allocated_;
509  bool ValuesInitialized_;
510  bool Factored_;
511  double RelaxValue_;
512  double Athresh_;
513  double Rthresh_;
514  mutable double Condest_;
515 
516  mutable Teuchos::RefCountPtr<Epetra_MultiVector> OverlapX_;
517  mutable Teuchos::RefCountPtr<Epetra_MultiVector> OverlapY_;
518  mutable Teuchos::RefCountPtr<Epetra_MultiVector> VbrX_;
519  mutable Teuchos::RefCountPtr<Epetra_MultiVector> VbrY_;
520  Epetra_CombineMode OverlapMode_;
521 
522 
523 };
524 
526 std::ostream& operator << (std::ostream& os, const Ifpack_CrsRiluk& A);
527 
528 #endif /* _IFPACK_CRSRILUK_H_ */
int Multiply(bool Trans, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of multiplying U, D and L in that order on an Epetra_MultiVector X in Y...
double GetRelaxValue()
Get RILU(k) relaxation parameter.
int NumMyNonzeros() const
Returns the number of nonzero entries in the local graph.
Ifpack_CrsRiluk: A class for constructing and using an incomplete lower/upper (ILU) factorization of ...
int Condest(bool Trans, double &ConditionNumberEstimate) const
Returns the maximum over all the condition number estimate for each local ILU set of factors...
Epetra_CombineMode GetOverlapMode()
Get overlap mode type.
double NormInf() const
Returns 0.0 because this class cannot compute Inf-norm.
const Epetra_CrsMatrix & L() const
Returns the address of the L factor associated with this factored matrix.
const char * Label() const
Returns a character string describing the operator.
const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator.
void SetOverlapMode(Epetra_CombineMode OverlapMode)
Set overlap mode type.
Ifpack_IlukGraph: A class for constructing level filled graphs for use with ILU(k) class precondition...
int NumGlobalCols() const
Returns the number of global matrix columns.
void SetAbsoluteThreshold(double Athresh)
Set absolute threshold value.
const Epetra_Comm & Comm() const
Returns the Epetra_BlockMap object associated with the range of this matrix operator.
void SetRelativeThreshold(double Rthresh)
Set relative threshold value.
int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of a Epetra_Operator inverse applied to an Epetra_MultiVector X in Y...
Ifpack_ScalingType enumerable type.
const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this operator.
int SetParameters(const Teuchos::ParameterList &parameterlist, bool cerr_warning_if_unused=false)
Set parameters using a Teuchos::ParameterList object.
int NumMyCols() const
Returns the number of local matrix columns.
int NumGlobalRows() const
Returns the number of global matrix rows.
int InitValues(const Epetra_CrsMatrix &A)
Initialize L and U with values from user matrix A.
const Epetra_CrsMatrix & U() const
Returns the address of the L factor associated with this factored matrix.
double GetAbsoluteThreshold()
Get absolute threshold value.
virtual int NumGlobalBlockDiagonals() const
Returns the number of diagonal entries found in the global input graph.
int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of a Epetra_Operator applied to a Epetra_MultiVector X in Y.
int Solve(bool Trans, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of a Ifpack_CrsRiluk forward/back solve on a Epetra_MultiVector X in Y (works for ...
int IndexBase() const
Returns the index base for row and column indices for this graph.
friend std::ostream & operator<<(std::ostream &os, const Ifpack_CrsRiluk &A)
&lt;&lt; operator will work for Ifpack_CrsRiluk.
int NumGlobalNonzeros() const
Returns the number of nonzero entries in the global graph.
bool HasNormInf() const
Returns false because this class cannot compute an Inf-norm.
bool Factored() const
If factor is completed, this query returns true, otherwise it returns false.
int NumMyRows() const
Returns the number of local matrix rows.
bool ValuesInitialized() const
If values have been initialized, this query returns true, otherwise it returns false.
void SetRelaxValue(double RelaxValue)
Set RILU(k) relaxation parameter.
const Epetra_Vector & D() const
Returns the address of the D factor associated with this factored matrix.
bool UseTranspose() const
Returns the current UseTranspose setting.
Epetra_CombineMode
double GetRelativeThreshold()
Get relative threshold value.
int SetUseTranspose(bool UseTranspose_in)
If set true, transpose of this operator will be applied.
virtual int NumMyBlockDiagonals() const
Returns the number of diagonal entries found in the local input graph.
virtual ~Ifpack_CrsRiluk()
Ifpack_CrsRiluk Destructor.
virtual int NumMyDiagonals() const
Returns the number of nonzero diagonal values found in matrix.
int Factor()
Compute ILU factors L and U using the specified graph, diagonal perturbation thresholds and relaxatio...
const Ifpack_IlukGraph & Graph() const
returns the address of the Ifpack_IlukGraph associated with this factored matrix. ...
Ifpack_CrsRiluk(const Ifpack_IlukGraph &Graph_in)
Ifpack_CrsRiluk constuctor with variable number of indices per row.