PlayaEpetraVectorSpace.cpp
00001
00002
00003
00004
00005 #include "PlayaEpetraVectorSpace.hpp"
00006 #include "PlayaEpetraVector.hpp"
00007 #include "Teuchos_Utils.hpp"
00008 #include "Teuchos_DefaultSerialComm.hpp"
00009 #include "PlayaOut.hpp"
00010 #include "Epetra_SerialComm.h"
00011 #include "Epetra_Comm.h"
00012 #ifdef HAVE_MPI
00013 #include "Epetra_MpiComm.h"
00014 #include "Teuchos_DefaultMpiComm.hpp"
00015 #endif
00016
00017
00018 #ifndef HAVE_TEUCHOS_EXPLICIT_INSTANTIATION
00019 #include "PlayaVectorSpaceImpl.hpp"
00020 #endif
00021
00022
00023
00024
00025 using Teuchos::RCP;
00026
00027 namespace Playa
00028 {
00029
00030 EpetraVectorSpace::EpetraVectorSpace(const RCP<const Epetra_Map>& m)
00031 : epetraMap_(m),
00032 comm_(epetraCommToTeuchosMPIComm(m->Comm())),
00033 globalDim_(m->NumGlobalElements()),
00034 baseGlobalNaturalIndex_(m->MinMyGID()),
00035 numLocalElements_(m->NumMyElements())
00036 {}
00037
00038 MPIComm EpetraVectorSpace::epetraCommToTeuchosMPIComm(
00039 const Epetra_Comm& epComm)
00040 {
00041 #ifdef HAVE_MPI
00042 const Epetra_MpiComm* c1 = dynamic_cast<const Epetra_MpiComm*>(&epComm);
00043 if (c1) return MPIComm(c1->Comm());
00044 #endif
00045 return MPIComm::self();
00046 }
00047
00048 bool EpetraVectorSpace::isCompatible(const VectorSpaceBase<double>* other) const
00049 {
00050 const EpetraVectorSpace* evs = dynamic_cast<const EpetraVectorSpace*>(other);
00051 if (evs == 0) return false;
00052 return epetraMap_->SameAs(*(evs->epetraMap_));
00053 }
00054
00055
00056
00057 Teuchos::RCP<VectorBase<double> >
00058 EpetraVectorSpace::createMember(const VectorSpace<double>& self) const
00059 {
00060 TEUCHOS_TEST_FOR_EXCEPTION(self.ptr().get() != this,
00061 InternalError,
00062 "inconsistency between space and self-reference in EpetraVectorSpace::createMember()");
00063 return rcp(new EpetraVector(self));
00064 }
00065
00066 string EpetraVectorSpace::description() const
00067 {
00068 std::string rtn = "EpetraVS[d=" + Teuchos::toString(dim());
00069 if (numLocalElements() != dim()) rtn += ", local="
00070 + Teuchos::toString(numLocalElements());
00071 rtn += "]";
00072 return rtn;
00073 }
00074
00075 }
00076
00077
00078