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 //
00013 // This class provides a wrapper for the Aztec DVBR matrix data structure.
00014 //
00015 // Some functions return an int. This will be the ESI_error_code. It
00016 // will be 0 if there were no errors, 1 if an error occurred.
00017 //
00018 namespace fei_trilinos {
00019 
00020 class Aztec_BlockMap;
00021 
00022 class AztecDVBR_Matrix {
00023  
00024   public:
00025     // Constructor.
00026     AztecDVBR_Matrix(Aztec_BlockMap& map, int* update);
00027 
00028     //Copy constructor.
00029     AztecDVBR_Matrix(const AztecDVBR_Matrix& src);
00030 
00031     virtual ~AztecDVBR_Matrix ();
00032 
00033     //query functions.
00034 
00035     int getBlockMaps(Aztec_BlockMap** rowMap, Aztec_BlockMap** colMap);
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_Vector& x, Aztec_Vector& 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     //Aztec-specific functions:
00088     int* getUpdate() {return(update_);};
00089     int* getUpdate_index() {return(update_index_);};
00090     int* getData_org() {return(data_org_);};
00091 
00092   private:
00093     int inUpdate(int globalIndex, int& localIndex) const;
00094 
00095     void readAllocateInfo(FILE* infile, int*& num_nz_blocks, int*& blk_col_inds);
00096     void readMatrixData(FILE* infile);
00097 
00098     void calcRpntr();
00099     void calcBpntr(int* nzBlksPerRow);
00100     void setBindx(int nnzBlks, int* blkColInds);
00101     void calcIndx(int nnzBlks);
00102 
00103     int getBindxOffset(int blkInd, int bpntrStart, int bpntrEnd) const;
00104 
00105     void calcRemoteInds(int*& remoteInds, int& len);
00106     void getRemoteBlkSizes(int* remoteBlkSizes, int* remoteInds, int len);
00107     void insertList(int item, int*& list, int& len);
00108     void getValuesFromString(char *line, int len, double *values,
00109                              int lenValues);
00110     void messageAbort(const char* mesg) const;
00111 
00112     Aztec_BlockMap& amap_;
00113 
00114     AZ_MATRIX *Amat_;
00115 
00116     int N_update_;
00117     int* update_;
00118     int* external_;
00119     int* extern_index_;
00120     int* update_index_;
00121     int* data_org_;
00122     int* orderingUpdate_;
00123 
00124     bool isLoaded_;
00125     bool isAllocated_;
00126 
00127     int localNNZ_;
00128     int* nnzPerRow_;
00129 
00130     int numRemoteBlocks_;
00131     int* remoteInds_;
00132     int* remoteBlockSizes_;
00133 };
00134 
00135 }//namespace fei_trilinos
00136 
00137 #endif

Generated on Wed May 12 21:30:40 2010 for FEI by  doxygen 1.4.7