|
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 00055 #ifndef AMESOS2_MULTIVEC_ADAPTER_DECL_HPP 00056 #define AMESOS2_MULTIVEC_ADAPTER_DECL_HPP 00057 00058 #include <Teuchos_RCP.hpp> 00059 #include <Teuchos_Ptr.hpp> 00060 #include <Teuchos_ArrayView.hpp> 00061 #include <Tpetra_Map.hpp> 00062 00063 #include "Amesos2_TypeDecl.hpp" 00064 00065 namespace Amesos2 { 00066 00067 00174 template <class MV> 00175 struct MultiVecAdapter {}; 00176 00184 template <class MV> 00185 Teuchos::RCP<MultiVecAdapter<MV> > 00186 createMultiVecAdapter(Teuchos::RCP<MV> mv){ 00187 using Teuchos::rcp; 00188 00189 if(mv.is_null()) return Teuchos::null; 00190 return( rcp(new MultiVecAdapter<MV>(mv)) ); 00191 } 00192 00193 template <class MV> 00194 Teuchos::RCP<const MultiVecAdapter<MV> > 00195 createConstMultiVecAdapter(Teuchos::RCP<const MV> mv){ 00196 using Teuchos::rcp; 00197 using Teuchos::rcp_const_cast; 00198 00199 if(mv.is_null()) return Teuchos::null; 00200 return( rcp(new MultiVecAdapter<MV>(Teuchos::rcp_const_cast<MV,const MV>(mv))).getConst() ); 00201 } 00202 00203 00205 // Utilities for getting and putting data from MultiVecs // 00207 00208 namespace Util { 00209 00210 /* 00211 * If the multivector scalar type and the desired scalar tpye are 00212 * the same, then we can do a simple straight copy. 00213 */ 00214 template <typename MV> 00215 struct same_type_get_copy { 00216 static void apply(const Teuchos::Ptr<const MV>& mv, 00217 const Teuchos::ArrayView<typename MV::scalar_t>& v, 00218 const size_t ldx, 00219 Teuchos::Ptr<const Tpetra::Map<typename MV::local_ordinal_t, typename MV::global_ordinal_t, typename MV::node_t> > distribution_map ); 00220 }; 00221 00222 /* 00223 * In the case where the scalar type of the multi-vector and the 00224 * corresponding S type are different, then we need to first get a 00225 * copy of the scalar values, then convert each one into the S 00226 * type before inserting into the vals array. 00227 */ 00228 template <typename MV, typename S> 00229 struct diff_type_get_copy { 00230 static void apply(const Teuchos::Ptr<const MV>& mv, 00231 const Teuchos::ArrayView<S>& v, 00232 const size_t& ldx, 00233 Teuchos::Ptr<const Tpetra::Map<typename MV::local_ordinal_t, typename MV::global_ordinal_t, typename MV::node_t> > distribution_map ); 00234 }; 00235 00242 template <class MV, typename S> 00243 struct get_1d_copy_helper { 00244 static void do_get(const Teuchos::Ptr<const MV>& mv, 00245 const Teuchos::ArrayView<S>& vals, 00246 const size_t ldx, 00247 Teuchos::Ptr<const Tpetra::Map<typename MV::local_ordinal_t, typename MV::global_ordinal_t, typename MV::node_t> > distribution_map ); 00248 00249 static void do_get(const Teuchos::Ptr<const MV>& mv, 00250 const Teuchos::ArrayView<S>& vals, 00251 const size_t ldx, 00252 EDistribution distribution); 00253 00254 static void do_get(const Teuchos::Ptr<const MV>& mv, 00255 const Teuchos::ArrayView<S>& vals, 00256 const size_t ldx); 00257 }; 00258 00259 /* 00260 * If the multivector scalar type and the desired scalar tpye are 00261 * the same, then we can do a simple straight copy. 00262 */ 00263 template <typename MV> 00264 struct same_type_data_put { 00265 static void apply(const Teuchos::Ptr<MV>& mv, 00266 const Teuchos::ArrayView<typename MV::scalar_t>& data, 00267 const size_t ldx, 00268 Teuchos::Ptr<const Tpetra::Map<typename MV::local_ordinal_t, typename MV::global_ordinal_t, typename MV::node_t> > distribution_map ); 00269 }; 00270 00271 /* 00272 * In the case where the scalar type of the multi-vector and the 00273 * corresponding S type are different, then we need to first get a 00274 * copy of the scalar values, then convert each one into the S 00275 * type before inserting into the vals array. 00276 */ 00277 template <typename MV, typename S> 00278 struct diff_type_data_put { 00279 static void apply(const Teuchos::Ptr<MV>& mv, 00280 const Teuchos::ArrayView<S>& data, 00281 const size_t& ldx, 00282 Teuchos::Ptr<const Tpetra::Map<typename MV::local_ordinal_t, typename MV::global_ordinal_t, typename MV::node_t> > distribution_map ); 00283 }; 00284 00291 template <class MV, typename S> 00292 struct put_1d_data_helper { 00293 static void do_put(const Teuchos::Ptr<MV>& mv, 00294 const Teuchos::ArrayView<S>& data, 00295 const size_t ldx, 00296 Teuchos::Ptr<const Tpetra::Map<typename MV::local_ordinal_t, typename MV::global_ordinal_t, typename MV::node_t> > distribution_map ); 00297 00298 static void do_put(const Teuchos::Ptr<MV>& mv, 00299 const Teuchos::ArrayView<S>& data, 00300 const size_t ldx, 00301 EDistribution distribution); 00302 00303 static void do_put(const Teuchos::Ptr<MV>& mv, 00304 const Teuchos::ArrayView<S>& data, 00305 const size_t ldx); 00306 }; 00307 } 00308 } // end namespace Amesos2 00309 00310 #include "Amesos2_TpetraMultiVecAdapter_decl.hpp" 00311 #ifdef HAVE_AMESOS2_EPETRA 00312 # include "Amesos2_EpetraMultiVecAdapter_decl.hpp" 00313 #endif 00314 00315 #endif // AMESOS2_MULTIVEC_ADAPTER_DECL_HPP
1.7.6.1