00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef BLOCK_PCG_SOLVER_H
00030 #define BLOCK_PCG_SOLVER_H
00031
00032 #include "Epetra_ConfigDefs.h"
00033
00034 #include "AztecOO.h"
00035
00036 #include "ml_include.h"
00037 #include "ml_epetra_operator.h"
00038 #include "ml_epetra_utils.h"
00039
00040 #include "Epetra_BLAS.h"
00041 #include "Epetra_Comm.h"
00042 #include "Epetra_LAPACK.h"
00043 #include "Epetra_Map.h"
00044 #include "Epetra_MultiVector.h"
00045 #include "Epetra_Operator.h"
00046 #include "Epetra_RowMatrix.h"
00047
00048 #include "FortranRoutines.h"
00049
00050
00051 class BlockPCGSolver : public virtual Epetra_Operator {
00052
00053 private:
00054
00055 const Epetra_Comm &MyComm;
00056 const Epetra_BLAS callBLAS;
00057 const Epetra_LAPACK callLAPACK;
00058 const FortranRoutines callFortran;
00059
00060 const Epetra_Operator *K;
00061 Epetra_Operator *Prec;
00062
00063 bool mlPrec;
00064 ML *ml_handle;
00065 ML_Aggregate *ml_agg;
00066
00067 mutable AztecOO *vectorPCG;
00068
00069 double tolCG;
00070 int iterMax;
00071
00072 int verbose;
00073
00074 int AMG_NLevels;
00075
00076 mutable double *workSpace;
00077
00078 mutable int numSolve;
00079 mutable int maxIter;
00080 mutable int sumIter;
00081 mutable int minIter;
00082
00083
00084 BlockPCGSolver(const BlockPCGSolver &ref);
00085 BlockPCGSolver& operator=(const BlockPCGSolver &ref);
00086
00087 public:
00088
00089 BlockPCGSolver(const Epetra_Comm& _Com, const Epetra_Operator *KK,
00090 double _tol = 0.0, int _iMax = 0, int _verb = 0);
00091
00092 BlockPCGSolver(const Epetra_Comm& _Com, const Epetra_Operator *KK,
00093 Epetra_Operator *PP,
00094 double _tol = 0.0, int _iMax = 0, int _verb = 0);
00095
00096 ~BlockPCGSolver();
00097
00098 const char * Label() const { return "Epetra_Operator for Block PCG solver"; };
00099
00100 bool UseTranspose() const { return (false); };
00101 int SetUseTranspose(bool UseTranspose) { return 0; };
00102
00103 bool HasNormInf() const { return (false); };
00104 double NormInf() const { return (-1.0); };
00105
00106 int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const;
00107 int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const;
00108
00109 const Epetra_Comm& Comm() const { return MyComm; };
00110
00111 const Epetra_Map& OperatorDomainMap() const { return K->OperatorDomainMap(); };
00112 const Epetra_Map& OperatorRangeMap() const { return K->OperatorRangeMap(); };
00113
00114 int Solve(const Epetra_MultiVector &X, Epetra_MultiVector &Y, int blkSize) const;
00115
00116 const Epetra_Operator* getPreconditioner() const { return Prec; };
00117 void setPreconditioner(Epetra_Operator *PP);
00118
00119 void setAMGPreconditioner(int smoother = 1, int degree = 2, int numDofs = 1,
00120 const Epetra_MultiVector *Z = 0);
00121 int getAMG_NLevels() const { return AMG_NLevels; };
00122
00123 void setIterMax(int _iMax) { iterMax = (_iMax > 0) ? _iMax : 0; };
00124
00125 int getMaxIter() const { return maxIter; };
00126 double getAvgIter() const { return sumIter/((double) numSolve); };
00127 int getMinIter() const { return minIter; };
00128
00129 };
00130
00131 #endif