PlayaEpetraVector.hpp

00001 /* @HEADER@ */
00002 //
00003  /* @HEADER@ */
00004 
00005 #ifndef PLAYA_EPETRAVECTOR_HPP
00006 #define PLAYA_EPETRAVECTOR_HPP
00007 
00008 #include "PlayaDefs.hpp"
00009 #include "PlayaPrintable.hpp"
00010 #include "PlayaVectorDecl.hpp"
00011 #include "PlayaLoadableVector.hpp"
00012 #include "PlayaSingleChunkVector.hpp"
00013 #include "Epetra_FEVector.h"
00014 #include "Epetra_Vector.h"
00015 #include "PlayaEpetraVectorSpace.hpp"
00016 
00017 
00018 namespace Playa
00019 {
00020 using Teuchos::RCP;
00024 class EpetraVector : public SingleChunkVector<double>,
00025                      public LoadableVector<double>,
00026                      public Printable,
00027                      public Teuchos::Describable
00028 {
00029 public:
00030 
00032   EpetraVector(const VectorSpace<double>& vs);
00033 
00036   EpetraVector(const VectorSpace<double>& vs,
00037     const RCP<Epetra_Vector>& vec);
00038 
00039 
00043   RCP< const VectorSpaceBase<double> > space() const {return vecSpace_.ptr();}
00045 
00049   virtual const double& operator[](int globalIndex) const 
00050     {return getElement(globalIndex);}
00051 
00053   virtual double& operator[](int globalIndex) ;
00055 
00059   void setElement(int globalIndex, const double& value);
00060 
00062   void addToElement(int globalIndex, const double& value);
00063 
00065   void setElements(int numElems, const int* globalIndices, 
00066     const double* values);
00067 
00068 
00070   void addToElements(int numElems, const int* globalIndices, 
00071     const double* values);
00072 
00074   void finalizeAssembly();
00076 
00080   const double& getElement(int globalIndex) const ;
00081 
00083   void getElements(const int* globalIndices, int numElems,
00084     Teuchos::Array<double>& elems) const ;
00086 
00090   void print(std::ostream& os) const ;
00092       
00093 
00095   const RCP<Epetra_Vector>& epetraVec() const 
00096     {return epetraVec_;}
00097 
00099   RCP<Epetra_Vector>& epetraVec() {return epetraVec_;}
00100 
00102   static const Epetra_Vector& getConcrete(const Playa::Vector<double>& tsfVec);
00104   static Epetra_Vector& getConcrete(Playa::Vector<double>& tsfVec);
00106   static Epetra_Vector* getConcretePtr(Playa::Vector<double>& tsfVec);
00107 
00108   
00110   virtual void update(const double& alpha, const VectorBase<double>* other,
00111     const double& gamma);
00112     
00113 
00115   virtual void update(
00116     const double& alpha, const VectorBase<double>* x,
00117     const double& beta, const VectorBase<double>* y,
00118     const double& gamma) ;
00119 
00121   virtual double dot(const VectorBase<double>* other) const ;
00122 
00124   virtual double norm2() const ;
00125 protected:    
00126 
00130   virtual const double* dataPtr() const {return &(epetraVec_->operator[](0));}
00132   virtual double* dataPtr() {return &(epetraVec_->operator[](0));}
00133 
00135   virtual int chunkSize() const {return numLocalElements_;}
00137 
00138 private:
00139 
00140   VectorSpace<double> vecSpace_;
00141 
00142   RCP<Epetra_Vector> epetraVec_;
00143 
00144   int numLocalElements_;
00145   
00146 };
00147   
00148 }
00149 
00150 
00151 #endif

doxygen