|
IFPACK Development
|
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 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 //@HEADER 00028 */ 00029 00030 #ifndef _IFPACK_CRSRILUK_H_ 00031 #define _IFPACK_CRSRILUK_H_ 00032 00033 #include "Ifpack_ConfigDefs.h" 00034 #include "Ifpack_ScalingType.h" 00035 #include "Ifpack_IlukGraph.h" 00036 #include "Epetra_CompObject.h" 00037 #include "Epetra_Operator.h" 00038 #include "Epetra_CrsMatrix.h" 00039 #include "Epetra_Object.h" 00040 #include "Epetra_MultiVector.h" 00041 #include "Epetra_Vector.h" 00042 #include "Epetra_Map.h" 00043 class Epetra_Comm; 00044 class Epetra_VbrMatrix; 00045 class Epetra_RowMatrix; 00046 00047 #include "Teuchos_RefCountPtr.hpp" 00048 00049 namespace Teuchos { 00050 class ParameterList; 00051 } 00052 00054 00196 class Ifpack_CrsRiluk: public Epetra_Object, public Epetra_CompObject, public virtual Epetra_Operator { 00197 00198 // Give ostream << function some access to private and protected data/functions. 00199 00200 friend ostream& operator << (ostream& os, const Ifpack_CrsRiluk& A); 00201 00202 public: 00204 00209 Ifpack_CrsRiluk(const Ifpack_IlukGraph & Graph_in); 00210 00212 Ifpack_CrsRiluk(const Ifpack_CrsRiluk & Matrix); 00213 00215 virtual ~Ifpack_CrsRiluk(); 00216 00218 00224 int InitValues(const Epetra_CrsMatrix &A); 00225 00227 00233 int InitValues(const Epetra_VbrMatrix &A); 00234 00236 bool ValuesInitialized() const {return(ValuesInitialized_);}; 00237 00239 void SetRelaxValue( double RelaxValue) {RelaxValue_ = RelaxValue; return;} 00240 00242 void SetAbsoluteThreshold( double Athresh) {Athresh_ = Athresh; return;} 00243 00245 void SetRelativeThreshold( double Rthresh) {Rthresh_ = Rthresh; return;} 00246 00248 void SetOverlapMode( Epetra_CombineMode OverlapMode) {OverlapMode_ = OverlapMode; return;} 00249 00251 /* This method is only available if the Teuchos package is enabled. 00252 This method recognizes four parameter names: relax_value, 00253 absolute_threshold, relative_threshold and overlap_mode. These names are 00254 case insensitive, and in each case except overlap_mode, the ParameterEntry 00255 must have type double. For overlap_mode, the ParameterEntry must have 00256 type Epetra_CombineMode. 00257 */ 00258 int SetParameters(const Teuchos::ParameterList& parameterlist, 00259 bool cerr_warning_if_unused=false); 00260 00262 00270 int Factor(); 00271 00273 bool Factored() const {return(Factored_);}; 00274 00275 00276 // Mathematical functions. 00277 00278 00280 00290 int Solve(bool Trans, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const; 00291 00293 00303 int Multiply(bool Trans, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const; 00304 00306 00314 int Condest(bool Trans, double & ConditionNumberEstimate) const; 00315 // Atribute access functions 00316 00318 double GetRelaxValue() {return RelaxValue_;} 00319 00321 double GetAbsoluteThreshold() {return Athresh_;} 00322 00324 double GetRelativeThreshold() {return Rthresh_;} 00325 00327 Epetra_CombineMode GetOverlapMode() {return OverlapMode_;} 00328 00329 00331 int NumGlobalRows() const {return(Graph().NumGlobalRows());}; 00332 00334 int NumGlobalCols() const {return(Graph().NumGlobalCols());}; 00335 00337 int NumGlobalNonzeros() const {return(L().NumGlobalNonzeros()+U().NumGlobalNonzeros());}; 00338 00340 virtual int NumGlobalBlockDiagonals() const {return(Graph().NumGlobalBlockDiagonals());}; 00341 00343 int NumMyRows() const {return(Graph().NumMyRows());}; 00344 00346 int NumMyCols() const {return(Graph().NumMyCols());}; 00347 00349 int NumMyNonzeros() const {return(L().NumMyNonzeros()+U().NumMyNonzeros());}; 00350 00352 virtual int NumMyBlockDiagonals() const {return(Graph().NumMyBlockDiagonals());}; 00353 00355 virtual int NumMyDiagonals() const {return(NumMyDiagonals_);}; 00356 00358 int IndexBase() const {return(Graph().IndexBase());}; 00359 00361 const Ifpack_IlukGraph & Graph() const {return(Graph_);}; 00362 00364 const Epetra_CrsMatrix & L() const {return(*L_);}; 00365 00367 const Epetra_Vector & D() const {return(*D_);}; 00368 00370 const Epetra_CrsMatrix & U() const {return(*U_);}; 00371 00373 00375 const char * Label() const {return(Epetra_Object::Label());}; 00376 00378 00387 int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);}; 00388 00390 00401 int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const { 00402 return(Multiply(Ifpack_CrsRiluk::UseTranspose(), X, Y));}; 00403 00405 00418 int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const { 00419 return(Solve(Ifpack_CrsRiluk::UseTranspose(), X, Y));}; 00420 00422 double NormInf() const {return(0.0);}; 00423 00425 bool HasNormInf() const {return(false);}; 00426 00428 bool UseTranspose() const {return(UseTranspose_);}; 00429 00431 const Epetra_Map & OperatorDomainMap() const {return(U_->OperatorDomainMap());}; 00432 00434 const Epetra_Map & OperatorRangeMap() const{return(L_->OperatorRangeMap());}; 00435 00437 const Epetra_Comm & Comm() const{return(Comm_);}; 00439 00440 protected: 00441 void SetFactored(bool Flag) {Factored_ = Flag;}; 00442 void SetValuesInitialized(bool Flag) {ValuesInitialized_ = Flag;}; 00443 bool Allocated() const {return(Allocated_);}; 00444 int SetAllocated(bool Flag) {Allocated_ = Flag; return(0);}; 00445 int BlockGraph2PointGraph(const Epetra_CrsGraph & BG, Epetra_CrsGraph & PG, bool Upper); 00446 00447 private: 00448 00449 00450 int AllocateCrs(); 00451 int AllocateVbr(); 00452 int InitAllValues(const Epetra_RowMatrix & A, int MaxNumEntries); 00453 int BlockMap2PointMap(const Epetra_BlockMap & BlockMap, Teuchos::RefCountPtr<Epetra_Map>* PointMap); 00454 int GenerateXY(bool Trans, 00455 const Epetra_MultiVector& Xin, const Epetra_MultiVector& Yin, 00456 Teuchos::RefCountPtr<Epetra_MultiVector>* Xout, 00457 Teuchos::RefCountPtr<Epetra_MultiVector>* Yout) const; 00458 bool UserMatrixIsVbr_; 00459 bool UserMatrixIsCrs_; 00460 bool IsOverlapped_; 00461 const Ifpack_IlukGraph & Graph_; 00462 Teuchos::RefCountPtr<Epetra_Map> IlukRowMap_; 00463 Teuchos::RefCountPtr<Epetra_Map> IlukDomainMap_; 00464 Teuchos::RefCountPtr<Epetra_Map> IlukRangeMap_; 00465 Teuchos::RefCountPtr<const Epetra_Map> U_DomainMap_; 00466 Teuchos::RefCountPtr<const Epetra_Map> L_RangeMap_; 00467 const Epetra_Comm & Comm_; 00468 Teuchos::RefCountPtr<Epetra_CrsMatrix> L_; 00469 Teuchos::RefCountPtr<Epetra_CrsMatrix> U_; 00470 Teuchos::RefCountPtr<Epetra_CrsGraph> L_Graph_; 00471 Teuchos::RefCountPtr<Epetra_CrsGraph> U_Graph_; 00472 Teuchos::RefCountPtr<Epetra_Vector> D_; 00473 bool UseTranspose_; 00474 00475 int NumMyDiagonals_; 00476 bool Allocated_; 00477 bool ValuesInitialized_; 00478 bool Factored_; 00479 double RelaxValue_; 00480 double Athresh_; 00481 double Rthresh_; 00482 mutable double Condest_; 00483 00484 mutable Teuchos::RefCountPtr<Epetra_MultiVector> OverlapX_; 00485 mutable Teuchos::RefCountPtr<Epetra_MultiVector> OverlapY_; 00486 mutable Teuchos::RefCountPtr<Epetra_MultiVector> VbrX_; 00487 mutable Teuchos::RefCountPtr<Epetra_MultiVector> VbrY_; 00488 Epetra_CombineMode OverlapMode_; 00489 00490 00491 }; 00492 00494 ostream& operator << (ostream& os, const Ifpack_CrsRiluk& A); 00495 00496 #endif /* _IFPACK_CRSRILUK_H_ */
1.7.4