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 // ***********************************************************************
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
47 #include "Xpetra_BlockedMultiVector.hpp"
48 
49 namespace Xpetra {
50 
51 // we need the Epetra specialization only if Epetra is enabled
52 #if defined(HAVE_XPETRA_EPETRA)
53 
54 #if !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
55 
58 }
59 
60 RCP<MultiVector<double, int, int, EpetraNode>>
62  Build(const Teuchos::RCP<const Map<int, int, EpetraNode>>& map, size_t NumVectors, bool zeroOut) {
64 
65  XPETRA_MONITOR("MultiVectorFactory::Build");
66 
67  RCP<const BlockedMap<LocalOrdinal, GlobalOrdinal, Node>> bmap = Teuchos::rcp_dynamic_cast<const BlockedMap<int, int, EpetraNode>>(map);
68 
69  if (!bmap.is_null()) {
70  return rcp(new BlockedMultiVector(bmap, NumVectors, zeroOut));
71  }
72 
73 #ifdef HAVE_XPETRA_TPETRA
74  if (map->lib() == UseTpetra) {
75  return rcp(new TpetraMultiVector<double, int, int, EpetraNode>(map, NumVectors, zeroOut));
76  }
77 #endif
78 
79  if (map->lib() == UseEpetra) {
80  return rcp(new EpetraMultiVectorT<int, EpetraNode>(map, NumVectors, zeroOut));
81  }
82 
84 }
85 
86 Teuchos::RCP<MultiVector<double, int, int, EpetraNode>>
88  Build(const Teuchos::RCP<const Map<int, int, EpetraNode>>& map,
89  const Teuchos::ArrayView<const Teuchos::ArrayView<const double>>& ArrayOfPtrs,
90  size_t NumVectors) {
91  XPETRA_MONITOR("MultiVectorFactory::Build");
92 
93 #ifdef HAVE_XPETRA_TPETRA
94  if (map->lib() == UseTpetra) {
95  return rcp(new TpetraMultiVector<double, int, int, EpetraNode>(map, ArrayOfPtrs, NumVectors));
96  }
97 #endif
98 
99  if (map->lib() == UseEpetra) {
100  return rcp(new EpetraMultiVectorT<int, EpetraNode>(map, ArrayOfPtrs, NumVectors));
101  }
102 
104 }
105 
106 Teuchos::RCP<MultiVector<double, int, int, EpetraNode>>
108  Build(const Teuchos::RCP<const MultiVector<double, int, int, EpetraNode>>& source,
109  Teuchos::DataAccess copyOrView) {
110  XPETRA_MONITOR("MultiVectorFactory::Build");
111 
112 #ifdef HAVE_XPETRA_TPETRA
113  if (source->getMap()->lib() == UseTpetra) {
114  return rcp(new TpetraMultiVector<double, int, int, EpetraNode>(*source, copyOrView));
115  }
116 #endif
117 
118  if (source->getMap()->lib() == UseEpetra) {
119  return rcp(new EpetraMultiVectorT<int, EpetraNode>(*source, copyOrView));
120  }
121 
123 }
124 
127 }
128 
129 RCP<MultiVector<int, int, int, EpetraNode>>
131  Build(const Teuchos::RCP<const Map<int, int, EpetraNode>>& map, size_t NumVectors, bool zeroOut) {
132  XPETRA_MONITOR("MultiVectorFactory::Build");
133 
134  RCP<const BlockedMap<int, int, EpetraNode>> bmap = Teuchos::rcp_dynamic_cast<const BlockedMap<int, int, EpetraNode>>(map);
135 
136  if (!bmap.is_null()) {
137  return rcp(new BlockedMultiVector<int, int, int, EpetraNode>(bmap, NumVectors, zeroOut));
138  }
139 
140 #ifdef HAVE_XPETRA_TPETRA
141  if (map->lib() == UseTpetra) {
142  return rcp(new TpetraMultiVector<int, int, int, EpetraNode>(map, NumVectors, zeroOut));
143  }
144 #endif
145 
146  if (map->lib() == UseEpetra) {
147  return rcp(new EpetraIntMultiVectorT<int, EpetraNode>(map, NumVectors, zeroOut));
148  }
149 
151 }
152 
153 Teuchos::RCP<MultiVector<int, int, int, EpetraNode>>
155  Build(const Teuchos::RCP<const Map<int, int, EpetraNode>>& map,
156  const Teuchos::ArrayView<const Teuchos::ArrayView<const int>>& ArrayOfPtrs,
157  size_t NumVectors) {
158  XPETRA_MONITOR("MultiVectorFactory::Build");
159 
160 #ifdef HAVE_XPETRA_TPETRA
161  if (map->lib() == UseTpetra) {
162  return rcp(new TpetraMultiVector<int, int, int, EpetraNode>(map, ArrayOfPtrs, NumVectors));
163  }
164 #endif
165 
166  if (map->lib() == UseEpetra) {
167  return rcp(new EpetraIntMultiVectorT<int, EpetraNode>(map, ArrayOfPtrs, NumVectors));
168  }
169 
171 }
172 
173 Teuchos::RCP<MultiVector<int, int, int, EpetraNode>>
175  Build(const Teuchos::RCP<const MultiVector<int, int, int, EpetraNode>>& source,
176  Teuchos::DataAccess copyOrView) {
177  XPETRA_MONITOR("MultiVectorFactory::Build");
178 
179 #ifdef HAVE_XPETRA_TPETRA
180  if (source->getMap()->lib() == UseTpetra) {
181  return rcp(new TpetraMultiVector<int, int, int, EpetraNode>(*source, copyOrView));
182  }
183 #endif
184 
185  if (source->getMap()->lib() == UseEpetra) {
186  return rcp(new EpetraIntMultiVectorT<int, EpetraNode>(*source, copyOrView));
187  }
188 
190 }
191 
192 // we need the Epetra specialization only if Epetra is enabled
193 #if !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
194 
196 
197 RCP<MultiVector<double, int, long long, EpetraNode>>
199  Build(const Teuchos::RCP<const Map<int, long long, EpetraNode>>& map,
200  size_t NumVectors,
201  bool zeroOut) {
202  XPETRA_MONITOR("MultiVectorFactory::Build");
203 
204  RCP<const BlockedMap<int, long long, EpetraNode>> bmap = Teuchos::rcp_dynamic_cast<const BlockedMap<int, long long, EpetraNode>>(map);
205 
206  if (!bmap.is_null()) {
207  return rcp(new BlockedMultiVector<double, int, long long, EpetraNode>(bmap, NumVectors, zeroOut));
208  }
209 
210 #ifdef HAVE_XPETRA_TPETRA
211  if (map->lib() == UseTpetra) {
212  return rcp(new TpetraMultiVector<double, int, long long, EpetraNode>(map, NumVectors, zeroOut));
213  }
214 #endif
215 
216  if (map->lib() == UseEpetra) {
217  return rcp(new EpetraMultiVectorT<long long, EpetraNode>(map, NumVectors, zeroOut));
218  }
219 
221 }
222 
223 Teuchos::RCP<MultiVector<double, int, long long, EpetraNode>>
225  Build(const Teuchos::RCP<const Map<int, long long, EpetraNode>>& map,
226  const Teuchos::ArrayView<const Teuchos::ArrayView<const Scalar>>& ArrayOfPtrs,
227  size_t NumVectors) {
228  XPETRA_MONITOR("MultiVectorFactory::Build");
229 
230 #ifdef HAVE_XPETRA_TPETRA
231  if (map->lib() == UseTpetra) {
232  return rcp(new TpetraMultiVector<double, int, long long, EpetraNode>(map, ArrayOfPtrs, NumVectors));
233  }
234 #endif
235 
236  if (map->lib() == UseEpetra) {
237  return rcp(new EpetraMultiVectorT<long long, EpetraNode>(map, ArrayOfPtrs, NumVectors));
238  }
239 
241 }
242 
243 Teuchos::RCP<MultiVector<double, int, long long, EpetraNode>>
245  Build(const Teuchos::RCP<const MultiVector<double, int, long long, EpetraNode>>& source,
246  Teuchos::DataAccess copyOrView) {
247  XPETRA_MONITOR("MultiVectorFactory::Build");
248 
249 #ifdef HAVE_XPETRA_TPETRA
250  if (source->getMap()->lib() == UseTpetra) {
251  return rcp(new TpetraMultiVector<double, int, long long, EpetraNode>(*source, copyOrView));
252  }
253 #endif
254 
255  if (source->getMap()->lib() == UseEpetra) {
256  return rcp(new EpetraMultiVectorT<long long, EpetraNode>(*source, copyOrView));
257  }
258 
260 }
261 
264 }
265 
266 RCP<MultiVector<int, int, long long, EpetraNode>>
268  Build(const Teuchos::RCP<const Map<int, long long, EpetraNode>>& map,
269  size_t NumVectors,
270  bool zeroOut) {
271  XPETRA_MONITOR("MultiVectorFactory::Build");
272 
273  RCP<const BlockedMap<int, long long, EpetraNode>> bmap = Teuchos::rcp_dynamic_cast<const BlockedMap<int, long long, EpetraNode>>(map);
274 
275  if (!bmap.is_null()) {
276  return rcp(new BlockedMultiVector<int, int, long long, EpetraNode>(bmap, NumVectors, zeroOut));
277  }
278 
279 #ifdef HAVE_XPETRA_TPETRA
280  if (map->lib() == UseTpetra) {
281  return rcp(new TpetraMultiVector<int, int, long long, EpetraNode>(map, NumVectors, zeroOut));
282  }
283 #endif
284 
285  if (map->lib() == UseEpetra) {
286  return rcp(new EpetraIntMultiVectorT<long long, EpetraNode>(map, NumVectors, zeroOut));
287  }
288 
290 }
291 
292 Teuchos::RCP<MultiVector<int, int, long long, EpetraNode>>
294  Build(const Teuchos::RCP<const Map<int, long long, Node>>& map,
295  const Teuchos::ArrayView<const Teuchos::ArrayView<const int>>& ArrayOfPtrs,
296  size_t NumVectors) {
297  XPETRA_MONITOR("MultiVectorFactory::Build");
298 
299 #ifdef HAVE_XPETRA_TPETRA
300  if (map->lib() == UseTpetra) {
301  return rcp(new TpetraMultiVector<int, int, long long, EpetraNode>(map, ArrayOfPtrs, NumVectors));
302  }
303 #endif
304 
305  if (map->lib() == UseEpetra) {
306  return rcp(new EpetraIntMultiVectorT<long long, EpetraNode>(map, ArrayOfPtrs, NumVectors));
307  }
308 
310 }
311 
312 Teuchos::RCP<MultiVector<int, int, long long, EpetraNode>>
314  Build(const Teuchos::RCP<const MultiVector<int, int, long long, EpetraNode>>& source,
315  Teuchos::DataAccess copyOrView) {
316  XPETRA_MONITOR("MultiVectorFactory::Build");
317 
318 #ifdef HAVE_XPETRA_TPETRA
319  if (source->getMap()->lib() == UseTpetra) {
320  return rcp(new TpetraMultiVector<int, int, long long, EpetraNode>(*source, copyOrView));
321  }
322 #endif
323 
324  if (source->getMap()->lib() == UseEpetra) {
325  return rcp(new EpetraIntMultiVectorT<long long, EpetraNode>(*source, copyOrView));
326  }
327 
329 }
330 
331 #endif // END !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
332 
333 #endif // END !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
334 
335 #endif // END HAVE_XPETRA_EPETRA
336 
337 } // 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)