TSFEpetraVectorType.cpp
Go to the documentation of this file.
00001 /* ***********************************************************************
00002 // 
00003 //           TSFExtended: Trilinos Solver Framework Extended
00004 //                 Copyright (2004) Sandia Corporation
00005 // 
00006 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00007 // license for use of this work by or on behalf of the U.S. Government.
00008 // 
00009 // This library is free software; you can redistribute it and/or modify
00010 // it under the terms of the GNU Lesser General Public License as
00011 // published by the Free Software Foundation; either version 2.1 of the
00012 // License, or (at your option) any later version.
00013 //  
00014 // This library is distributed in the hope that it will be useful, but
00015 // WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 // Lesser General Public License for more details.
00018 //  
00019 // You should have received a copy of the GNU Lesser General Public
00020 // License along with this library; if not, write to the Free Software
00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00022 // USA
00023 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
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 /*dimension*/,
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   //  RCP<SingleScalarTypeOp<double> > A = rcp(new EpetraMatrix(pd, pr));
00109 
00110   return rcp(new EpetraMatrixFactory(pd, pr));
00111 }
00112 
00113 
00114 
00115 
00116 
00117 

Site Contact