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
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 #ifndef XPETRA_EPETRAMULTIVECTOR_HPP
00047 #define XPETRA_EPETRAMULTIVECTOR_HPP
00048
00049
00050
00051 #include "Xpetra_EpetraConfigDefs.hpp"
00052
00053 #include "Xpetra_MultiVector.hpp"
00054 #include "Xpetra_Vector.hpp"
00055
00056 #include "Xpetra_EpetraMap.hpp"
00057 #include "Xpetra_EpetraExport.hpp"
00058 #include "Xpetra_Utils.hpp"
00059 #include "Xpetra_EpetraUtils.hpp"
00060 #include "Xpetra_EpetraImport.hpp"
00061 #include "Xpetra_Exceptions.hpp"
00062 #include "Epetra_SerialComm.h"
00063
00064 #include <Epetra_MultiVector.h>
00065
00066 namespace Xpetra {
00067
00068
00069 template<class GlobalOrdinal>
00070 const Epetra_MultiVector & toEpetra(const MultiVector<double,int,GlobalOrdinal> &);
00071 template<class GlobalOrdinal>
00072 Epetra_MultiVector & toEpetra(MultiVector<double, int,GlobalOrdinal> &);
00073 template<class GlobalOrdinal>
00074 RCP<MultiVector<double, int, GlobalOrdinal> > toXpetra(RCP<Epetra_MultiVector> vec);
00075
00076
00077
00078
00079
00080
00081 template<class EpetraGlobalOrdinal>
00082 class EpetraMultiVectorT
00083 : public virtual MultiVector<double, int, EpetraGlobalOrdinal>
00084 {
00085 typedef double Scalar;
00086 typedef int LocalOrdinal;
00087 typedef EpetraGlobalOrdinal GlobalOrdinal;
00088 typedef typename MultiVector<double, int, GlobalOrdinal>::node_type Node;
00089
00090 public:
00091
00093
00094
00096 EpetraMultiVectorT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, size_t NumVectors, bool zeroOut=true)
00097 : vec_(Teuchos::rcp(new Epetra_MultiVector(toEpetra(map), Teuchos::as<int>(NumVectors), zeroOut))) { }
00098
00100 EpetraMultiVectorT(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source)
00101 : vec_(Teuchos::rcp(new Epetra_MultiVector(toEpetra(source)))) { }
00102
00104 EpetraMultiVectorT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, const Teuchos::ArrayView< const Teuchos::ArrayView< const Scalar > > &ArrayOfPtrs, size_t NumVectors);
00105
00107 virtual ~EpetraMultiVectorT() {}
00108
00110
00112
00113
00115 void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) { XPETRA_MONITOR("EpetraMultiVectorT::replaceGlobalValue"); vec_->ReplaceGlobalValue(globalRow, Teuchos::as<int>(vectorIndex), value); }
00116
00118 void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) { XPETRA_MONITOR("EpetraMultiVectorT::sumIntoGlobalValue"); vec_->SumIntoGlobalValue(globalRow, Teuchos::as<int>(vectorIndex), value); }
00119
00121 void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) { XPETRA_MONITOR("EpetraMultiVectorT::replaceLocalValue"); vec_->ReplaceMyValue(myRow, Teuchos::as<int>(vectorIndex), value); }
00122
00124 void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) { XPETRA_MONITOR("EpetraMultiVectorT::sumIntoLocalValue"); vec_->SumIntoMyValue(myRow, Teuchos::as<int>(vectorIndex), value); }
00125
00127 void putScalar(const Scalar &value) { XPETRA_MONITOR("EpetraMultiVectorT::putScalar"); vec_->PutScalar(value); }
00128
00130
00132
00133
00135 Teuchos::RCP< const Vector< double, int, GlobalOrdinal, Node > > getVector(size_t j) const;
00136
00138 Teuchos::RCP< Vector< double, int, GlobalOrdinal, Node > > getVectorNonConst(size_t j);
00139
00141 Teuchos::ArrayRCP< const Scalar > getData(size_t j) const;
00142
00144 Teuchos::ArrayRCP< Scalar > getDataNonConst(size_t j);
00145
00147
00149
00150
00152 void dot(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Teuchos::ArrayView< Scalar > &dots) const;
00153
00155 void abs(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A) { XPETRA_MONITOR("EpetraMultiVectorT::abs"); vec_->Abs(toEpetra(A)); }
00156
00158 void reciprocal(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A) { XPETRA_MONITOR("EpetraMultiVectorT::reciprocal"); vec_->Reciprocal(toEpetra(A)); }
00159
00161 void scale(const Scalar &alpha) { XPETRA_MONITOR("EpetraMultiVectorT::scale"); vec_->Scale(alpha); }
00162
00164 void scale (Teuchos::ArrayView< const Scalar > alpha) {
00165 XPETRA_MONITOR("EpetraMultiVectorT::scale");
00166
00167
00168 const size_t numVecs = this->getNumVectors ();
00169 for (size_t j = 0; j < numVecs; ++j) {
00170 vec_->Scale (alpha[j]);
00171 }
00172 }
00173
00175 void update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta) { XPETRA_MONITOR("EpetraMultiVectorT::update"); vec_->Update(alpha, toEpetra(A), beta); }
00176
00178 void update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, const Scalar &gamma) { XPETRA_MONITOR("EpetraMultiVectorT::update"); vec_->Update(alpha, toEpetra(A), beta, toEpetra(B), gamma); }
00179
00181 void norm1(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const;
00182
00184 void norm2(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const;
00185
00187 void normInf(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const;
00188
00190 void normWeighted(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &weights, const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const;
00191
00193 void meanValue(const Teuchos::ArrayView< Scalar > &means) const;
00194
00196 void multiply(Teuchos::ETransp transA, Teuchos::ETransp transB, const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, const Scalar &beta) { XPETRA_MONITOR("EpetraMultiVectorT::multiply"); vec_->Multiply(toEpetra(transA), toEpetra(transB), alpha, toEpetra(A), toEpetra(B), beta); }
00197
00199 void elementWiseMultiply(Scalar scalarAB, const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, Scalar scalarThis) { XPETRA_MONITOR("EpetraMultiVectorT::elementWiseMultiply"); vec_->Multiply(scalarAB, toEpetra(A), toEpetra(B), scalarThis); }
00200
00202
00204
00205
00207 size_t getNumVectors() const { XPETRA_MONITOR("EpetraMultiVectorT::getNumVectors"); return vec_->NumVectors(); }
00208
00210 size_t getLocalLength() const { XPETRA_MONITOR("EpetraMultiVectorT::getLocalLength"); return vec_->MyLength(); }
00211
00213 global_size_t getGlobalLength() const { XPETRA_MONITOR("EpetraMultiVectorT::getGlobalLength"); return vec_->GlobalLength64(); }
00214
00216
00218
00219
00221 std::string description() const;
00222
00224 void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const;
00225
00227
00229 void randomize(bool bUseXpetraImplementation = false) {
00230 XPETRA_MONITOR("EpetraMultiVectorT::randomize");
00231
00232 if (bUseXpetraImplementation)
00233 Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::Xpetra_randomize();
00234 else
00235 vec_->Random();
00236 }
00237
00239
00240
00242 Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const { XPETRA_MONITOR("EpetraMultiVectorT::getMap"); return toXpetra<GlobalOrdinal>(vec_->Map()); }
00243
00245 void doImport(const DistObject<Scalar, LocalOrdinal, GlobalOrdinal, Node> &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM);
00246
00248 void doExport(const DistObject<Scalar, LocalOrdinal, GlobalOrdinal, Node> &dest, const Import< LocalOrdinal, GlobalOrdinal, Node >& importer, CombineMode CM);
00249
00251 void doImport(const DistObject<Scalar, LocalOrdinal, GlobalOrdinal, Node> &source, const Export< LocalOrdinal, GlobalOrdinal, Node >& exporter, CombineMode CM);
00252
00254 void doExport(const DistObject<Scalar, LocalOrdinal, GlobalOrdinal, Node> &dest, const Export< LocalOrdinal, GlobalOrdinal, Node >& exporter, CombineMode CM);
00255
00257 void replaceMap(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map);
00258
00260
00262
00263
00265 EpetraMultiVectorT(const RCP<Epetra_MultiVector> &vec) : vec_(vec) { }
00266
00268 RCP<Epetra_MultiVector> getEpetra_MultiVector() const { return vec_; }
00269
00271 void setSeed(unsigned int seed) {
00272 XPETRA_MONITOR("EpetraMultiVectorT::seedrandom");
00273
00274 Teuchos::ScalarTraits< Scalar >::seedrandom(seed);
00275 vec_->SetSeed(seed);
00276 }
00277
00279
00280 protected:
00283 virtual void
00284 assign (const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& rhs);
00285
00286 private:
00288 RCP< Epetra_MultiVector > vec_;
00289
00290 };
00291
00292 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
00293 typedef EpetraMultiVectorT<int> EpetraMultiVector;
00294 #endif
00295
00296 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
00297 typedef EpetraMultiVectorT<long long> EpetraMultiVector64;
00298 #endif
00299
00300
00301
00302
00303 template<class> class EpetraVectorT;
00304
00305 template<class EpetraGlobalOrdinal>
00306 EpetraMultiVectorT<EpetraGlobalOrdinal>::EpetraMultiVectorT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, const Teuchos::ArrayView< const Teuchos::ArrayView< const Scalar > > &ArrayOfPtrs, size_t NumVectors) {
00307
00308
00309 const std::string tfecfFuncName("MultiVector(ArrayOfPtrs)");
00310 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(NumVectors < 1 || NumVectors != Teuchos::as<size_t>(ArrayOfPtrs.size()), std::runtime_error,
00311 ": ArrayOfPtrs.size() must be strictly positive and as large as ArrayOfPtrs.");
00312
00313 #ifdef HAVE_XPETRA_DEBUG
00314
00315 {
00316 size_t localLength = map->getNodeNumElements();
00317 for(int j=0; j<ArrayOfPtrs.size(); j++) {
00318 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(Teuchos::as<size_t>(ArrayOfPtrs[j].size()) != localLength, std::runtime_error,
00319 ": ArrayOfPtrs[" << j << "].size() (== " << ArrayOfPtrs[j].size() <<
00320 ") is not equal to getLocalLength() (== " << localLength);
00321
00322 }
00323 }
00324 #endif
00325
00326
00327 Array<const double*> arrayOfRawPtrs(ArrayOfPtrs.size());
00328 for(int i=0; i<ArrayOfPtrs.size(); i++) {
00329 arrayOfRawPtrs[i] = ArrayOfPtrs[i].getRawPtr();
00330 }
00331 double** rawArrayOfRawPtrs = const_cast<double**>(arrayOfRawPtrs.getRawPtr());
00332
00333 vec_ = Teuchos::rcp(new Epetra_MultiVector(Copy, toEpetra(map), rawArrayOfRawPtrs, NumVectors));
00334 }
00335
00336
00337 template<class EpetraGlobalOrdinal>
00338 Teuchos::RCP< const Vector< double, int, EpetraGlobalOrdinal, typename EpetraMultiVectorT<EpetraGlobalOrdinal>::Node > > EpetraMultiVectorT<EpetraGlobalOrdinal>::getVector(size_t j) const {
00339 XPETRA_MONITOR("EpetraMultiVectorT::getVector");
00340 return rcp(new EpetraVectorT<GlobalOrdinal>(vec_, j));
00341 }
00342
00343 template<class EpetraGlobalOrdinal>
00344 Teuchos::RCP< Vector< double, int, EpetraGlobalOrdinal, typename EpetraMultiVectorT<EpetraGlobalOrdinal>::Node > > EpetraMultiVectorT<EpetraGlobalOrdinal>::getVectorNonConst(size_t j) {
00345 XPETRA_MONITOR("EpetraMultiVectorT::getVector");
00346 return rcp(new EpetraVectorT<GlobalOrdinal>(vec_, j));
00347 }
00348
00349 template<class EpetraGlobalOrdinal>
00350 Teuchos::ArrayRCP<const double> EpetraMultiVectorT<EpetraGlobalOrdinal>::getData(size_t j) const {
00351 XPETRA_MONITOR("EpetraMultiVectorT::getData");
00352
00353 double ** arrayOfPointers;
00354
00355 vec_->ExtractView(&arrayOfPointers);
00356
00357 double * data = arrayOfPointers[j];
00358 int localLength = vec_->MyLength();
00359
00360 return ArrayRCP<double>(data, 0, localLength, false);
00361 }
00362
00363 template<class EpetraGlobalOrdinal>
00364 Teuchos::ArrayRCP<double> EpetraMultiVectorT<EpetraGlobalOrdinal>::getDataNonConst(size_t j) {
00365 XPETRA_MONITOR("EpetraMultiVectorT::getDataNonConst");
00366
00367 double ** arrayOfPointers;
00368
00369 vec_->ExtractView(&arrayOfPointers);
00370
00371 double * data = arrayOfPointers[j];
00372 int localLength = vec_->MyLength();
00373
00374 return ArrayRCP<double>(data, 0, localLength, false);
00375 }
00376
00377 template<class EpetraGlobalOrdinal>
00378 void EpetraMultiVectorT<EpetraGlobalOrdinal>::dot(const MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &A, const Teuchos::ArrayView<Scalar> &dots) const {
00379 XPETRA_MONITOR("EpetraMultiVectorT::dot");
00380
00381 XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT, A, eA, "This Xpetra::EpetraMultiVectorT method only accept Xpetra::EpetraMultiVectorT as input arguments.");
00382 vec_->Dot(*eA.getEpetra_MultiVector(), dots.getRawPtr());
00383 }
00384
00385 template<class EpetraGlobalOrdinal>
00386 void EpetraMultiVectorT<EpetraGlobalOrdinal>::norm1(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const { XPETRA_MONITOR("EpetraMultiVectorT::norm1"); vec_->Norm1(norms.getRawPtr()); }
00387
00388 template<class EpetraGlobalOrdinal>
00389 void EpetraMultiVectorT<EpetraGlobalOrdinal>::norm2(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const { XPETRA_MONITOR("EpetraMultiVectorT::norm2"); vec_->Norm2(norms.getRawPtr()); }
00390
00391 template<class EpetraGlobalOrdinal>
00392 void EpetraMultiVectorT<EpetraGlobalOrdinal>::normInf(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const { XPETRA_MONITOR("EpetraMultiVectorT::normInf"); vec_->NormInf(norms.getRawPtr()); }
00393
00394 template<class EpetraGlobalOrdinal>
00395 void EpetraMultiVectorT<EpetraGlobalOrdinal>::normWeighted(const MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &weights, const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const {
00396 XPETRA_MONITOR("EpetraMultiVectorT::normWeighted");
00397
00398 XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT, weights, eWeights, "This Xpetra::EpetraMultiVectorT method only accept Xpetra::EpetraMultiVectorT as input arguments.");
00399 vec_->NormWeighted(*eWeights.getEpetra_MultiVector(), norms.getRawPtr());
00400 }
00401
00402 template<class EpetraGlobalOrdinal>
00403 void EpetraMultiVectorT<EpetraGlobalOrdinal>::meanValue(const Teuchos::ArrayView<double> &means) const { XPETRA_MONITOR("EpetraMultiVectorT::meanValue"); vec_->MeanValue(means.getRawPtr()); }
00404
00405 template<class EpetraGlobalOrdinal>
00406 std::string EpetraMultiVectorT<EpetraGlobalOrdinal>::description() const {
00407 XPETRA_MONITOR("EpetraMultiVectorT::description");
00408 TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO");
00409 return "TODO";
00410 }
00411
00412 template<class EpetraGlobalOrdinal>
00413 void EpetraMultiVectorT<EpetraGlobalOrdinal>::describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const {
00414 XPETRA_MONITOR("EpetraMultiVectorT::describe");
00415 vec_->Print(out);
00416 }
00417
00418 template<class EpetraGlobalOrdinal>
00419 void EpetraMultiVectorT<EpetraGlobalOrdinal>::doImport(const DistObject<double, int, GlobalOrdinal, Node> &source, const Import<int, GlobalOrdinal, Node> &importer, CombineMode CM) {
00420 XPETRA_MONITOR("EpetraMultiVectorT::doImport");
00421
00422 XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal>, source, tSource, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
00423 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal>, importer, tImporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
00424
00425 RCP<Epetra_MultiVector> v = tSource.getEpetra_MultiVector();
00426 int err = this->getEpetra_MultiVector()->Import(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
00427 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
00428 }
00429
00430 template<class EpetraGlobalOrdinal>
00431 void EpetraMultiVectorT<EpetraGlobalOrdinal>::doExport(const DistObject<double, int, GlobalOrdinal, Node> &dest, const Import<int, GlobalOrdinal, Node>& importer, CombineMode CM) {
00432 XPETRA_MONITOR("EpetraMultiVectorT::doExport");
00433
00434 XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal>, dest, tDest, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
00435 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal>, importer, tImporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
00436
00437 RCP<Epetra_MultiVector> v = tDest.getEpetra_MultiVector();
00438 int err = this->getEpetra_MultiVector()->Export(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
00439 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
00440 }
00441
00442 template<class EpetraGlobalOrdinal>
00443 void EpetraMultiVectorT<EpetraGlobalOrdinal>::doImport(const DistObject<double,int,GlobalOrdinal,Node> &source, const Export<int, GlobalOrdinal, Node>& exporter, CombineMode CM) {
00444 XPETRA_MONITOR("EpetraMultiVectorT::doImport");
00445
00446 XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal>, source, tSource, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
00447 XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal>, exporter, tExporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
00448
00449 RCP<Epetra_MultiVector> v = tSource.getEpetra_MultiVector();
00450 int err = this->getEpetra_MultiVector()->Import(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
00451 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
00452 }
00453
00454 template<class EpetraGlobalOrdinal>
00455 void EpetraMultiVectorT<EpetraGlobalOrdinal>::doExport(const DistObject<double, int, GlobalOrdinal, Node> &dest, const Export<int, GlobalOrdinal, Node>& exporter, CombineMode CM) {
00456 XPETRA_MONITOR("EpetraMultiVectorT::doExport");
00457
00458 XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal>, dest, tDest, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
00459 XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal>, exporter, tExporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
00460
00461 RCP<Epetra_MultiVector> v = tDest.getEpetra_MultiVector();
00462 int err = this->getEpetra_MultiVector()->Export(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
00463 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
00464 }
00465
00466 template<class EpetraGlobalOrdinal>
00467 void EpetraMultiVectorT<EpetraGlobalOrdinal>::replaceMap(const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& map) {
00468 int err = 0;
00469 if (!map.is_null()) {
00470 err = this->getEpetra_MultiVector()->ReplaceMap(toEpetra(map));
00471
00472 } else {
00473
00474 Epetra_SerialComm SComm;
00475 Epetra_Map NewMap((EpetraGlobalOrdinal) vec_->MyLength(), (EpetraGlobalOrdinal) vec_->Map().IndexBase64(), SComm);
00476 err = this->getEpetra_MultiVector()->ReplaceMap(NewMap);
00477 }
00478 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
00479 }
00480
00481 template<class EpetraGlobalOrdinal>
00482 void EpetraMultiVectorT<EpetraGlobalOrdinal>::
00483 assign (const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& rhs)
00484 {
00485 typedef EpetraMultiVectorT this_type;
00486 const this_type* rhsPtr = dynamic_cast<const this_type*> (&rhs);
00487 TEUCHOS_TEST_FOR_EXCEPTION(
00488 rhsPtr == NULL, std::invalid_argument, "Xpetra::MultiVector::operator=: "
00489 "The left-hand side (LHS) of the assignment has a different type than "
00490 "the right-hand side (RHS). The LHS has type Xpetra::EpetraMultiVectorT "
00491 "(which means it wraps an Epetra_MultiVector), but the RHS has some "
00492 "other type. This probably means that the RHS wraps a Tpetra::Multi"
00493 "Vector. Xpetra::MultiVector does not currently implement assignment "
00494 "from a Tpetra object to an Epetra object, though this could be added "
00495 "with sufficient interest.");
00496
00497 RCP<const Epetra_MultiVector> rhsImpl = rhsPtr->getEpetra_MultiVector ();
00498 RCP<Epetra_MultiVector> lhsImpl = this->getEpetra_MultiVector ();
00499
00500 TEUCHOS_TEST_FOR_EXCEPTION(
00501 rhsImpl.is_null (), std::logic_error, "Xpetra::MultiVector::operator= "
00502 "(in Xpetra::EpetraMultiVectorT::assign): *this (the right-hand side of "
00503 "the assignment) has a null RCP<Epetra_MultiVector> inside. Please "
00504 "report this bug to the Xpetra developers.");
00505 TEUCHOS_TEST_FOR_EXCEPTION(
00506 lhsImpl.is_null (), std::logic_error, "Xpetra::MultiVector::operator= "
00507 "(in Xpetra::EpetraMultiVectorT::assign): The left-hand side of the "
00508 "assignment has a null RCP<Epetra_MultiVector> inside. Please report "
00509 "this bug to the Xpetra developers.");
00510
00511
00512 *lhsImpl = *rhsImpl;
00513 }
00514
00515
00516 }
00517
00518 #include "Xpetra_EpetraVector.hpp"
00519
00520 #endif // XPETRA_EPETRAMULTIVECTOR_HPP