Xpetra_EpetraImport.cpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // Xpetra: A linear algebra interface package
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact
39 // Jonathan Hu (jhu@sandia.gov)
40 // Andrey Prokopenko (aprokop@sandia.gov)
41 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 #include "Xpetra_EpetraImport.hpp"
47 #include "Xpetra_Exceptions.hpp"
48 
49 namespace Xpetra {
50 
51 #if 0
52  template<class EpetraGlobalOrdinal, class Node>
54  : import_(rcp(new Epetra_Import(toEpetra<EpetraGlobalOrdinal,Node>(target), toEpetra<EpetraGlobalOrdinal,Node>(source)))) { } // Warning: Epetra(Target, Source) vs. Tpetra(Source, Target)
55 #endif
56  // //! copy constructor.
57  // EpetraImportT<EpetraGlobalOrdinal>::EpetraImportT(const Import<int,GlobalOrdinal> & import) { // TODO: refactoring
58  // XPETRA_DYNAMIC_CAST(const EpetraImportT, import, tImport, "Xpetra::EpetraImportT copy constructors only accept Xpetra::EpetraImportT as input arguments.");
59  // import_ = rcp(new Epetra_Import(*tImport.getEpetra_Import()));
60  // }
61 
62  // TODO: move that elsewhere
63  // template<class GlobalOrdinal>
64  // const Epetra_Import & toEpetra(const Import<int, GlobalOrdinal> &import) {
65  // // TODO: throw exception
66  // const EpetraImportT & tpetraImport = dynamic_cast<const EpetraImportT<GlobalOrdinal> &>(import);
67  // return *tpetraImport.getEpetra_Import();
68  // }
69 
70  template<class GlobalOrdinal, class Node>
71  RCP< const Import<int, GlobalOrdinal, Node > > toXpetra(const Epetra_Import *import) {
72  if (import != NULL) {
73  RCP<const Epetra_Import> imp = rcp(new Epetra_Import(*import)); //NOTE: non consitent: return pointer, take ref
75  }
76 
77  return Teuchos::null;
78  }
79  //
80 
81 #if 0
82  template<class EpetraGlobalOrdinal, class Node>
83  ArrayView< const int > EpetraImportT<EpetraGlobalOrdinal, Node>::getExportPIDs() const { XPETRA_MONITOR("EpetraImportT::getExportImageIDs"); return ArrayView<const int> (import_->ExportPIDs(),import_->NumExportIDs()); }
84 #endif
85 #if 0
86  template<class EpetraGlobalOrdinal, class Node>
87  size_t EpetraImportT<EpetraGlobalOrdinal, Node>::getNumRemoteIDs() const { XPETRA_MONITOR("EpetraImportT::getNumRemoteIDs"); return import_->NumRemoteIDs(); }
88 #endif
89 #if 0
90  template<class EpetraGlobalOrdinal, class Node>
91  size_t EpetraImportT<EpetraGlobalOrdinal, Node>::getNumExportIDs() const { XPETRA_MONITOR("EpetraImportT::getNumExportIDs"); return import_->NumExportIDs(); }
92 #endif
93 #if 0
94  template<class EpetraGlobalOrdinal, class Node>
96  XPETRA_MONITOR("EpetraImportT::getPermuteFromLIDs");
97  TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO EpetraImportT<EpetraGlobalOrdinal>::getExportImageIDs not implemented"); }
98 #endif
99 #if 0
100  template<class EpetraGlobalOrdinal, class Node>
102  XPETRA_MONITOR("EpetraImportT::getPermuteToLIDs");
103  TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO EpetraImportT<EpetraGlobalOrdinal>::getPermuteToLIDs not implemented"); }
104 #endif
105 #if 0
106  template<class EpetraGlobalOrdinal, class Node>
108  XPETRA_MONITOR("EpetraImportT::getRemoteLIDs");
109  TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO EpetraImportT<EpetraGlobalOrdinal>::getRemoteLIDs not implemented"); }
110 #endif
111 #if 0
112  template<class EpetraGlobalOrdinal, class Node>
114  XPETRA_MONITOR("EpetraImportT::getRemotePIDs");
115  TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO EpetraImportT<EpetraGlobalOrdinal>::getRemotePIDs not implemented"); }
116 #endif
117 #if 0
118  template<class EpetraGlobalOrdinal, class Node>
120  XPETRA_MONITOR("EpetraImportT::getExportLIDs");
121  TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO EpetraImportT<EpetraGlobalOrdinal>::getExportLIDs not implemented"); }
122 #endif
123 #if 0
124  template<class EpetraGlobalOrdinal, class Node>
125  void EpetraImportT<EpetraGlobalOrdinal, Node>::print(std::ostream &os) const { XPETRA_MONITOR("EpetraImportT::print"); import_->Print(os); }
126 #endif
127 
128 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
129 #ifdef HAVE_XPETRA_TPETRA
130 #ifdef HAVE_XPETRA_SERIAL
132 template RCP<const Import<int,int,Kokkos::Compat::KokkosSerialWrapperNode > > toXpetra<int,Kokkos::Compat::KokkosSerialWrapperNode >(const Epetra_Import *);
133 #endif
134 #ifdef HAVE_XPETRA_PTHREAD
136 template RCP<const Import<int,int,Kokkos::Compat::KokkosThreadsWrapperNode> > toXpetra<int,Kokkos::Compat::KokkosThreadsWrapperNode >(const Epetra_Import *);
137 #endif
138 #ifdef HAVE_XPETRA_OPENMP
140 template RCP<const Import<int, int, Kokkos::Compat::KokkosOpenMPWrapperNode> > toXpetra<int,Kokkos::Compat::KokkosOpenMPWrapperNode>(const Epetra_Import *);
141 #endif
142 #ifdef HAVE_XPETRA_CUDA
143 typedef Kokkos::Compat::KokkosCudaWrapperNode default_node_type;
145 template RCP<const Import<int, int, default_node_type> > toXpetra<int,default_node_type>(const Epetra_Import *);
146 #endif
147 #else
148 // Tpetra is disabled and Kokkos not available: use dummy node type
149 typedef EpetraNode default_node_type;
151 template RCP<const Import<int, int, default_node_type> > toXpetra<int,default_node_type>(const Epetra_Import *);
152 #endif // HAVE_XPETRA_TPETRA
153 #endif // XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
154 
155 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
156 #ifdef HAVE_XPETRA_TPETRA
157 #ifdef HAVE_XPETRA_SERIAL
159 template RCP<const Import<int,long long,Kokkos::Compat::KokkosSerialWrapperNode > > toXpetra<long long,Kokkos::Compat::KokkosSerialWrapperNode >(const Epetra_Import *);
160 #endif
161 #ifdef HAVE_XPETRA_PTHREAD
163 template RCP<const Import<int,long long,Kokkos::Compat::KokkosThreadsWrapperNode> > toXpetra<long long,Kokkos::Compat::KokkosThreadsWrapperNode >(const Epetra_Import *);
164 #endif
165 #ifdef HAVE_XPETRA_OPENMP
167 template RCP<const Import<int, long long, Kokkos::Compat::KokkosOpenMPWrapperNode> > toXpetra<long long,Kokkos::Compat::KokkosOpenMPWrapperNode>(const Epetra_Import *);
168 #endif
169 #ifdef HAVE_XPETRA_CUDA
170 typedef Kokkos::Compat::KokkosCudaWrapperNode default_node_type;
172 template RCP<const Import<int, long long, default_node_type> > toXpetra<long long,default_node_type>(const Epetra_Import *);
173 #endif
174 #else
175 // Tpetra is disabled and Kokkos not available: use dummy node type
176 typedef EpetraNode default_node_type;
178 template RCP<const Import<int, long long, default_node_type> > toXpetra<long long,default_node_type>(const Epetra_Import *);
179 #endif // HAVE_XPETRA_TPETRA
180 #endif
181 
182 } // Xpetra namespace
183 
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Xpetra namespace
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, GlobalOrdinal, Node > > &graph)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
EpetraImportT(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target)
Construct an Import from the source and target Maps.
Exception throws when you call an unimplemented method of Xpetra.
RCP< const Import< int, GlobalOrdinal, Node > > toXpetra(const Epetra_Import *import)
#define XPETRA_MONITOR(funcName)