fei_VectorTraits_LinSysCore.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_LinSysCore_hpp_
00010 #define _fei_VectorTraits_LinSysCore_hpp_
00011 
00012 
00013 #include <fei_VectorTraits.hpp>
00014 #include <fei_LinearSystemCore.hpp>
00015 
00016 namespace fei {
00017 
00021   template<>
00022   struct VectorTraits<LinearSystemCore>  {
00023 
00025     static const char* typeName()
00026       { return("LinearSystemCore"); }
00027 
00030     static int setValues(LinearSystemCore* vec, int firstLocalOffset,
00031        double scalar, bool isSolnVector=false)
00032       {
00033   if (isSolnVector) {
00034     //LinearSystemCore doesn't have a 'resetSolnVector()'.
00035     return(-1);
00036   }
00037   int err = vec->resetRHSVector(scalar);
00038   return(err);
00039       }
00040 
00044     static int putValuesIn(LinearSystemCore* vec,
00045          int firstLocalOffset,
00046          int numValues, const int* indices, const double* values,
00047                      bool sum_into,
00048          bool isSolnVector=false,
00049          int vectorIndex=0)
00050       {
00051   int err = 0;
00052   if (isSolnVector) {
00053           if (sum_into) {
00054             return(-1);//LinearSystemCore allows 'put' (overwrite) operations on
00055                //the soln-vector, but not 'sumInto'.
00056           }
00057           else {
00058       err = vec->putInitialGuess(indices, values, numValues);
00059           }
00060   }
00061   else {
00062           if (sum_into) {
00063             err = vec->sumIntoRHSVector(numValues, values, indices);
00064           }
00065           else {
00066       err = vec->putIntoRHSVector(numValues, values, indices);
00067           }
00068   }
00069   return(err);
00070       }
00071 
00075     static int copyOut(LinearSystemCore* vec,
00076            int firstLocalOffset,
00077            int numValues, const int* indices, double* values,
00078            bool isSolnVector=false,
00079            int vectorIndex=0)
00080       {
00081   int err = 0;
00082   if (isSolnVector) {
00083     for(int i=0; i<numValues; ++i) {
00084       if (vec->getSolnEntry(indices[i], values[i]) != 0) return(-1);
00085     }
00086   }
00087   else {
00088     err = vec->getFromRHSVector(numValues, values, indices);
00089   }
00090 
00091   return(err);
00092       }
00093 
00096     static int update(LinearSystemCore* vec,
00097           double a,
00098           const LinearSystemCore* x,
00099           double b)
00100     { return(-1); }
00101 
00102   };//struct VectorTraits
00103 }//namespace fei
00104 
00105 #endif // _fei_VectorTraits_LinSysCore_hpp_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends
Generated on Wed Apr 13 10:08:24 2011 for FEI by  doxygen 1.6.3