FEI Version of the Day
fei_VectorTraits_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_VectorTraits_Aztec_h_
00010 #define _fei_VectorTraits_Aztec_h_
00011 
00012 #ifdef HAVE_FEI_AZTECOO
00013 
00014 //
00015 //IMPORTANT NOTE: Make sure that wherever this file is included from, it
00016 //appears BEFORE any include of fei_base.hpp or fei_Vector.hpp !!!
00017 //
00018 #include <fei_VectorTraits.hpp>
00019 #include <fei_Include_Trilinos.hpp>
00020 
00021 namespace fei {
00028   template<>
00029   struct VectorTraits<Aztec_LSVector> {
00030     static const char* typeName()
00031       { return("fei::Aztec_LSVector"); }
00032 
00033     static int setValues(Aztec_LSVector* vec, int firstLocalOffset,
00034                          double scalar, bool isSolnVector=false)
00035       {
00036         return( vec->put(scalar) );
00037       }
00038 
00039     //note that incoming indices are point-entry indices, not block-indices.
00040     static int putValuesIn(Aztec_LSVector* vec,
00041                            int firstLocalOffset,
00042                            int numValues,
00043                            const int* indices,
00044                            const double* values,
00045                            bool sum_into,
00046                            bool isSolnVector=false,
00047                            int /*vectorIndex=0*/)
00048       {
00049         double* localVecValues = vec->startPointer();
00050         if (sum_into) {
00051           for(int i=0; i<numValues; ++i) {
00052             localVecValues[indices[i]-firstLocalOffset] += values[i];
00053           }
00054         }
00055         else {
00056           for(int i=0; i<numValues; ++i) {
00057             localVecValues[indices[i]-firstLocalOffset] = values[i];
00058           }
00059         }
00060         return(0);
00061       }
00062 
00063     //note that incoming indices are point-entry indices, not block-indices.
00064     static int copyOut(Aztec_LSVector* vec,
00065                        int firstLocalOffset,
00066                        int numValues, const int* indices, double* values,
00067                        bool isSolnVector=false,
00068                        int vectorIndex=0)
00069       {
00070         double* localVecValues = vec->startPointer();
00071         for(int i=0; i<numValues; ++i) {
00072           values[i] = localVecValues[indices[i]-firstLocalOffset];
00073         }
00074 
00075         return(0);
00076       }
00077 
00078     static double* getLocalCoefsPtr(Aztec_LSVector* vec,
00079                                     bool isSolnVector=false,
00080                                     int vectorIndex=0)
00081       {
00082         return(vec->startPointer());
00083       }
00084 
00085     static int update(Aztec_LSVector* vec,
00086                       double a,
00087                       const Aztec_LSVector* x,
00088                       double b)
00089     {
00090       vec->scale(b);
00091       vec->addVec(a, x);
00092       return(0);
00093     }
00094 
00095   };//struct VectorTraits<Aztec_LSVector>
00096 }//namespace fei
00097 
00098 #endif //HAVE_FEI_AZTECOO
00099 
00100 #endif // _fei_VectorTraits_Aztec_hpp_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends