Xpetra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Xpetra_EpetraMultiVectorFactory.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 #include "Xpetra_BlockedMultiVector.hpp"
12 
13 namespace Xpetra {
14 
15 // we need the Epetra specialization only if Epetra is enabled
16 #if defined(HAVE_XPETRA_EPETRA)
17 
18 #if !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
19 
22 }
23 
24 RCP<MultiVector<double, int, int, EpetraNode>>
26  Build(const Teuchos::RCP<const Map<int, int, EpetraNode>>& map, size_t NumVectors, bool zeroOut) {
28 
29  XPETRA_MONITOR("MultiVectorFactory::Build");
30 
31  RCP<const BlockedMap<LocalOrdinal, GlobalOrdinal, Node>> bmap = Teuchos::rcp_dynamic_cast<const BlockedMap<int, int, EpetraNode>>(map);
32 
33  if (!bmap.is_null()) {
34  return rcp(new BlockedMultiVector(bmap, NumVectors, zeroOut));
35  }
36 
37 #ifdef HAVE_XPETRA_TPETRA
38  if (map->lib() == UseTpetra) {
39  return rcp(new TpetraMultiVector<double, int, int, EpetraNode>(map, NumVectors, zeroOut));
40  }
41 #endif
42 
43  if (map->lib() == UseEpetra) {
44  return rcp(new EpetraMultiVectorT<int, EpetraNode>(map, NumVectors, zeroOut));
45  }
46 
48 }
49 
50 Teuchos::RCP<MultiVector<double, int, int, EpetraNode>>
52  Build(const Teuchos::RCP<const Map<int, int, EpetraNode>>& map,
53  const Teuchos::ArrayView<const Teuchos::ArrayView<const double>>& ArrayOfPtrs,
54  size_t NumVectors) {
55  XPETRA_MONITOR("MultiVectorFactory::Build");
56 
57 #ifdef HAVE_XPETRA_TPETRA
58  if (map->lib() == UseTpetra) {
59  return rcp(new TpetraMultiVector<double, int, int, EpetraNode>(map, ArrayOfPtrs, NumVectors));
60  }
61 #endif
62 
63  if (map->lib() == UseEpetra) {
64  return rcp(new EpetraMultiVectorT<int, EpetraNode>(map, ArrayOfPtrs, NumVectors));
65  }
66 
68 }
69 
70 Teuchos::RCP<MultiVector<double, int, int, EpetraNode>>
72  Build(const Teuchos::RCP<const MultiVector<double, int, int, EpetraNode>>& source,
73  Teuchos::DataAccess copyOrView) {
74  XPETRA_MONITOR("MultiVectorFactory::Build");
75 
76 #ifdef HAVE_XPETRA_TPETRA
77  if (source->getMap()->lib() == UseTpetra) {
78  return rcp(new TpetraMultiVector<double, int, int, EpetraNode>(*source, copyOrView));
79  }
80 #endif
81 
82  if (source->getMap()->lib() == UseEpetra) {
83  return rcp(new EpetraMultiVectorT<int, EpetraNode>(*source, copyOrView));
84  }
85 
87 }
88 
91 }
92 
93 RCP<MultiVector<int, int, int, EpetraNode>>
95  Build(const Teuchos::RCP<const Map<int, int, EpetraNode>>& map, size_t NumVectors, bool zeroOut) {
96  XPETRA_MONITOR("MultiVectorFactory::Build");
97 
98  RCP<const BlockedMap<int, int, EpetraNode>> bmap = Teuchos::rcp_dynamic_cast<const BlockedMap<int, int, EpetraNode>>(map);
99 
100  if (!bmap.is_null()) {
101  return rcp(new BlockedMultiVector<int, int, int, EpetraNode>(bmap, NumVectors, zeroOut));
102  }
103 
104 #ifdef HAVE_XPETRA_TPETRA
105  if (map->lib() == UseTpetra) {
106  return rcp(new TpetraMultiVector<int, int, int, EpetraNode>(map, NumVectors, zeroOut));
107  }
108 #endif
109 
110  if (map->lib() == UseEpetra) {
111  return rcp(new EpetraIntMultiVectorT<int, EpetraNode>(map, NumVectors, zeroOut));
112  }
113 
115 }
116 
117 Teuchos::RCP<MultiVector<int, int, int, EpetraNode>>
119  Build(const Teuchos::RCP<const Map<int, int, EpetraNode>>& map,
120  const Teuchos::ArrayView<const Teuchos::ArrayView<const int>>& ArrayOfPtrs,
121  size_t NumVectors) {
122  XPETRA_MONITOR("MultiVectorFactory::Build");
123 
124 #ifdef HAVE_XPETRA_TPETRA
125  if (map->lib() == UseTpetra) {
126  return rcp(new TpetraMultiVector<int, int, int, EpetraNode>(map, ArrayOfPtrs, NumVectors));
127  }
128 #endif
129 
130  if (map->lib() == UseEpetra) {
131  return rcp(new EpetraIntMultiVectorT<int, EpetraNode>(map, ArrayOfPtrs, NumVectors));
132  }
133 
135 }
136 
137 Teuchos::RCP<MultiVector<int, int, int, EpetraNode>>
139  Build(const Teuchos::RCP<const MultiVector<int, int, int, EpetraNode>>& source,
140  Teuchos::DataAccess copyOrView) {
141  XPETRA_MONITOR("MultiVectorFactory::Build");
142 
143 #ifdef HAVE_XPETRA_TPETRA
144  if (source->getMap()->lib() == UseTpetra) {
145  return rcp(new TpetraMultiVector<int, int, int, EpetraNode>(*source, copyOrView));
146  }
147 #endif
148 
149  if (source->getMap()->lib() == UseEpetra) {
150  return rcp(new EpetraIntMultiVectorT<int, EpetraNode>(*source, copyOrView));
151  }
152 
154 }
155 
156 // we need the Epetra specialization only if Epetra is enabled
157 #if !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
158 
160 
161 RCP<MultiVector<double, int, long long, EpetraNode>>
163  Build(const Teuchos::RCP<const Map<int, long long, EpetraNode>>& map,
164  size_t NumVectors,
165  bool zeroOut) {
166  XPETRA_MONITOR("MultiVectorFactory::Build");
167 
168  RCP<const BlockedMap<int, long long, EpetraNode>> bmap = Teuchos::rcp_dynamic_cast<const BlockedMap<int, long long, EpetraNode>>(map);
169 
170  if (!bmap.is_null()) {
171  return rcp(new BlockedMultiVector<double, int, long long, EpetraNode>(bmap, NumVectors, zeroOut));
172  }
173 
174 #ifdef HAVE_XPETRA_TPETRA
175  if (map->lib() == UseTpetra) {
176  return rcp(new TpetraMultiVector<double, int, long long, EpetraNode>(map, NumVectors, zeroOut));
177  }
178 #endif
179 
180  if (map->lib() == UseEpetra) {
181  return rcp(new EpetraMultiVectorT<long long, EpetraNode>(map, NumVectors, zeroOut));
182  }
183 
185 }
186 
187 Teuchos::RCP<MultiVector<double, int, long long, EpetraNode>>
189  Build(const Teuchos::RCP<const Map<int, long long, EpetraNode>>& map,
190  const Teuchos::ArrayView<const Teuchos::ArrayView<const Scalar>>& ArrayOfPtrs,
191  size_t NumVectors) {
192  XPETRA_MONITOR("MultiVectorFactory::Build");
193 
194 #ifdef HAVE_XPETRA_TPETRA
195  if (map->lib() == UseTpetra) {
196  return rcp(new TpetraMultiVector<double, int, long long, EpetraNode>(map, ArrayOfPtrs, NumVectors));
197  }
198 #endif
199 
200  if (map->lib() == UseEpetra) {
201  return rcp(new EpetraMultiVectorT<long long, EpetraNode>(map, ArrayOfPtrs, NumVectors));
202  }
203 
205 }
206 
207 Teuchos::RCP<MultiVector<double, int, long long, EpetraNode>>
209  Build(const Teuchos::RCP<const MultiVector<double, int, long long, EpetraNode>>& source,
210  Teuchos::DataAccess copyOrView) {
211  XPETRA_MONITOR("MultiVectorFactory::Build");
212 
213 #ifdef HAVE_XPETRA_TPETRA
214  if (source->getMap()->lib() == UseTpetra) {
215  return rcp(new TpetraMultiVector<double, int, long long, EpetraNode>(*source, copyOrView));
216  }
217 #endif
218 
219  if (source->getMap()->lib() == UseEpetra) {
220  return rcp(new EpetraMultiVectorT<long long, EpetraNode>(*source, copyOrView));
221  }
222 
224 }
225 
228 }
229 
230 RCP<MultiVector<int, int, long long, EpetraNode>>
232  Build(const Teuchos::RCP<const Map<int, long long, EpetraNode>>& map,
233  size_t NumVectors,
234  bool zeroOut) {
235  XPETRA_MONITOR("MultiVectorFactory::Build");
236 
237  RCP<const BlockedMap<int, long long, EpetraNode>> bmap = Teuchos::rcp_dynamic_cast<const BlockedMap<int, long long, EpetraNode>>(map);
238 
239  if (!bmap.is_null()) {
240  return rcp(new BlockedMultiVector<int, int, long long, EpetraNode>(bmap, NumVectors, zeroOut));
241  }
242 
243 #ifdef HAVE_XPETRA_TPETRA
244  if (map->lib() == UseTpetra) {
245  return rcp(new TpetraMultiVector<int, int, long long, EpetraNode>(map, NumVectors, zeroOut));
246  }
247 #endif
248 
249  if (map->lib() == UseEpetra) {
250  return rcp(new EpetraIntMultiVectorT<long long, EpetraNode>(map, NumVectors, zeroOut));
251  }
252 
254 }
255 
256 Teuchos::RCP<MultiVector<int, int, long long, EpetraNode>>
258  Build(const Teuchos::RCP<const Map<int, long long, Node>>& map,
259  const Teuchos::ArrayView<const Teuchos::ArrayView<const int>>& ArrayOfPtrs,
260  size_t NumVectors) {
261  XPETRA_MONITOR("MultiVectorFactory::Build");
262 
263 #ifdef HAVE_XPETRA_TPETRA
264  if (map->lib() == UseTpetra) {
265  return rcp(new TpetraMultiVector<int, int, long long, EpetraNode>(map, ArrayOfPtrs, NumVectors));
266  }
267 #endif
268 
269  if (map->lib() == UseEpetra) {
270  return rcp(new EpetraIntMultiVectorT<long long, EpetraNode>(map, ArrayOfPtrs, NumVectors));
271  }
272 
274 }
275 
276 Teuchos::RCP<MultiVector<int, int, long long, EpetraNode>>
278  Build(const Teuchos::RCP<const MultiVector<int, int, long long, EpetraNode>>& source,
279  Teuchos::DataAccess copyOrView) {
280  XPETRA_MONITOR("MultiVectorFactory::Build");
281 
282 #ifdef HAVE_XPETRA_TPETRA
283  if (source->getMap()->lib() == UseTpetra) {
284  return rcp(new TpetraMultiVector<int, int, long long, EpetraNode>(*source, copyOrView));
285  }
286 #endif
287 
288  if (source->getMap()->lib() == UseEpetra) {
289  return rcp(new EpetraIntMultiVectorT<long long, EpetraNode>(*source, copyOrView));
290  }
291 
293 }
294 
295 #endif // END !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
296 
297 #endif // END !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
298 
299 #endif // END HAVE_XPETRA_EPETRA
300 
301 } // namespace Xpetra
static Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node >> &map, size_t NumVectors, bool zeroOut=true)
Constructor specifying the number of non-zeros for all rows.
MultiVectorFactory()
Private constructor. This is a static class.
#define XPETRA_FACTORY_END
#define XPETRA_MONITOR(funcName)