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 #include "TSFEpetraVectorType.hpp"
00028 #include "TSFEpetraVectorSpace.hpp"
00029 #include "TSFEpetraGhostImporter.hpp"
00030 #include "TSFEpetraMatrixFactory.hpp"
00031 #include "Epetra_Map.h"
00032 #include "Epetra_Import.h"
00033 #include "Epetra_Comm.h"
00034 #include "SundanceOut.hpp"
00035
00036 #ifdef HAVE_MPI
00037 #include "Epetra_MpiComm.h"
00038 #else
00039 #include "Epetra_SerialComm.h"
00040 #endif
00041
00042 #include "Teuchos_RefCountPtr.hpp"
00043 #include "TSFEpetraMatrix.hpp"
00044
00045 using namespace TSFExtended;
00046 using namespace Teuchos;
00047
00048 EpetraVectorType::EpetraVectorType()
00049 {;}
00050
00051
00052 RCP<const Thyra::VectorSpaceBase<double> >
00053 EpetraVectorType::createSpace(int ,
00054 int nLocal,
00055 const int* localIndices,
00056 const MPIComm& comm) const
00057 {
00058 #ifdef HAVE_MPI
00059 Epetra_MpiComm epComm(comm.getComm());
00060 #else
00061 Epetra_SerialComm epComm;
00062 #endif
00063
00064 TEST_FOR_EXCEPTION(nLocal < 0, std::runtime_error, "negative vector size n=" << nLocal);
00065
00066 RCP<Epetra_Map> map = rcp(new Epetra_Map(-1, nLocal,
00067 (int*) localIndices,
00068 0, epComm));
00069
00070 return rcp(new EpetraVectorSpace(map));
00071 }
00072
00073 RCP<GhostImporter<double> >
00074 EpetraVectorType::createGhostImporter(const VectorSpace<double>& space,
00075 int nGhost,
00076 const int* ghostIndices) const
00077 {
00078 const EpetraVectorSpace* p
00079 = dynamic_cast<const EpetraVectorSpace*>(space.ptr().get());
00080
00081 TEST_FOR_EXCEPTION(p==0, std::runtime_error,
00082 "non-epetra vector space [" << space.description() << "] given as "
00083 "argument to EpetraVectorType::createGhostImporter()");
00084
00085 return rcp(new EpetraGhostImporter(p->epetraMap(), nGhost, ghostIndices));
00086
00087 }
00088
00089 RCP<MatrixFactory<double> >
00090 EpetraVectorType::createMatrixFactory(const VectorSpace<double>& domain,
00091 const VectorSpace<double>& range) const
00092 {
00093 RCP<const EpetraVectorSpace> pd
00094 = rcp_dynamic_cast<const EpetraVectorSpace>(domain.ptr());
00095
00096 RCP<const EpetraVectorSpace> pr
00097 = rcp_dynamic_cast<const EpetraVectorSpace>(range.ptr());
00098
00099
00100 TEST_FOR_EXCEPTION(pd.get()==0, std::runtime_error,
00101 "incompatible domain space given to "
00102 "EpetraVectorType::createMatrix()");
00103
00104 TEST_FOR_EXCEPTION(pr.get()==0, std::runtime_error,
00105 "incompatible range space given to "
00106 "EpetraVectorType::createMatrix()");
00107
00108
00109
00110 return rcp(new EpetraMatrixFactory(pd, pr));
00111 }
00112
00113
00114
00115
00116
00117