PlayaSerialVector.hpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 //
00003  /* @HEADER@ */
00004 
00005 #ifndef PLAYA_SERIAL_VECTOR_HPP
00006 #define PLAYA_SERIAL_VECTOR_HPP
00007 
00008 #include "PlayaDefs.hpp"
00009 #include "PlayaSingleChunkVector.hpp"
00010 #include "PlayaLoadableVector.hpp"
00011 #include "PlayaVectorSpaceDecl.hpp"
00012 #include "Teuchos_Array.hpp"
00013 
00014 namespace Playa
00015 {
00016 using namespace Teuchos;
00017 
00018 template <class Scalar> class Vector;
00019 
00020 /**
00021  * Playa implementation of a serial vector, implementing the LoadableVector
00022  * interface allowing an application to access elements. 
00023  * If created in SPMD, this will be replicated on
00024  * all processors.
00025  */
00026 class SerialVector : public SingleChunkVector<double>,
00027                      public LoadableVector<double>,
00028                      public Describable
00029 {
00030 public:
00031 
00032   /** Construct with a vector space. */
00033   SerialVector(const VectorSpace<double>& vs);
00034 
00035   /** \name VectorBase interface */
00036   //@{
00037   /** Access to the space in which this vector lives */
00038   RCP<const VectorSpaceBase<double> > space() const {return vecSpace_.ptr();}
00039   //@}
00040 
00041   /** \name LoadableVector interface */
00042   //@{
00043   /** set a single element */
00044   void setElement(int globalIndex, const double& value);
00045 
00046   /** add to a single element */
00047   void addToElement(int globalIndex, const double& value);
00048 
00049   /** set a group of elements */
00050   void setElements(int numElems, const int* globalIndices, 
00051     const double* values);
00052 
00053 
00054   /** add to a group of elements */
00055   void addToElements(int numElems, const int* globalIndices, 
00056     const double* values);
00057 
00058   /** */
00059   void finalizeAssembly();
00060   //@}
00061 
00062   /** \name Diagnostics */
00063   //@{
00064   /** */
00065   std::string description() const ;
00066   //@}
00067 
00068 
00069 
00070   /** \name Access through global indices */
00071   //@{
00072   /** get the batch of elements at the given global indices */
00073   void getElements(const int* globalIndices, int numElems,
00074     Array<double>& elems) const ;
00075   //@}
00076 
00077   /** */
00078   static const SerialVector* getConcrete(const Vector<double>& x);
00079   /** */
00080   static SerialVector* getConcrete(Vector<double>& x);
00081 
00082       
00083  /** \name Single chunk data access interface */
00084   //@{
00085   /** */
00086   virtual const double* dataPtr() const {return &(data_[0]);}
00087   /** */
00088   virtual double* dataPtr() {return &(data_[0]);}
00089 
00090   /** Size of the (single) chunk of data values */
00091   virtual int chunkSize() const {return dim_;}
00092   //@}
00093 
00094 
00095 
00096   
00097 private:
00098 
00099   VectorSpace<double> vecSpace_;
00100 
00101   Array<double> data_;
00102 
00103   int dim_;
00104 };
00105   
00106 }
00107 
00108 
00109 #endif

Site Contact