00001
00002
00003
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
00022
00023
00024
00025
00026 class SerialVector : public SingleChunkVector<double>,
00027 public LoadableVector<double>,
00028 public Describable
00029 {
00030 public:
00031
00032
00033 SerialVector(const VectorSpace<double>& vs);
00034
00035
00036
00037
00038 RCP<const VectorSpaceBase<double> > space() const {return vecSpace_.ptr();}
00039
00040
00041
00042
00043
00044 void setElement(int globalIndex, const double& value);
00045
00046
00047 void addToElement(int globalIndex, const double& value);
00048
00049
00050 void setElements(int numElems, const int* globalIndices,
00051 const double* values);
00052
00053
00054
00055 void addToElements(int numElems, const int* globalIndices,
00056 const double* values);
00057
00058
00059 void finalizeAssembly();
00060
00061
00062
00063
00064
00065 std::string description() const ;
00066
00067
00068
00069
00070
00071
00072
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
00084
00085
00086 virtual const double* dataPtr() const {return &(data_[0]);}
00087
00088 virtual double* dataPtr() {return &(data_[0]);}
00089
00090
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