Xpetra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Xpetra_EpetraMultiVector.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Xpetra: A linear algebra interface package
4 //
5 // Copyright 2012 NTESS and the Xpetra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
11 
12 #include "Xpetra_EpetraImport.hpp"
13 #include "Xpetra_EpetraExport.hpp"
14 #include "Xpetra_Exceptions.hpp"
15 
16 #include "Xpetra_EpetraVector.hpp"
17 
18 #include "Epetra_SerialComm.h"
19 
20 namespace Xpetra {
21 
22 // specialization for GO=int and NO=EpetraNode
23 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
24 Teuchos::RCP<const Vector<double, int, int, EpetraNode> > EpetraMultiVectorT<int, EpetraNode>::getVector(size_t j) const {
25  XPETRA_MONITOR("EpetraMultiVectorT::getVector");
26  return rcp(new Xpetra::EpetraVectorT<int, EpetraNode>(vec_, j)); // See constructor EpetraVectorT(const RCP<EpetraMultiVectorT> &mv, size_t j) for more info
27 }
28 
30 Teuchos::RCP<Vector<double, int, int, EpetraNode> > EpetraMultiVectorT<int, EpetraNode>::getVectorNonConst(size_t j) {
31  XPETRA_MONITOR("EpetraMultiVectorT::getVector");
32  return rcp(new EpetraVectorT<int, EpetraNode>(vec_, j)); // See constructor EpetraVectorT(const RCP<EpetraMultiVectorT> &mv, size_t j) for more info
33 }
34 #endif
35 
36 // specialization for GO=long long and NO=EpetraNode
37 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
38 Teuchos::RCP<const Vector<double, int, long long, EpetraNode> > EpetraMultiVectorT<long long, EpetraNode>::getVector(size_t j) const {
39  XPETRA_MONITOR("EpetraMultiVectorT::getVector");
40  return rcp(new Xpetra::EpetraVectorT<long long, EpetraNode>(vec_, j)); // See constructor EpetraVectorT(const RCP<EpetraMultiVectorT> &mv, size_t j) for more info
41 }
42 
44 Teuchos::RCP<Vector<double, int, long long, EpetraNode> > EpetraMultiVectorT<long long, EpetraNode>::getVectorNonConst(size_t j) {
45  XPETRA_MONITOR("EpetraMultiVectorT::getVector");
46  return rcp(new EpetraVectorT<long long, EpetraNode>(vec_, j)); // See constructor EpetraVectorT(const RCP<EpetraMultiVectorT> &mv, size_t j) for more info
47 }
48 #endif
49 
50 // TODO: move that elsewhere
51 template <class GlobalOrdinal, class Node>
52 const Epetra_MultiVector &toEpetra(const MultiVector<double, int, GlobalOrdinal, Node> &x) {
54  return *tX.getEpetra_MultiVector();
55 }
56 
57 template <class GlobalOrdinal, class Node>
60  return *tX.getEpetra_MultiVector();
61 }
62 //
63 
64 template <class GlobalOrdinal, class Node>
65 RCP<MultiVector<double, int, GlobalOrdinal, Node> > toXpetra(RCP<Epetra_MultiVector> vec) {
66  if (!vec.is_null())
67  return rcp(new EpetraMultiVectorT<GlobalOrdinal, Node>(vec));
68 
69  return Teuchos::null;
70 }
71 
72 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
73 #ifdef HAVE_XPETRA_TPETRA
74 #include "TpetraCore_config.h"
75 #if ((defined(EPETRA_HAVE_OMP) && !defined(HAVE_TPETRA_INST_OPENMP)) || \
76  (!defined(EPETRA_HAVE_OMP) && !defined(HAVE_TPETRA_INST_SERIAL)))
77 template class EpetraMultiVectorT<int, Xpetra::EpetraNode>;
78 template RCP<MultiVector<double, int, int, Xpetra::EpetraNode> > toXpetra<int, Xpetra::EpetraNode>(RCP<Epetra_MultiVector>);
79 template Epetra_MultiVector &toEpetra<int, Xpetra::EpetraNode>(MultiVector<double, int, int, Xpetra::EpetraNode> &);
80 template const Epetra_MultiVector &toEpetra<int, Xpetra::EpetraNode>(const MultiVector<double, int, int, Xpetra::EpetraNode> &);
81 #endif
82 
83 #ifdef HAVE_TPETRA_INST_SERIAL
84 template class EpetraMultiVectorT<int, Tpetra::KokkosCompat::KokkosSerialWrapperNode>;
85 template RCP<MultiVector<double, int, int, Tpetra::KokkosCompat::KokkosSerialWrapperNode> > toXpetra<int, Tpetra::KokkosCompat::KokkosSerialWrapperNode>(RCP<Epetra_MultiVector>);
86 template Epetra_MultiVector &toEpetra<int, Tpetra::KokkosCompat::KokkosSerialWrapperNode>(MultiVector<double, int, int, Tpetra::KokkosCompat::KokkosSerialWrapperNode> &);
87 template const Epetra_MultiVector &toEpetra<int, Tpetra::KokkosCompat::KokkosSerialWrapperNode>(const MultiVector<double, int, int, Tpetra::KokkosCompat::KokkosSerialWrapperNode> &);
88 #endif
89 #ifdef HAVE_TPETRA_INST_PTHREAD
90 template class EpetraMultiVectorT<int, Tpetra::KokkosCompat::KokkosThreadsWrapperNode>;
91 template RCP<MultiVector<double, int, int, Tpetra::KokkosCompat::KokkosThreadsWrapperNode> > toXpetra<int, Tpetra::KokkosCompat::KokkosThreadsWrapperNode>(RCP<Epetra_MultiVector>);
92 template Epetra_MultiVector &toEpetra<int, Tpetra::KokkosCompat::KokkosThreadsWrapperNode>(MultiVector<double, int, int, Tpetra::KokkosCompat::KokkosThreadsWrapperNode> &);
93 template const Epetra_MultiVector &toEpetra<int, Tpetra::KokkosCompat::KokkosThreadsWrapperNode>(const MultiVector<double, int, int, Tpetra::KokkosCompat::KokkosThreadsWrapperNode> &);
94 #endif
95 #ifdef HAVE_TPETRA_INST_OPENMP
96 template class EpetraMultiVectorT<int, Tpetra::KokkosCompat::KokkosOpenMPWrapperNode>;
97 template RCP<MultiVector<double, int, int, Tpetra::KokkosCompat::KokkosOpenMPWrapperNode> > toXpetra<int, Tpetra::KokkosCompat::KokkosOpenMPWrapperNode>(RCP<Epetra_MultiVector>);
98 template Epetra_MultiVector &toEpetra<int, Tpetra::KokkosCompat::KokkosOpenMPWrapperNode>(MultiVector<double, int, int, Tpetra::KokkosCompat::KokkosOpenMPWrapperNode> &);
99 template const Epetra_MultiVector &toEpetra<int, Tpetra::KokkosCompat::KokkosOpenMPWrapperNode>(const MultiVector<double, int, int, Tpetra::KokkosCompat::KokkosOpenMPWrapperNode> &);
100 #endif
101 #ifdef HAVE_TPETRA_INST_CUDA
102 template class EpetraMultiVectorT<int, Tpetra::KokkosCompat::KokkosCudaWrapperNode>;
103 template RCP<MultiVector<double, int, int, Tpetra::KokkosCompat::KokkosCudaWrapperNode> > toXpetra<int, Tpetra::KokkosCompat::KokkosCudaWrapperNode>(RCP<Epetra_MultiVector>);
104 template Epetra_MultiVector &toEpetra<int, Tpetra::KokkosCompat::KokkosCudaWrapperNode>(MultiVector<double, int, int, Tpetra::KokkosCompat::KokkosCudaWrapperNode> &);
105 template const Epetra_MultiVector &toEpetra<int, Tpetra::KokkosCompat::KokkosCudaWrapperNode>(const MultiVector<double, int, int, Tpetra::KokkosCompat::KokkosCudaWrapperNode> &);
106 #endif
107 #ifdef HAVE_TPETRA_INST_HIP
108 template class EpetraMultiVectorT<int, Tpetra::KokkosCompat::KokkosHIPWrapperNode>;
109 template RCP<MultiVector<double, int, int, Tpetra::KokkosCompat::KokkosHIPWrapperNode> > toXpetra<int, Tpetra::KokkosCompat::KokkosHIPWrapperNode>(RCP<Epetra_MultiVector>);
110 template Epetra_MultiVector &toEpetra<int, Tpetra::KokkosCompat::KokkosHIPWrapperNode>(MultiVector<double, int, int, Tpetra::KokkosCompat::KokkosHIPWrapperNode> &);
111 template const Epetra_MultiVector &toEpetra<int, Tpetra::KokkosCompat::KokkosHIPWrapperNode>(const MultiVector<double, int, int, Tpetra::KokkosCompat::KokkosHIPWrapperNode> &);
112 #endif
113 #else // Tpetra is disabled
114 typedef Xpetra::EpetraNode default_node_type;
115 template class EpetraMultiVectorT<int, default_node_type>;
116 template RCP<MultiVector<double, int, int, default_node_type> > toXpetra<int, default_node_type>(RCP<Epetra_MultiVector>);
117 template Epetra_MultiVector &toEpetra<int, default_node_type>(MultiVector<double, int, int, default_node_type> &);
118 template const Epetra_MultiVector &toEpetra<int, default_node_type>(const MultiVector<double, int, int, default_node_type> &);
119 #endif
120 #endif
121 
122 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
123 #ifdef HAVE_XPETRA_TPETRA
124 #include "TpetraCore_config.h"
125 #if ((defined(EPETRA_HAVE_OMP) && !defined(HAVE_TPETRA_INST_OPENMP)) || \
126  (!defined(EPETRA_HAVE_OMP) && !defined(HAVE_TPETRA_INST_SERIAL)))
127 template class EpetraMultiVectorT<long long, Xpetra::EpetraNode>;
128 template RCP<MultiVector<double, int, long long, Xpetra::EpetraNode> > toXpetra<long long, Xpetra::EpetraNode>(RCP<Epetra_MultiVector>);
129 template Epetra_MultiVector &toEpetra<long long, Xpetra::EpetraNode>(MultiVector<double, int, long long, Xpetra::EpetraNode> &);
130 template const Epetra_MultiVector &toEpetra<long long, Xpetra::EpetraNode>(const MultiVector<double, int, long long, Xpetra::EpetraNode> &);
131 #endif
132 
133 #ifdef HAVE_TPETRA_INST_SERIAL
134 template class EpetraMultiVectorT<long long, Tpetra::KokkosCompat::KokkosSerialWrapperNode>;
135 template RCP<MultiVector<double, int, long long, Tpetra::KokkosCompat::KokkosSerialWrapperNode> > toXpetra<long long, Tpetra::KokkosCompat::KokkosSerialWrapperNode>(RCP<Epetra_MultiVector>);
136 template Epetra_MultiVector &toEpetra<long long, Tpetra::KokkosCompat::KokkosSerialWrapperNode>(MultiVector<double, int, long long, Tpetra::KokkosCompat::KokkosSerialWrapperNode> &);
137 template const Epetra_MultiVector &toEpetra<long long, Tpetra::KokkosCompat::KokkosSerialWrapperNode>(const MultiVector<double, int, long long, Tpetra::KokkosCompat::KokkosSerialWrapperNode> &);
138 #endif
139 #ifdef HAVE_TPETRA_INST_PTHREAD
140 template class EpetraMultiVectorT<long long, Tpetra::KokkosCompat::KokkosThreadsWrapperNode>;
141 template RCP<MultiVector<double, int, long long, Tpetra::KokkosCompat::KokkosThreadsWrapperNode> > toXpetra<long long, Tpetra::KokkosCompat::KokkosThreadsWrapperNode>(RCP<Epetra_MultiVector>);
142 template Epetra_MultiVector &toEpetra<long long, Tpetra::KokkosCompat::KokkosThreadsWrapperNode>(MultiVector<double, int, long long, Tpetra::KokkosCompat::KokkosThreadsWrapperNode> &);
143 template const Epetra_MultiVector &toEpetra<long long, Tpetra::KokkosCompat::KokkosThreadsWrapperNode>(const MultiVector<double, int, long long, Tpetra::KokkosCompat::KokkosThreadsWrapperNode> &);
144 #endif
145 #ifdef HAVE_TPETRA_INST_OPENMP
146 template class EpetraMultiVectorT<long long, Tpetra::KokkosCompat::KokkosOpenMPWrapperNode>;
147 template RCP<MultiVector<double, int, long long, Tpetra::KokkosCompat::KokkosOpenMPWrapperNode> > toXpetra<long long, Tpetra::KokkosCompat::KokkosOpenMPWrapperNode>(RCP<Epetra_MultiVector>);
148 template Epetra_MultiVector &toEpetra<long long, Tpetra::KokkosCompat::KokkosOpenMPWrapperNode>(MultiVector<double, int, long long, Tpetra::KokkosCompat::KokkosOpenMPWrapperNode> &);
149 template const Epetra_MultiVector &toEpetra<long long, Tpetra::KokkosCompat::KokkosOpenMPWrapperNode>(const MultiVector<double, int, long long, Tpetra::KokkosCompat::KokkosOpenMPWrapperNode> &);
150 #endif
151 #ifdef HAVE_TPETRA_INST_CUDA
152 template class EpetraMultiVectorT<long long, Tpetra::KokkosCompat::KokkosCudaWrapperNode>;
153 template RCP<MultiVector<double, int, long long, Tpetra::KokkosCompat::KokkosCudaWrapperNode> > toXpetra<long long, Tpetra::KokkosCompat::KokkosCudaWrapperNode>(RCP<Epetra_MultiVector>);
154 template Epetra_MultiVector &toEpetra<long long, Tpetra::KokkosCompat::KokkosCudaWrapperNode>(MultiVector<double, int, long long, Tpetra::KokkosCompat::KokkosCudaWrapperNode> &);
155 template const Epetra_MultiVector &toEpetra<long long, Tpetra::KokkosCompat::KokkosCudaWrapperNode>(const MultiVector<double, int, long long, Tpetra::KokkosCompat::KokkosCudaWrapperNode> &);
156 #endif
157 #ifdef HAVE_TPETRA_INST_HIP
158 template class EpetraMultiVectorT<long long, Tpetra::KokkosCompat::KokkosHIPWrapperNode>;
159 template RCP<MultiVector<double, int, long long, Tpetra::KokkosCompat::KokkosHIPWrapperNode> > toXpetra<long long, Tpetra::KokkosCompat::KokkosHIPWrapperNode>(RCP<Epetra_MultiVector>);
160 template Epetra_MultiVector &toEpetra<long long, Tpetra::KokkosCompat::KokkosHIPWrapperNode>(MultiVector<double, int, long long, Tpetra::KokkosCompat::KokkosHIPWrapperNode> &);
161 template const Epetra_MultiVector &toEpetra<long long, Tpetra::KokkosCompat::KokkosHIPWrapperNode>(const MultiVector<double, int, long long, Tpetra::KokkosCompat::KokkosHIPWrapperNode> &);
162 #endif
163 #else // Tpetra is disabled
164 typedef Xpetra::EpetraNode default_node_type;
165 template class EpetraMultiVectorT<long long, default_node_type>;
166 template RCP<MultiVector<double, int, long long, default_node_type> > toXpetra<long long, default_node_type>(RCP<Epetra_MultiVector>);
167 template Epetra_MultiVector &toEpetra<long long, default_node_type>(MultiVector<double, int, long long, default_node_type> &);
168 template const Epetra_MultiVector &toEpetra<long long, default_node_type>(const MultiVector<double, int, long long, default_node_type> &);
169 #endif
170 #endif
171 
172 } // namespace Xpetra
#define XPETRA_DYNAMIC_CAST(type, obj, newObj, exceptionMsg)
Tpetra::KokkosCompat::KokkosSerialWrapperNode EpetraNode
Teuchos::RCP< const Vector< double, int, GlobalOrdinal, Node > > getVector(size_t j) const
Return a Vector which is a const view of column j.
#define XPETRA_MONITOR(funcName)
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, GlobalOrdinal, Node > > &graph)
Teuchos::RCP< Vector< double, int, GlobalOrdinal, Node > > getVectorNonConst(size_t j)
Return a Vector which is a nonconst view of column j.
RCP< const CrsGraph< int, GlobalOrdinal, Node > > toXpetra(const Epetra_CrsGraph &g)