TSFSerialVectorSpace.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 "TSFSerialVectorSpace.hpp"
00028 #include "TSFSerialVector.hpp"
00029 #include "Teuchos_Utils.hpp"
00030 
00031 #include "Teuchos_DefaultSerialComm.hpp"
00032 #include "Thyra_DefaultSpmdVectorSpaceFactory.hpp"
00033 #include "Thyra_DefaultSpmdVectorSpace_decl.hpp"
00034 #include "Thyra_DefaultColumnwiseMultiVector.hpp"
00035 #include "SundanceOut.hpp"
00036 #include "Epetra_SerialComm.h"
00037 #include "Epetra_Comm.h"
00038 #ifdef HAVE_MPI
00039 #include "Epetra_MpiComm.h"
00040 #include "Teuchos_DefaultMpiComm.hpp"
00041 #endif
00042 
00043 
00044 #ifndef HAVE_TEUCHOS_EXPLICIT_INSTANTIATION
00045 #include "TSFVectorSpaceImpl.hpp"
00046 #endif
00047 
00048 
00049 
00050 using namespace TSFExtended;
00051 using namespace Thyra;
00052 
00053 using Teuchos::RCP;
00054 
00055 SerialVectorSpace::SerialVectorSpace(int dim)
00056   : DefaultSpmdVectorSpace<double>(dim),
00057     smallVecSpcFactory_(rcp(new DefaultSpmdVectorSpaceFactory<double>()))
00058 {
00059 }
00060 
00061 
00062 RCP<const VectorSpaceFactoryBase<double> > 
00063 SerialVectorSpace::smallVecSpcFcty() const 
00064 {
00065   return smallVecSpcFactory_;
00066 }
00067 
00068 bool SerialVectorSpace::isCompatible(const VectorSpaceBase<double>& other) const 
00069 {
00070   const SerialVectorSpace* rvs 
00071     = dynamic_cast<const SerialVectorSpace*>(&other);
00072   if (rvs != 0)
00073   {
00074     return this->dim() == rvs->dim();
00075   }
00076   return false;
00077 }
00078 
00079 
00080 // Overridden from VectorSpace
00081 
00082 Teuchos::RCP<VectorBase<double> >
00083 SerialVectorSpace::createMember() const
00084 {
00085   return rcp(new SerialVector(rcp(this, false)));
00086 }
00087 
00088 
00089 
00090 Teuchos::RCP<MultiVectorBase<double> >
00091 SerialVectorSpace::createMembers(int n) const
00092 {
00093   RCP<const VectorSpaceBase<double> > self = rcp(this, false);
00094   RCP<const VectorSpaceBase<double> > small 
00095     = rcp(new SerialVectorSpace(n));
00096   Array<RCP<VectorBase<double> > > vecs(n);
00097   for (int i=0; i<vecs.size(); i++)
00098   {
00099     vecs[i] = createMember();
00100   }
00101   return rcp(
00102     new Thyra::DefaultColumnwiseMultiVector<double>(
00103       self, small,
00104       vecs
00105       )
00106     );
00107 }
00108 
00109 
00110 
00111 Teuchos::RCP< const VectorSpaceBase<double> >
00112 SerialVectorSpace::clone() const
00113 {
00114   return Teuchos::rcp(new SerialVectorSpace(this->dim()));
00115 }
00116 
00117 
00118 
00119 string SerialVectorSpace::description() const
00120 {
00121   std::string rtn = "SerialVS[d=" + Teuchos::toString(this->dim()) + "]";
00122   return rtn;
00123 }
00124 
00125 
00126 
00127 

Site Contact