|
Amesos2 - Direct Sparse Solver Interfaces
Version of the Day
|
00001 // @HEADER 00002 // 00003 // *********************************************************************** 00004 // 00005 // Amesos2: Templated Direct Sparse Solver Package 00006 // Copyright 2011 Sandia Corporation 00007 // 00008 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 00009 // the U.S. Government retains certain rights in this software. 00010 // 00011 // Redistribution and use in source and binary forms, with or without 00012 // modification, are permitted provided that the following conditions are 00013 // met: 00014 // 00015 // 1. Redistributions of source code must retain the above copyright 00016 // notice, this list of conditions and the following disclaimer. 00017 // 00018 // 2. Redistributions in binary form must reproduce the above copyright 00019 // notice, this list of conditions and the following disclaimer in the 00020 // documentation and/or other materials provided with the distribution. 00021 // 00022 // 3. Neither the name of the Corporation nor the names of the 00023 // contributors may be used to endorse or promote products derived from 00024 // this software without specific prior written permission. 00025 // 00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY 00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE 00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00037 // 00038 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00039 // 00040 // *********************************************************************** 00041 // 00042 // @HEADER 00043 00053 #ifndef AMESOS2_TPETRA_MULTIVEC_ADAPTER_DECL_HPP 00054 #define AMESOS2_TPETRA_MULTIVEC_ADAPTER_DECL_HPP 00055 00056 #include <Teuchos_RCP.hpp> 00057 #include <Teuchos_Array.hpp> 00058 #include <Teuchos_as.hpp> 00059 #include <Tpetra_MultiVector.hpp> 00060 00061 #include "Amesos2_MultiVecAdapter_decl.hpp" 00062 00063 namespace Amesos2 { 00064 00070 template< typename Scalar, 00071 typename LocalOrdinal, 00072 typename GlobalOrdinal, 00073 class Node > 00074 class MultiVecAdapter<Tpetra::MultiVector<Scalar, 00075 LocalOrdinal, 00076 GlobalOrdinal, 00077 Node> > 00078 { 00079 public: 00080 00081 // public type definitions 00082 typedef Tpetra::MultiVector<Scalar, 00083 LocalOrdinal, 00084 GlobalOrdinal, 00085 Node> multivec_t; 00086 typedef Scalar scalar_t; 00087 typedef LocalOrdinal local_ordinal_t; 00088 typedef GlobalOrdinal global_ordinal_t; 00089 typedef Node node_t; 00090 typedef Tpetra::global_size_t global_size_t; 00091 00092 friend Teuchos::RCP<MultiVecAdapter<multivec_t> > createMultiVecAdapter<>(Teuchos::RCP<multivec_t>); 00093 friend Teuchos::RCP<const MultiVecAdapter<multivec_t> > createConstMultiVecAdapter<>(Teuchos::RCP<const multivec_t>); 00094 00095 static const char* name; 00096 00097 00098 protected: 00099 // Do not allow direct construction of MultiVecAdapter's. Only 00100 // allow construction throw the non-member friend functions. 00101 00103 MultiVecAdapter( const MultiVecAdapter<multivec_t>& adapter ); 00104 00110 MultiVecAdapter( const Teuchos::RCP<multivec_t>& m ); 00111 00112 00113 public: 00114 00115 ~MultiVecAdapter() 00116 { } 00117 00118 00120 bool isLocallyIndexed() const 00121 { 00122 if(getComm()->getSize() == 1){ 00123 return true; 00124 } // There may be other conditions to check 00125 } 00126 00127 // TODO 00128 bool isGloballyIndexed() const; 00129 00130 00131 const Teuchos::RCP<const Tpetra::Map< 00132 local_ordinal_t, 00133 global_ordinal_t, 00134 node_t > >& 00135 getMap() const 00136 { 00137 return mv_->getMap(); 00138 } 00139 00141 const Teuchos::RCP<const Teuchos::Comm<int> >& getComm() const 00142 { 00143 return getMap()->getComm(); 00144 } 00145 00147 size_t getLocalLength() const 00148 { 00149 return Teuchos::as<size_t>(mv_->getLocalLength()); 00150 } 00151 00152 00154 size_t getLocalNumVectors() const 00155 { 00156 return mv_->getNumVectors(); 00157 } 00158 00159 00161 global_size_t getGlobalLength() const 00162 { 00163 // return mv_->getGlobalLength(); 00164 return getMap()->getMaxAllGlobalIndex() + 1; 00165 } 00166 00167 00169 global_size_t getGlobalNumVectors() const 00170 { 00171 return Teuchos::as<global_size_t>(mv_->getNumVectors()); 00172 } 00173 00174 00176 size_t getStride() const 00177 { 00178 return mv_->getStride(); 00179 } 00180 00181 00183 bool isConstantStride() const 00184 { 00185 return mv_->isConstantStride(); 00186 } 00187 00188 00190 Teuchos::RCP<const Tpetra::Vector<scalar_t,local_ordinal_t,global_ordinal_t,node_t> > 00191 getVector( size_t j ) const 00192 { 00193 return mv_->getVector(j); 00194 } 00195 00196 00198 Teuchos::RCP<Tpetra::Vector<scalar_t,local_ordinal_t,global_ordinal_t,node_t> > 00199 getVectorNonConst( size_t j ) 00200 { 00201 return mv_->getVectorNonConst(j); 00202 } 00203 00204 00231 void get1dCopy( const Teuchos::ArrayView<scalar_t>& A, 00232 size_t lda, 00233 Teuchos::Ptr< 00234 const Tpetra::Map<local_ordinal_t, 00235 global_ordinal_t, 00236 node_t> > distribution_map ) const; 00237 00251 Teuchos::ArrayRCP<scalar_t> get1dViewNonConst( bool local = false ); 00252 00261 void put1dData( const Teuchos::ArrayView<const scalar_t>& new_data, 00262 size_t lda, 00263 Teuchos::Ptr< 00264 const Tpetra::Map<local_ordinal_t, 00265 global_ordinal_t, 00266 node_t> > source_map ); 00267 00268 00270 std::string description() const; 00271 00272 00274 void describe( Teuchos::FancyOStream& os, 00275 const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default ) const; 00276 00277 00278 private: 00279 00281 Teuchos::RCP<multivec_t> mv_; 00282 00283 00285 mutable Teuchos::RCP<Tpetra::Import<local_ordinal_t, 00286 global_ordinal_t, 00287 node_t> > importer_; 00288 mutable Teuchos::RCP<Tpetra::Export<local_ordinal_t, 00289 global_ordinal_t, 00290 node_t> > exporter_; 00291 00293 mutable Teuchos::RCP<const Tpetra::Map<local_ordinal_t, 00294 global_ordinal_t, 00295 node_t> > mv_map_; 00296 00297 }; // end class MultiVecAdapter<Tpetra::MultiVector> 00298 00299 } // end namespace Amesos2 00300 00301 00302 #endif // AMESOS2_TPETRA_MULTIVEC_ADAPTER_DECL_HPP
1.7.6.1