fei_Aztec_LSVector.hpp

00001 #ifndef _fei_Aztec_LSVector_hpp_
00002 #define _fei_Aztec_LSVector_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 //
00015 // This class provides a vector that can be used with the AztecDMSR_matrix
00016 // and the AztecDVBR_Matrix.
00017 //
00018 // An important restriction to note:
00019 //
00020 // * An Aztec_LSVector can not be constructed until AFTER the AztecDMSR_Matrix
00021 //   (or AztecDVBR_Matrix) that it is to be used with has been completely
00022 //   initialized and filled (e.g., A.loadComplete() has been called (which
00023 //   means, most importantly, that AZ_transform has been called)). This is
00024 //   because the local data array for an aztec vector must be allocated
00025 //   with enough extra space to hold 'boundary elements' that are exchanged
00026 //   with other processors during the calculation of a parallel matrix-vector
00027 //   product, and we don't know how much memory that requires until after
00028 //   AZ_transform has been called.
00029 //
00030 // * Also, the calling code is responsible for keeping track of any 
00031 //   re-ordering that AZ_transform has done. i.e., Aztec_LSVector is just
00032 //   like a raw array with respect to indexing of entries. If v is an
00033 //   instantiation of an Aztec_LSVector, then v[9] literally returns the
00034 //   entry at position 9 (the 10th entry, since indexing is 0-based).
00035 //
00036 namespace fei_trilinos {
00037 
00038 class Aztec_Map;
00039 
00041 class Aztec_LSVector {
00042   public:
00043     // Constructor.
00044     Aztec_LSVector(fei::SharedPtr<Aztec_Map> map, int* data_org);
00045 
00046     Aztec_LSVector(const Aztec_LSVector& source);  // copy constructor
00047 
00048     virtual ~Aztec_LSVector ();
00049 
00050     Aztec_LSVector* newVector() const;
00051 
00052     // Mathematical functions.
00053     double dotProd (const Aztec_LSVector& y) const;
00054     void scale (double s);
00055     void addVec (double s, const Aztec_LSVector& c);
00056     double norm () const;
00057     double norm1 () const;
00058  
00059     // operator=
00060     Aztec_LSVector& operator = (const Aztec_LSVector& rhs);
00061     
00062     // Access functions.
00063     double& operator [] (int index);
00064     const double& operator [] (int index) const;
00065     
00066     void put (double scalar);
00067 
00068     const double* startPointer() const {return localCoeffs_;};
00069 
00070     //Special function
00071     bool readFromFile(const char *fileName);
00072     bool writeToFile(const char *fileName) const;
00073     
00074   protected:
00075     virtual void assign(const Aztec_LSVector& rhs);
00076     
00077   private:
00078     void checkInput();
00079     int inUpdate(int globalIndex, int& localIndex) const;
00080 
00081     fei::SharedPtr<Aztec_Map> amap_;
00082     double *localCoeffs_;        // local vector coefficients
00083     int length_;
00084 };
00085 
00086 }//namespace fei_trilinos
00087 
00088 #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