fei_AztecDVBR_Matrix.hpp

00001 #ifndef _fei_AztecDVBR_Matrix_hpp_
00002 #define _fei_AztecDVBR_Matrix_hpp_
00003 
00004 /*--------------------------------------------------------------------*/
00005 /*    Copyright 2005 Sandia Corporation.                              */
00006 /*    Under the terms of Contract DE-AC04-94AL85000, there is a       */
00007 /*    non-exclusive license for use of this work by or on behalf      */
00008 /*    of the U.S. Government.  Export of this program may require     */
00009 /*    a license from the United States Government.                    */
00010 /*--------------------------------------------------------------------*/
00011 
00012 #include <fei_SharedPtr.hpp>
00013 //
00014 // This class provides a wrapper for the Aztec DVBR matrix data structure.
00015 //
00016 // Some functions return an int. This will be the ESI_error_code. It
00017 // will be 0 if there were no errors, 1 if an error occurred.
00018 //
00019 namespace fei_trilinos {
00020 
00021 class Aztec_BlockMap;
00022 
00023 class AztecDVBR_Matrix {
00024  
00025   public:
00026     // Constructor.
00027     AztecDVBR_Matrix(fei::SharedPtr<Aztec_BlockMap> map);
00028 
00029     //Copy constructor.
00030     AztecDVBR_Matrix(const AztecDVBR_Matrix& src);
00031 
00032     virtual ~AztecDVBR_Matrix ();
00033 
00034     //query functions.
00035 
00036     int getNumBlocksPerRow(int blkRow, int& nnzBlksPerRow) const;
00037     int getNumNonzerosPerRow(int blkRow, int& nnzPerRow) const;
00038     int getNumBlocksPerRow(int* nnzBlksPerRow) const;
00039     int getNumNonzerosPerRow(int* nnzPerRow) const;
00040     int getBlockSize(int blkRow, int blkCol, int& ptRows, int& ptCols);
00041 
00042     // Mathematical functions.
00043     void matvec(const Aztec_LSVector& x, Aztec_LSVector& y) const;
00044 
00045     void put(double s);
00046 
00047     // ... to read matrix.
00048 
00049     int getBlockRow(int blk_row,
00050                     double* vals,
00051                     int* blk_col_inds,
00052                     int num_nz_blocks) const;
00053     
00054     // ... to write matrix.
00055 
00056     int putBlockRow(int blk_row,
00057                     double* vals,
00058                     int* blk_col_inds,
00059                     int num_nz_blocks) const;
00060 
00061     int sumIntoBlockRow(int blk_row,
00062                         double* vals,
00063                         int* blk_col_inds,
00064                         int num_nz_blocks) const;
00065  
00066     // configuration function.
00067     void allocate(int* num_nz_blocks, int* blk_col_inds);
00068 
00069     void loadComplete();
00070 
00071     bool isLoaded() const {return(isLoaded_);};
00072     void setLoaded(bool flag) {isLoaded_ = flag;};
00073     bool isAllocated() const {return(isAllocated_);};
00074     void setAllocated(bool flag) {isAllocated_ = flag;};
00075 
00076     AZ_MATRIX* getAZ_MATRIX_Ptr() const {return(Amat_);};
00077 
00078     bool readFromFile(const char *filename);
00079     bool writeToFile(const char *fileName) const;
00080 
00081     //numRemoteBlocks is the number of block-column-indices on this processor
00082     //that correspond to block-rows that reside on another processor.
00083     int getNumRemoteBlocks() {return(numRemoteBlocks_);};
00084     int* getRemoteBlockIndices() {return(remoteInds_);};
00085     int* getRemoteBlockSizes() {return(remoteBlockSizes_);};
00086 
00087     int* getUpdate_index() {return(update_index_);};
00088     int* getData_org() {return(data_org_);};
00089 
00090   private:
00091     int inUpdate(int globalIndex, int& localIndex) const;
00092 
00093     void readAllocateInfo(FILE* infile, int*& num_nz_blocks, int*& blk_col_inds);
00094     void readMatrixData(FILE* infile);
00095 
00096     void calcRpntr();
00097     void calcBpntr(int* nzBlksPerRow);
00098     void setBindx(int nnzBlks, int* blkColInds);
00099     void calcIndx(int nnzBlks);
00100 
00101     int getBindxOffset(int blkInd, int bpntrStart, int bpntrEnd) const;
00102 
00103     void calcRemoteInds(int*& remoteInds, int& len);
00104     void getRemoteBlkSizes(int* remoteBlkSizes, int* remoteInds, int len);
00105     void insertList(int item, int*& list, int& len);
00106     void getValuesFromString(char *line, int len, double *values,
00107                              int lenValues);
00108     void messageAbort(const char* mesg) const;
00109 
00110     fei::SharedPtr<Aztec_BlockMap> amap_;
00111 
00112     AZ_MATRIX *Amat_;
00113 
00114     int N_update_;
00115     int* external_;
00116     int* extern_index_;
00117     int* update_index_;
00118     int* data_org_;
00119     int* orderingUpdate_;
00120 
00121     bool isLoaded_;
00122     bool isAllocated_;
00123 
00124     int localNNZ_;
00125     int* nnzPerRow_;
00126 
00127     int numRemoteBlocks_;
00128     int* remoteInds_;
00129     int* remoteBlockSizes_;
00130 };
00131 
00132 }//namespace fei_trilinos
00133 
00134 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends
Generated on Wed Apr 13 10:08:23 2011 for FEI by  doxygen 1.6.3