Xpetra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Xpetra_EpetraMap.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_ConfigDefs.hpp"
47 
48 #ifdef HAVE_XPETRA_EPETRA
49 
50 #include "Xpetra_EpetraMap.hpp"
51 
52 namespace Xpetra {
53 
54  template<class GlobalOrdinal, class Node>
55  const Epetra_Map & toEpetra(const Map<int,GlobalOrdinal, Node> &map)
56  {
57  const EpetraMapT<GlobalOrdinal, Node> & epetraMap = dynamic_cast<const EpetraMapT<GlobalOrdinal, Node> &>(*map.getMap());
58  return epetraMap.getEpetra_Map();
59  }
60 
61  template<class GlobalOrdinal, class Node>
62  const Epetra_Map & toEpetra(const RCP< const Map<int,GlobalOrdinal,Node> > &map)
63  {
65  return epetraMap->getEpetra_Map();
66  }
67 
68  template<class GlobalOrdinal, class Node>
69  const RCP< const Xpetra::Map<int, GlobalOrdinal, Node> > toXpetra(const Epetra_BlockMap &map)
70  {
71  RCP<const Epetra_BlockMap> m = rcp(new Epetra_BlockMap(map));
72  return rcp( new EpetraMapT<GlobalOrdinal, Node>(m) );
73  }
74 
75 
76 
77 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
78 
79 #ifdef HAVE_XPETRA_TPETRA
80 #include "TpetraCore_config.h"
81 #if ((defined(EPETRA_HAVE_OMP) && !defined(HAVE_TPETRA_INST_OPENMP)) || \
82  (!defined(EPETRA_HAVE_OMP) && !defined(HAVE_TPETRA_INST_SERIAL)))
83  template const RCP< const Map<int, int, Xpetra::EpetraNode > > toXpetra<int, Xpetra::EpetraNode>(const Epetra_BlockMap &map);
84  template const Epetra_Map & toEpetra<int, Xpetra::EpetraNode >(const RCP< const Map<int, int, Xpetra::EpetraNode > > &map);
85  template const Epetra_Map & toEpetra<int, Xpetra::EpetraNode >(const Map< int, int, Xpetra::EpetraNode> & map);
86 #endif
87 #ifdef HAVE_TPETRA_INST_SERIAL
88 //template class EpetraMapT<int, Kokkos::Compat::KokkosSerialWrapperNode >;
89 template const RCP< const Map<int, int, Kokkos::Compat::KokkosSerialWrapperNode > > toXpetra<int, Kokkos::Compat::KokkosSerialWrapperNode>(const Epetra_BlockMap &map);
90 template const Epetra_Map & toEpetra<int, Kokkos::Compat::KokkosSerialWrapperNode >(const RCP< const Map<int, int, Kokkos::Compat::KokkosSerialWrapperNode > > & map);
91 template const Epetra_Map & toEpetra<int, Kokkos::Compat::KokkosSerialWrapperNode >(const Map< int, int, Kokkos::Compat::KokkosSerialWrapperNode> & map);
92 #endif
93 #ifdef HAVE_TPETRA_INST_PTHREAD
94 //template class EpetraMapT<int, Kokkos::Compat::KokkosThreadsWrapperNode>;
95 template const RCP< const Map<int, int, Kokkos::Compat::KokkosThreadsWrapperNode > > toXpetra<int, Kokkos::Compat::KokkosThreadsWrapperNode>(const Epetra_BlockMap &map);
96 template const Epetra_Map & toEpetra<int, Kokkos::Compat::KokkosThreadsWrapperNode >(const RCP< const Map<int, int, Kokkos::Compat::KokkosThreadsWrapperNode > > &map);
97 template const Epetra_Map & toEpetra<int, Kokkos::Compat::KokkosThreadsWrapperNode >(const Map< int, int, Kokkos::Compat::KokkosThreadsWrapperNode> & map);
98 #endif
99 #ifdef HAVE_TPETRA_INST_OPENMP
100 //template class EpetraMapT<int, Kokkos::Compat::KokkosOpenMPWrapperNode >;
101 template const RCP< const Map<int, int, Kokkos::Compat::KokkosOpenMPWrapperNode > > toXpetra<int, Kokkos::Compat::KokkosOpenMPWrapperNode>(const Epetra_BlockMap &map);
102 template const Epetra_Map & toEpetra<int, Kokkos::Compat::KokkosOpenMPWrapperNode >(const RCP< const Map<int, int, Kokkos::Compat::KokkosOpenMPWrapperNode > > &map);
103 template const Epetra_Map & toEpetra<int, Kokkos::Compat::KokkosOpenMPWrapperNode >(const Map< int, int, Kokkos::Compat::KokkosOpenMPWrapperNode> & map);
104 #endif
105 #ifdef HAVE_TPETRA_INST_CUDA
106 typedef Kokkos::Compat::KokkosCudaWrapperNode default_node_type;
107 //template class EpetraMapT<int, default_node_type >;
108 template const RCP< const Map<int, int, default_node_type > > toXpetra<int, default_node_type>(const Epetra_BlockMap &map);
109 template const Epetra_Map & toEpetra<int, default_node_type >(const RCP< const Map<int, int, default_node_type > > &map);
110 template const Epetra_Map & toEpetra<int, default_node_type >(const Map< int, int, default_node_type> & map);
111 #endif
112 #else
113 // Tpetra is disabled and Kokkos not available: use dummy node type
114 typedef Xpetra::EpetraNode default_node_type;
115 template const RCP< const Map<int, int, default_node_type > > toXpetra<int, default_node_type>(const Epetra_BlockMap &map);
116 template const Epetra_Map & toEpetra<int, default_node_type >(const RCP< const Map<int, int, default_node_type > > &map);
117 template const Epetra_Map & toEpetra<int, default_node_type >(const Map< int, int, default_node_type> & map);
118 #endif // HAVE_XPETRA_TPETRA
119 
120 #endif // XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
121 
122 
123 
124 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
125 
126 #ifdef HAVE_XPETRA_TPETRA
127 #include "TpetraCore_config.h"
128 #if ((defined(EPETRA_HAVE_OMP) && !defined(HAVE_TPETRA_INST_OPENMP)) || \
129  (!defined(EPETRA_HAVE_OMP) && !defined(HAVE_TPETRA_INST_SERIAL)))
130 template const RCP< const Map<int, long long, Xpetra::EpetraNode > > toXpetra<long long, Xpetra::EpetraNode>(const Epetra_BlockMap &map);
131 template const Epetra_Map & toEpetra<long long, Xpetra::EpetraNode >(const RCP< const Map<int, long long, Xpetra::EpetraNode > > &map);
132 template const Epetra_Map & toEpetra<long long, Xpetra::EpetraNode >(const Map< int, long long, Xpetra::EpetraNode> & map);
133 #endif
134 
135 #ifdef HAVE_TPETRA_INST_SERIAL
136 //template class EpetraMapT<long long, Kokkos::Compat::KokkosSerialWrapperNode >;
137 template const RCP< const Map<int, long long, Kokkos::Compat::KokkosSerialWrapperNode > > toXpetra<long long, Kokkos::Compat::KokkosSerialWrapperNode>(const Epetra_BlockMap &map);
138 template const Epetra_Map & toEpetra<long long, Kokkos::Compat::KokkosSerialWrapperNode >(const RCP< const Map<int, long long, Kokkos::Compat::KokkosSerialWrapperNode > > & map);
139 template const Epetra_Map & toEpetra<long long, Kokkos::Compat::KokkosSerialWrapperNode >(const Map< int, long long, Kokkos::Compat::KokkosSerialWrapperNode> & map);
140 #endif
141 
142 #ifdef HAVE_TPETRA_INST_PTHREAD
143 //template class EpetraMapT<long long, Kokkos::Compat::KokkosThreadsWrapperNode>;
144 template const RCP< const Map<int, long long, Kokkos::Compat::KokkosThreadsWrapperNode > > toXpetra<long long, Kokkos::Compat::KokkosThreadsWrapperNode>(const Epetra_BlockMap &map);
145 template const Epetra_Map & toEpetra<long long, Kokkos::Compat::KokkosThreadsWrapperNode >(const RCP< const Map<int, long long, Kokkos::Compat::KokkosThreadsWrapperNode > > &map);
146 template const Epetra_Map & toEpetra<long long, Kokkos::Compat::KokkosThreadsWrapperNode >(const Map< int, long long, Kokkos::Compat::KokkosThreadsWrapperNode> & map);
147 #endif
148 
149 #ifdef HAVE_TPETRA_INST_OPENMP
150 //template class EpetraMapT<long long, Kokkos::Compat::KokkosOpenMPWrapperNode >;
151 template const RCP< const Map<int, long long, Kokkos::Compat::KokkosOpenMPWrapperNode > > toXpetra<long long, Kokkos::Compat::KokkosOpenMPWrapperNode>(const Epetra_BlockMap &map);
152 template const Epetra_Map & toEpetra<long long, Kokkos::Compat::KokkosOpenMPWrapperNode >(const RCP< const Map<int, long long, Kokkos::Compat::KokkosOpenMPWrapperNode > > &map);
153 template const Epetra_Map & toEpetra<long long, Kokkos::Compat::KokkosOpenMPWrapperNode >(const Map< int, long long, Kokkos::Compat::KokkosOpenMPWrapperNode> & map);
154 #endif
155 
156 #ifdef HAVE_TPETRA_INST_CUDA
157 typedef Kokkos::Compat::KokkosCudaWrapperNode default_node_type;
158 //template class EpetraMapT<long long, default_node_type >;
159 template const RCP< const Map<int, long long, default_node_type > > toXpetra<long long, default_node_type>(const Epetra_BlockMap &map);
160 template const Epetra_Map & toEpetra<long long, default_node_type >(const RCP< const Map<int, long long, default_node_type > > &map);
161 template const Epetra_Map & toEpetra<long long, default_node_type >(const Map< int, long long, default_node_type> & map);
162 #endif
163 
164 #else
165 // Tpetra is disabled and Kokkos not available: use dummy node type
166 typedef Xpetra::EpetraNode default_node_type;
167 template const RCP< const Map<int, long long, default_node_type > > toXpetra<long long, default_node_type>(const Epetra_BlockMap &map);
168 template const Epetra_Map & toEpetra<long long, default_node_type >(const RCP< const Map<int, long long, default_node_type > > &map);
169 template const Epetra_Map & toEpetra<long long, default_node_type >(const Map< int, long long, default_node_type> & map);
170 #endif // HAVE_XPETRA_TPETRA
171 
172 #endif // HAVE_XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
173 
174 }
175 
176 #endif // HAVE_XPETRA_EPETRA
177 
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, GlobalOrdinal, Node > > &graph)
virtual RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
#define XPETRA_RCP_DYNAMIC_CAST(type, obj, newObj, exceptionMsg)
RCP< const CrsGraph< int, GlobalOrdinal, Node > > toXpetra(const Epetra_CrsGraph &g)
const Epetra_Map & getEpetra_Map() const