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 TSFEPETRAVECTOR_HPP
00028 #define TSFEPETRAVECTOR_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 "Epetra_FEVector.h"
00037 #include "Epetra_Vector.h"
00038 #include "TSFEpetraVectorSpace.hpp"
00039
00040
00041 namespace TSFExtended
00042 {
00043 using Teuchos::Range1D;
00044 using namespace Thyra;
00045 using namespace Teuchos;
00046
00047
00048
00049
00050
00051
00052 class EpetraVector : public Thyra::VectorDefaultBase<double>,
00053 public IndexableVector<double>,
00054 public RawDataAccessibleVector<double>,
00055 public Sundance::Printable
00056 {
00057 public:
00058
00059
00060 EpetraVector(const RCP<const VectorSpaceBase<double> >& vs);
00061
00062
00063
00064 EpetraVector(const RCP<const VectorSpaceBase<double> >& vs,
00065 const RCP<Epetra_Vector>& vec);
00066
00067
00068
00069
00070
00071 RCP< const VectorSpaceBase<double> >
00072 space() const {return vecSpace_;}
00073
00074 #ifndef TRILINOS_8
00075
00076 void applyOpImpl(const RTOpPack::RTOpT< double >& op,
00077 const ArrayView< const Ptr< const VectorBase< double > > > & vecs,
00078 const ArrayView< const Ptr< VectorBase< double > > > & targ_vecs,
00079 const Ptr< RTOpPack::ReductTarget > & reduct_obj,
00080 const OrdType global_offset
00081 ) const ;
00082 #else
00083 virtual void applyOp(
00084 const RTOpPack::RTOpT<double> &op,
00085 const int num_vecs,
00086 const VectorBase<double>*const vecs[],
00087 const int num_targ_vecs,
00088 VectorBase<double>*const targ_vecs[],
00089 RTOpPack::ReductTarget *reduct_obj,
00090 const OrdType first_ele_offset,
00091 const OrdType sub_dim,
00092 const OrdType global_offset
00093 ) const ;
00094 #endif
00095
00096
00097 void acquireDetachedVectorViewImpl(const Range1D& rng,
00098 RTOpPack::ConstSubVectorView<double>* sub_vec) const ;
00099
00100
00101 void releaseDetachedVectorViewImpl(
00102 RTOpPack::ConstSubVectorView<double>* sub_vec) const ;
00103
00104
00105 void acquireNonconstDetachedVectorViewImpl(const Range1D& rng,
00106 RTOpPack::SubVectorView<double> * sub_vec);
00107
00108
00109
00110 void commitNonconstDetachedVectorViewImpl(
00111 RTOpPack::SubVectorView<double>* sub_vec);
00112
00113
00114
00115
00116
00117
00118 virtual const double& operator[](OrdType globalIndex) const
00119 {return getElement(globalIndex);}
00120
00121
00122 virtual double& operator[](OrdType globalIndex) ;
00123
00124
00125
00126
00127
00128 virtual const double* dataPtr() const {return &(epetraVec_->operator[](0));}
00129
00130 virtual double* dataPtr() {return &(epetraVec_->operator[](0));}
00131
00132
00133
00134
00135
00136 void setElement(OrdType globalIndex, const double& value);
00137
00138
00139 void addToElement(OrdType globalIndex, const double& value);
00140
00141
00142 void setElements(int numElems, const int* globalIndices,
00143 const double* values);
00144
00145
00146
00147 void addToElements(int numElems, const int* globalIndices,
00148 const double* values);
00149
00150
00151 void finalizeAssembly();
00152
00153
00154
00155
00156
00157 const double& getElement(OrdType globalIndex) const ;
00158
00159
00160 void getElements(const OrdType* globalIndices, int numElems,
00161 Teuchos::Array<double>& elems) const ;
00162
00163
00164
00165
00166
00167 void print(std::ostream& os) const ;
00168
00169
00170
00171
00172 const RCP<Epetra_Vector>& epetraVec() const
00173 {return epetraVec_;}
00174
00175
00176 RCP<Epetra_Vector>& epetraVec() {return epetraVec_;}
00177
00178
00179 static const Epetra_Vector& getConcrete(const TSFExtended::Vector<double>& tsfVec);
00180
00181 static Epetra_Vector& getConcrete(TSFExtended::Vector<double>& tsfVec);
00182
00183 static Epetra_Vector* getConcretePtr(TSFExtended::Vector<double>& tsfVec);
00184
00185
00186
00187
00188
00189 protected:
00190
00191 const RCP<const Epetra_Map>& epetraMap() const {return epetraMap_;}
00192
00193
00194 Range1D validateRange(const Range1D& rng) const ;
00195
00196 private:
00197
00198 RCP<Epetra_Vector> epetraVec_;
00199
00200 RCP<const Thyra::VectorSpaceBase<double> > vecSpace_;
00201
00202 RCP<const EpetraVectorSpace> epetraVecSpace_;
00203
00204 RCP<const Epetra_Map> epetraMap_;
00205
00206 int localOffset_;
00207
00208 int localSubDim_;
00209
00210 int globalDim_;
00211
00212 mutable bool in_applyOpImpl_;
00213 };
00214
00215 }
00216
00217
00218 #endif