Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

cg.hpp

Go to the documentation of this file.
00001 //************************************************************************************//
00002 // Module       : cg.hpp
00003 // Date         : 9/14/01 (DLR)
00004 // Copyright    : 2001-2006 Copyright University Corporation for Atmospheric
00005 //                Research
00006 // Description  : Encapsulates the methods and data associated with
00007 //                a conjugate-gradient object.
00008 // Derived From : none.
00009 // Modifications: 7/21/03: converted to linked-list-based data structures
00010 //************************************************************************************//
00011 #if !defined(CG_HPP)
00012 #define CG_HPP
00013 
00014 #include "diagop.hpp"
00015 #include "identityop.hpp"
00016 #include "glop.hpp"
00017 #include "gttlist.hpp"
00018 #include "gtlist.hpp"
00019 #include "glinoplist.hpp"
00020 #include "gelemlist.hpp"
00021 #include "gtbuffer.hpp"
00022 #include "gs.hpp"
00023 
00024 enum CGType {CG_STANDARD, CG_REDUCED_VAR1, CG_REDUCED_VAR2};  // Types of CG solver algorithm
00025 extern char *s_cgerror_[] ;
00026 
00027 
00028 class CG 
00029 {
00030 public:
00031 enum              CGERRNO {CGERR_NONE=0    , CGERR_NULLOP  , CGERR_LISTSZERR, 
00032                            CGERR_BADITERNUM, CGERR_CONVERGE, CGERR_SOLVE   };
00033 
00034 
00035                   CG(CGType itype, GBOOL isNested=FALSE);
00036                   CG(GElemList *e, GLinOpList *A, GLinOpList *ROP, GVecList *x, GVecList *b, GS *comm, 
00037                      CGType itype=CG_STANDARD, GBOOL isNested=FALSE);
00038                  ~CG();
00039                   CG(const CG &a);
00040 void              operator=(const CG &);
00041 void              operator()(GElemList *e, GLinOpList *A, GLinOpList *ROP, GVecList *x, GVecList *b, GS *c) ;
00042 
00043 void              Quiet(GBOOL b);
00044 void              SetNoDSS(GVecList *rb);
00045 void              SetTolerance(GDOUBLE);
00046 void              SetMaxIterations(GINT );
00047 void              SetResidualChkNum(GINT );
00048 void              SetSolveType(CGType);
00049 void              SetPreconditioner(GLinOpList *op);
00050 void              SetComm(GS *op);
00051 GCHandle          InitComm(GDWBuffer  *n, GINT  nTotal);
00052 GCHandle          SetCommHandle(GCHandle hIn=NULL);
00053 GCHandle          SetIntermedCommHandle(GCHandle hIn);
00054 void              SetIntermedMask(GLinOpList *in);
00055 void              SetBdyValues (GVecList *bdy_vals);
00056 void              SetElems(GElemList *gelems);
00057 GDOUBLE           GetTolerance();
00058 GINT              GetMaxIterations();
00059 GINT              GetResidualChkNum();
00060 GINT              GetNumIterations();
00061 GDOUBLE           GetError();
00062 GDOUBLE           GetMinError();
00063 GDOUBLE           GetMaxError();
00064 GVector           *GetEucResidualHistory();
00065 GVector           *GetL2ResidualHistory();
00066 GINT              ErrNo();
00067 char              *ErrString();
00068 //GLinOpList      *GetPreconditioner();
00069 GVecList          &GetBdyValues ();
00070 
00071 GBOOL             SolveCG();
00072 
00073 
00074 
00075 private:
00076 // Private methods:
00077 GINT              SolveStandard();
00078 GBOOL             OpVec_prod(GVecList &in, GVecList &out);
00079 GINT              SolveReduced(CGType itype);
00080 //GBOOL           DSS_Intermediate(GLinOpList &in_A, GVecList &in_x, GVecList &out_x);
00081 GBOOL             DoDotProducts(GVecList &a1, GVecList a2[], GDOUBLE *ldot, GDOUBLE *dots, const GINT  ndot);
00082 void              ResetExpandables(GLinOpList *AA, GLinOpList *ROp);
00083 
00084 
00085 
00086 // Private data:
00087 GINT              MaxIterations;
00088 GINT              nResidualChk;
00089 GINT              numIterations;
00090 GINT              nIntermedProd;
00091 GINT              iErrType;
00092 GINT              nTotalNodes;
00093 GINT              bad_iter_number;
00094 GINT              nops;
00095 GINT              nprecon;
00096 GBOOL             bQuiet;
00097 GBOOL             bNested;
00098 GBOOL             bMaskAlloc;
00099 CGType            iSolveType;
00100 GDOUBLE        tolerance;
00101 GDOUBLE           minErr;
00102 GDOUBLE           maxErr;
00103 GDOUBLE           finErr;
00104 GVector           EucResidual_;
00105 GVector           L2Residual_;
00106 GDWBuffer         *glob_ids;
00107 GDBuffer          *imultiplicity;
00108 GCHandle          hDSOp;
00109 GCHandle          hDSOp_Intermed;
00110 GLinOpList        mask_Intermed;
00111 GS                *gsop;
00112 GElemList         *gelems_;       // element list
00113 GLinOpList        *A;             // operator to be inverted 
00114 GLinOpList        *ROp;           // operator multiplied by b to find RHS
00115 GVecList          *x;             // solution
00116 GVecList          *b;             // RHS operand
00117 GLinOpList        precon;         // preconditioner
00118 GVecList          xb;             // boundary solution
00119 GVecList          bnodss;         // RHS operand contrib which should not be DSS'd
00120 GVecList          intermed_soln;  // intermediate solution for nested case
00121 GVecList          intermed_vecp;  // intermediate vec products pointers for nested case
00122 GVecList          ytmp         ;  // intermediate temp space
00123 GLinOpList        intermed_op;    // list of pointers to intermediate solve's operators
00124 CG                **cg_intermed;  // intermediate solvers, one for each intermed product
00125 
00126 // temporary vectors:
00127 
00128 GVecList          rk;
00129 GVecList          wk;
00130 GVecList          qk;
00131 GVecList          sk;
00132 GVecList          zk;
00133 GVecList          msk;
00134 GVecList          mqk;
00135 GVecList          vk;
00136 
00137 };
00138 #endif
00139 

Generated on Wed Dec 21 16:00:48 2005 for Geophysics & Astrophysics Spectral Element Adaptive Refinement (GASpAR) 2D Code by  doxygen 1.4.4