00001
00002
00003
00004
00005
00006 #include "PlayaEpetraVectorType.hpp"
00007 #include "PlayaEpetraVectorSpace.hpp"
00008 #include "PlayaEpetraGhostImporter.hpp"
00009 #include "PlayaEpetraMatrixFactory.hpp"
00010 #include "Epetra_Map.h"
00011 #include "Epetra_Import.h"
00012 #include "Epetra_Comm.h"
00013 #include "PlayaOut.hpp"
00014
00015 #ifdef HAVE_MPI
00016 #include "Epetra_MpiComm.h"
00017 #else
00018 #include "Epetra_SerialComm.h"
00019 #endif
00020
00021 #include "Teuchos_RefCountPtr.hpp"
00022 #include "PlayaEpetraMatrix.hpp"
00023
00024 using namespace Playa;
00025 using namespace Teuchos;
00026
00027 EpetraVectorType::EpetraVectorType()
00028 {;}
00029
00030
00031 RCP<const VectorSpaceBase<double> >
00032 EpetraVectorType::createSpace(int ,
00033 int nLocal,
00034 const int* localIndices,
00035 const MPIComm& comm) const
00036 {
00037 #ifdef HAVE_MPI
00038 Epetra_MpiComm epComm(comm.getComm());
00039 #else
00040 Epetra_SerialComm epComm;
00041 #endif
00042
00043 TEUCHOS_TEST_FOR_EXCEPTION(nLocal < 0, std::runtime_error, "negative vector size n=" << nLocal);
00044
00045 RCP<Epetra_Map> map = rcp(new Epetra_Map(-1, nLocal,
00046 (int*) localIndices,
00047 0, epComm));
00048
00049 return rcp(new EpetraVectorSpace(map));
00050 }
00051
00052 RCP<GhostImporter<double> >
00053 EpetraVectorType::createGhostImporter(const VectorSpace<double>& space,
00054 int nGhost,
00055 const int* ghostIndices) const
00056 {
00057 const EpetraVectorSpace* p
00058 = dynamic_cast<const EpetraVectorSpace*>(space.ptr().get());
00059
00060 TEUCHOS_TEST_FOR_EXCEPTION(p==0, std::runtime_error,
00061 "non-epetra vector space [" << space.description() << "] given as "
00062 "argument to EpetraVectorType::createGhostImporter()");
00063
00064 return rcp(new EpetraGhostImporter(p->epetraMap(), nGhost, ghostIndices));
00065
00066 }
00067
00068 RCP<MatrixFactory<double> >
00069 EpetraVectorType::createMatrixFactory(const VectorSpace<double>& domain,
00070 const VectorSpace<double>& range) const
00071 {
00072 RCP<const EpetraVectorSpace> pd
00073 = rcp_dynamic_cast<const EpetraVectorSpace>(domain.ptr());
00074
00075 RCP<const EpetraVectorSpace> pr
00076 = rcp_dynamic_cast<const EpetraVectorSpace>(range.ptr());
00077
00078
00079 TEUCHOS_TEST_FOR_EXCEPTION(pd.get()==0, std::runtime_error,
00080 "incompatible domain space given to "
00081 "EpetraVectorType::createMatrix()");
00082
00083 TEUCHOS_TEST_FOR_EXCEPTION(pr.get()==0, std::runtime_error,
00084 "incompatible range space given to "
00085 "EpetraVectorType::createMatrix()");
00086
00087
00088
00089 return rcp(new EpetraMatrixFactory(pd, pr));
00090 }
00091
00092
00093
00094
00095
00096