TSFSerialVectorType.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 "TSFSerialVectorType.hpp"
00028 #include "TSFSerialVectorSpace.hpp"
00029 #include "TSFDenseSerialMatrixFactory.hpp"
00030 #include "TSFSerialGhostImporter.hpp"
00031 #include "SundanceOut.hpp"
00032 
00033 #include "Teuchos_RefCountPtr.hpp"
00034 
00035 using namespace TSFExtended;
00036 using namespace Teuchos;
00037 
00038 SerialVectorType::SerialVectorType()
00039 {;}
00040 
00041 
00042 RCP<const Thyra::VectorSpaceBase<double> > 
00043 SerialVectorType::createSpace(int dimension,
00044   int nLocal,
00045   const int* localIndices,
00046   const MPIComm& comm) const
00047 {
00048   TEST_FOR_EXCEPTION(nLocal < 0, std::runtime_error, "negative vector size n=" << nLocal);
00049   TEST_FOR_EXCEPTION(dimension != nLocal, std::runtime_error, 
00050     "nLocal=" << nLocal << " and dimension=" << dimension
00051     << " should be equal for a replicated space");
00052 
00053   return rcp(new SerialVectorSpace(dimension));
00054 }
00055 
00056 RCP<GhostImporter<double> > 
00057 SerialVectorType::createGhostImporter(const VectorSpace<double>& space,
00058                                       int nGhost,
00059                                       const int* ghostIndices) const
00060 {
00061   TEST_FOR_EXCEPTION(dynamic_cast<const SerialVectorSpace*>(space.ptr().get())==0, std::runtime_error, "expected " 
00062     << space << " to be a SerialVectorSpace");
00063   return rcp(new SerialGhostImporter());
00064 }
00065 
00066 RCP<MatrixFactory<double> >
00067 SerialVectorType::createMatrixFactory(const VectorSpace<double>& domain,
00068                                       const VectorSpace<double>& range) const
00069 {
00070   RCP<const SerialVectorSpace> serDomain 
00071     = rcp_dynamic_cast<const SerialVectorSpace>(domain.ptr());
00072   RCP<const SerialVectorSpace> serRange 
00073     = rcp_dynamic_cast<const SerialVectorSpace>(range.ptr());
00074 
00075   RCP<MatrixFactory<double> > rtn 
00076     = rcp(new DenseSerialMatrixFactory(serDomain, serRange));
00077 
00078   return rtn;
00079 }
00080 
00081 
00082 VectorSpace<double> SerialVectorType
00083 ::createEvenlyPartitionedSpace(const MPIComm& /* comm */,
00084   int nLocal) const
00085 {
00086   RCP<const VectorSpaceBase<double> > rtn = rcp(new SerialVectorSpace(nLocal));
00087   return rtn;
00088 }
00089 
00090 
00091 
00092 
00093 
00094 

Site Contact