IFPACK  Development
 All Classes Files Functions Variables Enumerations Friends
Ifpack_CrsRiluk.h
00001 /*@HEADER
00002 // ***********************************************************************
00003 //
00004 //       Ifpack: Object-Oriented Algebraic Preconditioner Package
00005 //                 Copyright (2002) Sandia Corporation
00006 //
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00038 //
00039 // ***********************************************************************
00040 //@HEADER
00041 */
00042 
00043 #ifndef _IFPACK_CRSRILUK_H_
00044 #define _IFPACK_CRSRILUK_H_
00045 
00046 #include "Ifpack_ConfigDefs.h"
00047 #include "Ifpack_ScalingType.h"
00048 #include "Ifpack_IlukGraph.h"
00049 #include "Epetra_ConfigDefs.h"
00050 #include "Epetra_CompObject.h"
00051 #include "Epetra_Operator.h"
00052 #include "Epetra_CrsMatrix.h"
00053 #include "Epetra_Object.h"
00054 #include "Epetra_MultiVector.h"
00055 #include "Epetra_Vector.h"
00056 #include "Epetra_Map.h"
00057 class Epetra_Comm;
00058 class Epetra_VbrMatrix;
00059 class Epetra_RowMatrix;
00060 
00061 #include "Teuchos_RefCountPtr.hpp"
00062 
00063 namespace Teuchos {
00064   class ParameterList;
00065 }
00066 
00068 
00210 class Ifpack_CrsRiluk: public Epetra_Object, public Epetra_CompObject, public virtual Epetra_Operator {
00211       
00212   // Give ostream << function some access to private and protected data/functions.
00213 
00214   friend ostream& operator << (ostream& os, const Ifpack_CrsRiluk& A);
00215 
00216  public:
00218 
00223   Ifpack_CrsRiluk(const Ifpack_IlukGraph & Graph_in);
00224   
00226   Ifpack_CrsRiluk(const Ifpack_CrsRiluk & Matrix);
00227 
00229   virtual ~Ifpack_CrsRiluk();
00230 
00232 
00238   int InitValues(const Epetra_CrsMatrix &A);
00239 
00241 
00247 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES // FIXME LONG LONG
00248   int InitValues(const Epetra_VbrMatrix &A);
00249 #endif
00250 
00252   bool ValuesInitialized() const {return(ValuesInitialized_);};
00253 
00255   void SetRelaxValue( double RelaxValue) {RelaxValue_ = RelaxValue; return;}
00256 
00258   void SetAbsoluteThreshold( double Athresh) {Athresh_ = Athresh; return;}
00259 
00261   void SetRelativeThreshold( double Rthresh) {Rthresh_ = Rthresh; return;}
00262 
00264   void SetOverlapMode( Epetra_CombineMode OverlapMode) {OverlapMode_ = OverlapMode; return;}
00265 
00267   /* This method is only available if the Teuchos package is enabled.
00268      This method recognizes four parameter names: relax_value,
00269      absolute_threshold, relative_threshold and overlap_mode. These names are
00270      case insensitive, and in each case except overlap_mode, the ParameterEntry
00271      must have type double. For overlap_mode, the ParameterEntry must have
00272      type Epetra_CombineMode.
00273   */
00274   int SetParameters(const Teuchos::ParameterList& parameterlist,
00275                     bool cerr_warning_if_unused=false);
00276 
00278 
00286   int Factor();
00287 
00289   bool Factored() const {return(Factored_);};
00290   
00291 
00292   // Mathematical functions.
00293   
00294   
00296 
00306   int Solve(bool Trans, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00307 
00309 
00319   int Multiply(bool Trans, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00320 
00322 
00330   int Condest(bool Trans, double & ConditionNumberEstimate) const;
00331   // Attribute access functions
00332   
00334   double GetRelaxValue() {return RelaxValue_;}
00335 
00337   double GetAbsoluteThreshold() {return Athresh_;}
00338 
00340   double GetRelativeThreshold() {return Rthresh_;}
00341 
00343   Epetra_CombineMode GetOverlapMode() {return OverlapMode_;}
00344 
00345     
00346 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00347 
00348   int NumGlobalRows() const {return(Graph().NumGlobalRows());};
00349   
00351   int NumGlobalCols() const {return(Graph().NumGlobalCols());};
00352   
00354   int NumGlobalNonzeros() const {return(L().NumGlobalNonzeros()+U().NumGlobalNonzeros());};
00355 
00357   virtual int NumGlobalBlockDiagonals() const {return(Graph().NumGlobalBlockDiagonals());};
00358 #endif
00359 
00360   long long NumGlobalRows64() const {return(Graph().NumGlobalRows64());};
00361   long long NumGlobalCols64() const {return(Graph().NumGlobalCols64());};
00362   long long NumGlobalNonzeros64() const {return(L().NumGlobalNonzeros64()+U().NumGlobalNonzeros64());};
00363   virtual long long NumGlobalBlockDiagonals64() const {return(Graph().NumGlobalBlockDiagonals64());};
00364     
00366   int NumMyRows() const {return(Graph().NumMyRows());};
00367   
00369   int NumMyCols() const {return(Graph().NumMyCols());};
00370   
00372   int NumMyNonzeros() const {return(L().NumMyNonzeros()+U().NumMyNonzeros());};
00373   
00375   virtual int NumMyBlockDiagonals() const {return(Graph().NumMyBlockDiagonals());};
00376   
00378   virtual int NumMyDiagonals() const {return(NumMyDiagonals_);};
00379   
00381 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00382   int IndexBase() const {return(Graph().IndexBase());};
00383 #endif
00384   long long IndexBase64() const {return(Graph().IndexBase64());};
00385     
00387   const Ifpack_IlukGraph & Graph() const {return(Graph_);};
00388   
00390   const Epetra_CrsMatrix & L() const {return(*L_);};
00391     
00393   const Epetra_Vector & D() const {return(*D_);};
00394     
00396   const Epetra_CrsMatrix & U() const {return(*U_);};
00397 
00399 
00401     const char * Label() const {return(Epetra_Object::Label());};
00402     
00404 
00413   int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
00414 
00416 
00427   int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const {
00428     return(Multiply(Ifpack_CrsRiluk::UseTranspose(), X, Y));};
00429 
00431 
00444   int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const {
00445     return(Solve(Ifpack_CrsRiluk::UseTranspose(), X, Y));};
00446 
00448     double NormInf() const {return(0.0);};
00449 
00451     bool HasNormInf() const {return(false);};
00452 
00454     bool UseTranspose() const {return(UseTranspose_);};
00455 
00457     const Epetra_Map & OperatorDomainMap() const {return(U_->OperatorDomainMap());};
00458 
00460     const Epetra_Map & OperatorRangeMap() const{return(L_->OperatorRangeMap());};
00461 
00463     const Epetra_Comm & Comm() const{return(Comm_);};
00465 
00466  protected:
00467   void SetFactored(bool Flag) {Factored_ = Flag;};
00468   void SetValuesInitialized(bool Flag) {ValuesInitialized_ = Flag;};
00469   bool Allocated() const {return(Allocated_);};
00470   int SetAllocated(bool Flag) {Allocated_ = Flag; return(0);};
00471   int BlockGraph2PointGraph(const Epetra_CrsGraph & BG, Epetra_CrsGraph & PG, bool Upper);
00472   
00473  private:
00474   
00475   
00476   int AllocateCrs();
00477   int AllocateVbr();
00478   int InitAllValues(const Epetra_RowMatrix & A, int MaxNumEntries);
00479   int BlockMap2PointMap(const Epetra_BlockMap & BlockMap, Teuchos::RefCountPtr<Epetra_Map>* PointMap);
00480   int GenerateXY(bool Trans, 
00481          const Epetra_MultiVector& Xin, const Epetra_MultiVector& Yin,
00482          Teuchos::RefCountPtr<Epetra_MultiVector>* Xout, 
00483                  Teuchos::RefCountPtr<Epetra_MultiVector>* Yout) const;
00484   bool UserMatrixIsVbr_;
00485   bool UserMatrixIsCrs_;
00486   bool IsOverlapped_;
00487   const Ifpack_IlukGraph & Graph_;
00488   Teuchos::RefCountPtr<Epetra_Map> IlukRowMap_;
00489   Teuchos::RefCountPtr<Epetra_Map> IlukDomainMap_;
00490   Teuchos::RefCountPtr<Epetra_Map> IlukRangeMap_;
00491   Teuchos::RefCountPtr<const Epetra_Map> U_DomainMap_;
00492   Teuchos::RefCountPtr<const Epetra_Map> L_RangeMap_;
00493   const Epetra_Comm & Comm_;
00494   Teuchos::RefCountPtr<Epetra_CrsMatrix> L_;
00495   Teuchos::RefCountPtr<Epetra_CrsMatrix> U_;
00496   Teuchos::RefCountPtr<Epetra_CrsGraph> L_Graph_;
00497   Teuchos::RefCountPtr<Epetra_CrsGraph> U_Graph_;
00498   Teuchos::RefCountPtr<Epetra_Vector> D_;
00499   bool UseTranspose_;
00500 
00501   int NumMyDiagonals_;
00502   bool Allocated_;
00503   bool ValuesInitialized_;
00504   bool Factored_;
00505   double RelaxValue_;
00506   double Athresh_;
00507   double Rthresh_;
00508   mutable double Condest_;
00509 
00510   mutable Teuchos::RefCountPtr<Epetra_MultiVector> OverlapX_;
00511   mutable Teuchos::RefCountPtr<Epetra_MultiVector> OverlapY_;
00512   mutable Teuchos::RefCountPtr<Epetra_MultiVector> VbrX_;
00513   mutable Teuchos::RefCountPtr<Epetra_MultiVector> VbrY_;
00514   Epetra_CombineMode OverlapMode_;
00515 
00516 
00517 };
00518 
00520 ostream& operator << (ostream& os, const Ifpack_CrsRiluk& A);
00521 
00522 #endif /* _IFPACK_CRSRILUK_H_ */
 All Classes Files Functions Variables Enumerations Friends