Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef TSF_SERIAL_VECTOR_HPP
00028 #define TSF_SERIAL_VECTOR_HPP
00029
00030 #include "SundanceDefs.hpp"
00031 #include "SundancePrintable.hpp"
00032 #include "TSFIndexableVector.hpp"
00033 #include "TSFVectorDecl.hpp"
00034 #include "TSFRawDataAccessibleVector.hpp"
00035 #include "Thyra_VectorDefaultBase.hpp"
00036 #include "TSFSerialVectorSpace.hpp"
00037
00038
00039 namespace TSFExtended
00040 {
00041 using Teuchos::Range1D;
00042 using namespace Thyra;
00043 using namespace Teuchos;
00044
00045
00046
00047
00048
00049
00050
00051 class SerialVector : public Thyra::VectorDefaultBase<double>,
00052 public IndexableVector<double>,
00053 public RawDataAccessibleVector<double>,
00054 public Sundance::Printable
00055 {
00056 public:
00057
00058
00059 SerialVector(const RCP<const VectorSpaceBase<double> >& vs);
00060
00061
00062
00063
00064 RCP< const VectorSpaceBase<double> >
00065 space() const {return vecSpace_;}
00066
00067
00068 void applyOpImpl(const RTOpPack::RTOpT< double >& op,
00069 const ArrayView< const Ptr< const VectorBase< double > > > & vecs,
00070 const ArrayView< const Ptr< VectorBase< double > > > & targ_vecs,
00071 const Ptr< RTOpPack::ReductTarget > & reduct_obj,
00072 const OrdType global_offset
00073 ) const ;
00074
00075
00076 void acquireDetachedVectorViewImpl(const Range1D& rng,
00077 RTOpPack::ConstSubVectorView<double>* sub_vec) const ;
00078
00079
00080 void releaseDetachedVectorViewImpl(
00081 RTOpPack::ConstSubVectorView<double>* sub_vec) const ;
00082
00083
00084 void acquireNonconstDetachedVectorViewImpl(const Range1D& rng,
00085 RTOpPack::SubVectorView<double> * sub_vec);
00086
00087
00088
00089 void commitNonconstDetachedVectorViewImpl(
00090 RTOpPack::SubVectorView<double>* sub_vec);
00091
00092
00093
00094
00095
00096
00097 virtual const double& operator[](OrdType globalIndex) const
00098 {return getElement(globalIndex);}
00099
00100
00101 virtual double& operator[](OrdType globalIndex) ;
00102
00103
00104
00105
00106
00107 virtual const double* dataPtr() const {return &(data_[0]);}
00108
00109 virtual double* dataPtr() {return &(data_[0]);}
00110
00111
00112
00113
00114
00115 void setElement(OrdType globalIndex, const double& value);
00116
00117
00118 void addToElement(OrdType globalIndex, const double& value);
00119
00120
00121 void setElements(int numElems, const int* globalIndices,
00122 const double* values);
00123
00124
00125
00126 void addToElements(int numElems, const int* globalIndices,
00127 const double* values);
00128
00129
00130 void finalizeAssembly();
00131
00132
00133
00134
00135
00136 const double& getElement(OrdType globalIndex) const ;
00137
00138
00139 void getElements(const OrdType* globalIndices, int numElems,
00140 Teuchos::Array<double>& elems) const ;
00141
00142
00143
00144
00145
00146 void print(std::ostream& os) const ;
00147
00148
00149
00150 static const SerialVector* getConcrete(const Vector<double>& x);
00151
00152 static SerialVector* getConcrete(Vector<double>& x);
00153
00154
00155 protected:
00156
00157 Range1D validateRange(const Range1D& rng) const ;
00158
00159 private:
00160
00161 RCP<const Thyra::VectorSpaceBase<double> > vecSpace_;
00162
00163 Array<double> data_;
00164
00165 int globalDim_;
00166
00167 mutable bool in_applyOpImpl_;
00168 };
00169
00170 }
00171
00172
00173 #endif