|
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 00245 do_get (const Teuchos::Ptr<const MV>& mv, 00246 const Teuchos::ArrayView<S>& vals, 00247 const size_t ldx, 00248 Teuchos::Ptr<const Tpetra::Map<typename MV::local_ordinal_t, typename MV::global_ordinal_t, typename MV::node_t> > distribution_map ); 00249 00250 static void 00251 do_get (const Teuchos::Ptr<const MV>& mv, 00252 const Teuchos::ArrayView<S>& vals, 00253 const size_t ldx, 00254 EDistribution distribution, 00255 typename MV::global_ordinal_t indexBase = 0); 00256 00257 static void 00258 do_get (const Teuchos::Ptr<const MV>& mv, 00259 const Teuchos::ArrayView<S>& vals, 00260 const size_t ldx); 00261 }; 00262 00263 /* 00264 * If the multivector scalar type and the desired scalar tpye are 00265 * the same, then we can do a simple straight copy. 00266 */ 00267 template <typename MV> 00268 struct same_type_data_put { 00269 static void apply(const Teuchos::Ptr<MV>& mv, 00270 const Teuchos::ArrayView<typename MV::scalar_t>& data, 00271 const size_t ldx, 00272 Teuchos::Ptr<const Tpetra::Map<typename MV::local_ordinal_t, typename MV::global_ordinal_t, typename MV::node_t> > distribution_map ); 00273 }; 00274 00275 /* 00276 * In the case where the scalar type of the multi-vector and the 00277 * corresponding S type are different, then we need to first get a 00278 * copy of the scalar values, then convert each one into the S 00279 * type before inserting into the vals array. 00280 */ 00281 template <typename MV, typename S> 00282 struct diff_type_data_put { 00283 static void apply(const Teuchos::Ptr<MV>& mv, 00284 const Teuchos::ArrayView<S>& data, 00285 const size_t& ldx, 00286 Teuchos::Ptr<const Tpetra::Map<typename MV::local_ordinal_t, typename MV::global_ordinal_t, typename MV::node_t> > distribution_map ); 00287 }; 00288 00295 template <class MV, typename S> 00296 struct put_1d_data_helper { 00297 static void do_put(const Teuchos::Ptr<MV>& mv, 00298 const Teuchos::ArrayView<S>& data, 00299 const size_t ldx, 00300 Teuchos::Ptr<const Tpetra::Map<typename MV::local_ordinal_t, typename MV::global_ordinal_t, typename MV::node_t> > distribution_map ); 00301 00302 static void do_put(const Teuchos::Ptr<MV>& mv, 00303 const Teuchos::ArrayView<S>& data, 00304 const size_t ldx, 00305 EDistribution distribution, typename MV::global_ordinal_t indexBase = 0); 00306 00307 static void do_put(const Teuchos::Ptr<MV>& mv, 00308 const Teuchos::ArrayView<S>& data, 00309 const size_t ldx); 00310 }; 00311 } 00312 } // end namespace Amesos2 00313 00314 #include "Amesos2_TpetraMultiVecAdapter_decl.hpp" 00315 #ifdef HAVE_AMESOS2_EPETRA 00316 # include "Amesos2_EpetraMultiVecAdapter_decl.hpp" 00317 #endif 00318 00319 #endif // AMESOS2_MULTIVEC_ADAPTER_DECL_HPP
1.7.6.1