FEI Version of the Day
fei_MatrixTraits_Aztec.hpp
00001 /*--------------------------------------------------------------------*/
00002 /*    Copyright 2005 Sandia Corporation.                              */
00003 /*    Under the terms of Contract DE-AC04-94AL85000, there is a       */
00004 /*    non-exclusive license for use of this work by or on behalf      */
00005 /*    of the U.S. Government.  Export of this program may require     */
00006 /*    a license from the United States Government.                    */
00007 /*--------------------------------------------------------------------*/
00008 
00009 #ifndef _fei_MatrixTraits_Aztec_hpp_
00010 #define _fei_MatrixTraits_Aztec_hpp_
00011 
00012 #include <fei_trilinos_macros.hpp>
00013 
00014 #ifdef HAVE_FEI_AZTECOO
00015 
00016 //
00017 //IMPORTANT NOTE: Make sure that wherever this file is included from, it
00018 //appears BEFORE any include of fei_Vector_Impl.hpp or fei_Matrix_Impl.hpp !!!
00019 //
00020 #include <fei_MatrixTraits.hpp>
00021 #include <snl_fei_BlockMatrixTraits.hpp>
00022 #include <fei_VectorTraits_Aztec.hpp>
00023 #include <fei_Include_Trilinos.hpp>
00024 #include <fei_Vector_Impl.hpp>
00025 
00026 namespace fei {
00033   template<>
00034   struct MatrixTraits<AztecDMSR_Matrix> {
00035     static const char* typeName()
00036       { return("fei::AztecDMSR_Matrix"); }
00037 
00038     static int setValues(AztecDMSR_Matrix* mat, double scalar)
00039       {
00040         return( mat->put(scalar) );
00041       }
00042 
00043     static int getNumLocalRows(AztecDMSR_Matrix* mat, int& numRows)
00044     {
00045       numRows = mat->getAztec_Map().localSize();
00046       return(0);
00047     }
00048 
00049     static int getRowLength(AztecDMSR_Matrix* mat, int row, int& length)
00050       {
00051         length = mat->rowLength(row);
00052         if (length < 0) return(-1);
00053         return( 0 );
00054       }
00055 
00056     static int copyOutRow(AztecDMSR_Matrix* mat,
00057                       int row, int len, double* coefs, int* indices)
00058       {
00059         int dummy;
00060         mat->getRow(row, dummy, coefs, indices);
00061         return(0);
00062       }
00063 
00064     static int putValuesIn(AztecDMSR_Matrix* mat,
00065                      int numRows, const int* rows,
00066                      int numCols, const int* cols,
00067                      const double* const* values,
00068                            bool sum_into)
00069       {
00070         int err = 0;
00071         if (sum_into) {
00072           err = mat->sumIntoRow(numRows, rows, numCols, cols, coefs);
00073         }
00074         else {
00075           for(int i=0; i<numRows; ++i) {
00076             err = mat->putRow(rows[i], numCols, values[i], cols);
00077             if (err != 0) {
00078               return(err);
00079             }
00080           }
00081         }
00082         return(err);
00083       }
00084 
00085     static int globalAssemble(AztecDMSR_Matrix* mat)
00086     {
00087       if (!mat->isFilled()) {
00088         int err = mat->fillComplete();
00089         if (err != 0) {
00090           FEI_CERR << "MatrixTraits<AztecDMSR_Matrix>::globalAssemble"
00091                    << " ERROR in mat->fillComplete" << FEI_ENDL;
00092           return(-1);
00093         }
00094       }
00095 
00096       return( 0 );
00097     }
00098 
00099     static int matvec(AztecDMSR_Matrix* mat,
00100                       fei::Vector* x,
00101                       fei::Vector* y)
00102     {
00103       fei::Vector_Impl<Aztec_LSVector>* avx =
00104         dynamic_cast<fei::Vector_Impl<Aztec_LSVector>* >(x);
00105       fei::Vector_Impl<Aztec_LSVector>* avy =
00106         dynamic_cast<fei::Vector_Impl<Aztec_LSVector>* >(y);
00107 
00108       if (avx == NULL || avy == NULL) {
00109         return(-1);
00110       }
00111 
00112       Aztec_LSVector* ax = avx->getUnderlyingVector();
00113       Aztec_LSVector* ay = avy->getUnderlyingVector();
00114 
00115       return( mat->matvec(*ax, *ay) );
00116     }
00117 
00118   };//struct MatrixTraits<AztecDMSR_Matrix>
00119 }//namespace fei
00120 
00121 namespace snl_fei {
00128   template<>
00129   struct BlockMatrixTraits<AztecDVBR_Matrix> {
00130     static const char* typeName()
00131       { return("fei::AztecDVBR_Matrix"); }
00132 
00133     static int putScalar(AztecDVBR_Matrix* mat, double scalar)
00134       {
00135         return( mat->put(scalar) );
00136       }
00137 
00138     static int getRowLength(AztecDVBR_Matrix* mat, int row, int& length)
00139       {
00140         return(-1);
00141       }
00142 
00143     static int getPointRowLength(AztecDVBR_Matrix* mat, int row, int& length)
00144     {
00145       return(-1);
00146     }
00147 
00148     static int copyOutRow(AztecDVBR_Matrix* mat,
00149                           int row, int numBlkCols,
00150                           int rowDim,
00151                           int* blkCols,
00152                           int* colDims,
00153                           double* coefs,
00154                           int coefsLen,
00155                           int& blkRowLength)
00156       {
00157         return(-1);
00158       }
00159 
00160     static int copyOutPointRow(AztecDVBR_Matrix* mat,
00161                                int firstLocalOffset,
00162                                int row,
00163                                int len,
00164                                double* coefs,
00165                                int* indices,
00166                                int& rowLength)
00167       {
00168         return(-1);
00169       }
00170 
00171     static int sumIn(AztecDVBR_Matrix* mat,
00172                      int blockRow,
00173                      int rowDim,
00174                      int numBlockCols,
00175                      const int* blockCols,
00176                      const int* colDims,
00177                      int LDA,
00178                      const double* values)
00179     {
00180       return(-1);
00181     }
00182 
00183     static int copyIn(AztecDVBR_Matrix* mat,
00184                       int blockRow,
00185                       int rowDim,
00186                       int numBlockCols,
00187                       const int* blockCols,
00188                       const int* colDims,
00189                       int LDA,
00190                       const double* values)
00191     {
00192       return(-1);
00193     }
00194 
00195     static int sumIn(AztecDVBR_Matrix* mat,
00196                      int row,
00197                      int rowDim,
00198                      int numCols,
00199                      const int* cols,
00200                      const int* LDAs,
00201                      const int* colDims,
00202                      const double* const* values)
00203       {
00204         return(-1);
00205       }
00206 
00207     static int copyIn(AztecDVBR_Matrix* mat,
00208                       int row,
00209                       int rowDim,
00210                       int numCols,
00211                       const int* cols,
00212                       const int* LDAs,
00213                       const int* colDims,
00214                       const double* const* values)
00215       {
00216         return(-1);
00217       }
00218 
00219     static int globalAssemble(AztecDVBR_Matrix* mat)
00220     {
00221       return( mat->loadComplete() );
00222     }
00223   };//struct BlockMatrixTraits<AztecDVBR_Matrix>
00224 }//namespace snl_fei
00225 #endif //HAVE_FEI_AZTECOO
00226 #endif // _fei_MatrixTraits_Aztec_hpp_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends