|
Thyra Package Browser (Single Doxygen Collection) Version of the Day
|
00001 // @HEADER 00002 // *********************************************************************** 00003 // 00004 // Thyra: Interfaces and Support for Abstract Numerical Algorithms 00005 // Copyright (2004) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 // @HEADER 00028 00029 00030 #ifndef THYRA_TPETRA_VECTOR_SPACE_HPP 00031 #define THYRA_TPETRA_VECTOR_SPACE_HPP 00032 00033 00034 #include "Thyra_TpetraVectorSpace_decl.hpp" 00035 #include "Thyra_TpetraThyraWrappers.hpp" 00036 #include "Thyra_TpetraVector.hpp" 00037 #include "Thyra_TpetraMultiVector.hpp" 00038 00039 00040 namespace Thyra { 00041 00042 00043 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node> 00044 RCP<TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node> > 00045 TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node>::create() 00046 { 00047 const RCP<this_t> vs(new this_t); 00048 vs->weakSelfPtr_ = vs.create_weak(); 00049 return vs; 00050 } 00051 00052 00053 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node> 00054 void TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node>::initialize( 00055 const RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > &tpetraMap 00056 ) 00057 { 00058 comm_ = convertTpetraToThyraComm(tpetraMap->getComm()); 00059 tpetraMap_ = tpetraMap; 00060 localSubDim_ = tpetraMap->getNodeNumElements(); 00061 numProc_ = comm_->getSize(); 00062 procRank_ = comm_->getRank(); 00063 this->updateState(tpetraMap->getGlobalNumElements()); 00064 } 00065 00066 00067 // Overridden from VectorSpace 00068 00069 00070 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node> 00071 RCP<VectorBase<Scalar> > 00072 TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node>::createMember() const 00073 { 00074 return tpetraVector<Scalar>( 00075 weakSelfPtr_.create_strong().getConst(), 00076 Teuchos::rcp( 00077 new Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node>(tpetraMap_, false) 00078 ) 00079 ); 00080 } 00081 00082 00083 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node> 00084 RCP< MultiVectorBase<Scalar> > 00085 TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node>::createMembers(int numMembers) const 00086 { 00087 return tpetraMultiVector<Scalar>( 00088 weakSelfPtr_.create_strong().getConst(), 00089 tpetraVectorSpace<Scalar>( 00090 Tpetra::createLocalMapWithNode<LocalOrdinal, GlobalOrdinal, Node>( 00091 numMembers, tpetraMap_->getComm(), tpetraMap_->getNode() 00092 ) 00093 ), 00094 Teuchos::rcp( 00095 new Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>( 00096 tpetraMap_, numMembers, false) 00097 ) 00098 ); 00099 // ToDo: Create wrapper function to create locally replicated vector space 00100 // and use it. 00101 } 00102 00103 00104 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node> 00105 bool TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node>::hasInCoreView( 00106 const Range1D& rng_in, const EViewType viewType, const EStrideType strideType 00107 ) const 00108 { 00109 const Range1D rng = full_range(rng_in,0,this->dim()-1); 00110 const Ordinal l_localOffset = this->localOffset(); 00111 return ( l_localOffset<=rng.lbound() && rng.ubound()<l_localOffset+localSubDim_ ); 00112 } 00113 00114 00115 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node> 00116 RCP< const VectorSpaceBase<Scalar> > 00117 TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node>::clone() const 00118 { 00119 return tpetraVectorSpace<Scalar>(tpetraMap_); 00120 } 00121 00122 00123 // Overridden from SpmdVectorSpaceDefaultBase 00124 00125 00126 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node> 00127 RCP<const Teuchos::Comm<Ordinal> > 00128 TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node>::getComm() const 00129 { 00130 return comm_; 00131 } 00132 00133 00134 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node> 00135 Ordinal TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node>::localSubDim() const 00136 { 00137 return localSubDim_; 00138 } 00139 00140 00141 // private 00142 00143 00144 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node> 00145 TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node>::TpetraVectorSpace() 00146 :localSubDim_(-1), numProc_(-1), procRank_(-1) 00147 { 00148 // The base classes should automatically default initialize to a safe 00149 // uninitialized state. 00150 } 00151 00152 00153 } // end namespace Thyra 00154 00155 00156 #endif // THYRA_TPETRA_VECTOR_SPACE_HPP
1.7.4