Xpetra  Version of the Day
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 
50 namespace Xpetra {
51 
52 
53 
54 // we need the Epetra specialization only if Epetra is enabled
55 #if defined(HAVE_XPETRA_EPETRA)
56 
57 #if !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
58 
59 
62 {
63 }
64 
65 
68 Build(const Teuchos::RCP<const Map<int, int, EpetraNode>>& map, size_t NumVectors, bool zeroOut)
69 {
71 
72  XPETRA_MONITOR("MultiVectorFactory::Build");
73 
74  RCP<const BlockedMap<LocalOrdinal, GlobalOrdinal, Node>> bmap = Teuchos::rcp_dynamic_cast<const BlockedMap<int, int, EpetraNode>>(map);
75 
76  if(!bmap.is_null())
77  {
78  return rcp(new BlockedMultiVector(bmap, NumVectors, zeroOut));
79  }
80 
81 #ifdef HAVE_XPETRA_TPETRA
82  if(map->lib() == UseTpetra)
83  {
84  return rcp(new TpetraMultiVector<double, int, int, EpetraNode>(map, NumVectors, zeroOut));
85  }
86 #endif
87 
88  if(map->lib() == UseEpetra)
89  {
90  return rcp(new EpetraMultiVectorT<int, EpetraNode>(map, NumVectors, zeroOut));
91  }
92 
94 }
95 
96 
100  const Teuchos::ArrayView<const Teuchos::ArrayView<const double>>& ArrayOfPtrs,
101  size_t NumVectors)
102 {
103  XPETRA_MONITOR("MultiVectorFactory::Build");
104 
105 #ifdef HAVE_XPETRA_TPETRA
106  if(map->lib() == UseTpetra)
107  {
108  return rcp(new TpetraMultiVector<double, int, int, EpetraNode>(map, ArrayOfPtrs, NumVectors));
109  }
110 #endif
111 
112  if(map->lib() == UseEpetra)
113  {
114  return rcp(new EpetraMultiVectorT<int, EpetraNode>(map, ArrayOfPtrs, NumVectors));
115  }
116 
118 }
119 
120 
124  Teuchos::DataAccess copyOrView)
125 {
126  XPETRA_MONITOR("MultiVectorFactory::Build");
127 
128 #ifdef HAVE_XPETRA_TPETRA
129  if(source->getMap()->lib() == UseTpetra)
130  {
131  return rcp(new TpetraMultiVector<double, int, int, EpetraNode>(*source, copyOrView));
132  }
133 #endif
134 
135  if(source->getMap()->lib() == UseEpetra)
136  {
137  return rcp(new EpetraMultiVectorT<int, EpetraNode>(*source, copyOrView));
138  }
139 
141 }
142 
143 
146 {
147 }
148 
149 
152 Build(const Teuchos::RCP<const Map<int, int, EpetraNode>>& map, size_t NumVectors, bool zeroOut)
153 {
154  XPETRA_MONITOR("MultiVectorFactory::Build");
155 
156  RCP<const BlockedMap<int, int, EpetraNode>> bmap = Teuchos::rcp_dynamic_cast<const BlockedMap<int, int, EpetraNode>>(map);
157 
158  if(!bmap.is_null())
159  {
160  return rcp(new BlockedMultiVector<int, int, int, EpetraNode>(bmap, NumVectors, zeroOut));
161  }
162 
163 #ifdef HAVE_XPETRA_TPETRA
164  if(map->lib() == UseTpetra)
165  {
166  return rcp(new TpetraMultiVector<int, int, int, EpetraNode>(map, NumVectors, zeroOut));
167  }
168 #endif
169 
170  if(map->lib() == UseEpetra)
171  {
172  return rcp(new EpetraIntMultiVectorT<int, EpetraNode>(map, NumVectors, zeroOut));
173  }
174 
176 }
177 
178 
182  const Teuchos::ArrayView<const Teuchos::ArrayView<const int>>& ArrayOfPtrs,
183  size_t NumVectors)
184 {
185  XPETRA_MONITOR("MultiVectorFactory::Build");
186 
187 #ifdef HAVE_XPETRA_TPETRA
188  if(map->lib() == UseTpetra)
189  {
190  return rcp(new TpetraMultiVector<int, int, int, EpetraNode>(map, ArrayOfPtrs, NumVectors));
191  }
192 #endif
193 
194  if(map->lib() == UseEpetra)
195  {
196  return rcp(new EpetraIntMultiVectorT<int, EpetraNode>(map, ArrayOfPtrs, NumVectors));
197  }
198 
200 }
201 
202 
206  Teuchos::DataAccess copyOrView)
207 {
208  XPETRA_MONITOR("MultiVectorFactory::Build");
209 
210 #ifdef HAVE_XPETRA_TPETRA
211  if(source->getMap()->lib() == UseTpetra)
212  {
213  return rcp(new TpetraMultiVector<int, int, int, EpetraNode>(*source, copyOrView));
214  }
215 #endif
216 
217  if(source->getMap()->lib() == UseEpetra)
218  {
219  return rcp(new EpetraIntMultiVectorT<int, EpetraNode>(*source, copyOrView));
220  }
221 
223 }
224 
225 
226 // we need the Epetra specialization only if Epetra is enabled
227 #if !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
228 
229 
230 
232 
233 
237  size_t NumVectors,
238  bool zeroOut)
239 {
240  XPETRA_MONITOR("MultiVectorFactory::Build");
241 
242  RCP<const BlockedMap<int, long long, EpetraNode>> bmap = Teuchos::rcp_dynamic_cast<const BlockedMap<int, long long, EpetraNode>>(map);
243 
244  if(!bmap.is_null())
245  {
246  return rcp(new BlockedMultiVector<double, int, long long, EpetraNode>(bmap, NumVectors, zeroOut));
247  }
248 
249 #ifdef HAVE_XPETRA_TPETRA
250  if(map->lib() == UseTpetra)
251  {
252  return rcp(new TpetraMultiVector<double, int, long long, EpetraNode>(map, NumVectors, zeroOut));
253  }
254 #endif
255 
256  if(map->lib() == UseEpetra)
257  {
258  return rcp(new EpetraMultiVectorT<long long, EpetraNode>(map, NumVectors, zeroOut));
259  }
260 
262 }
263 
264 
267 Build(const Teuchos::RCP<const Map<int, long long, EpetraNode>>& map,
268  const Teuchos::ArrayView<const Teuchos::ArrayView<const Scalar>>& ArrayOfPtrs,
269  size_t NumVectors)
270 {
271  XPETRA_MONITOR("MultiVectorFactory::Build");
272 
273 #ifdef HAVE_XPETRA_TPETRA
274  if(map->lib() == UseTpetra)
275  {
276  return rcp(new TpetraMultiVector<double, int, long long, EpetraNode>(map, ArrayOfPtrs, NumVectors));
277  }
278 #endif
279 
280  if(map->lib() == UseEpetra)
281  {
282  return rcp(new EpetraMultiVectorT<long long, EpetraNode>(map, ArrayOfPtrs, NumVectors));
283  }
284 
286 }
287 
288 
292  Teuchos::DataAccess copyOrView)
293 {
294  XPETRA_MONITOR("MultiVectorFactory::Build");
295 
296 #ifdef HAVE_XPETRA_TPETRA
297  if(source->getMap()->lib() == UseTpetra)
298  {
299  return rcp(new TpetraMultiVector<double, int, long long, EpetraNode>(*source, copyOrView));
300  }
301 #endif
302 
303  if(source->getMap()->lib() == UseEpetra)
304  {
305  return rcp(new EpetraMultiVectorT<long long, EpetraNode>(*source, copyOrView));
306  }
307 
309 }
310 
311 
314 {
315 }
316 
317 
321  size_t NumVectors,
322  bool zeroOut)
323 {
324  XPETRA_MONITOR("MultiVectorFactory::Build");
325 
326  RCP<const BlockedMap<int, long long, EpetraNode>> bmap = Teuchos::rcp_dynamic_cast<const BlockedMap<int, long long, EpetraNode>>(map);
327 
328  if(!bmap.is_null())
329  {
330  return rcp(new BlockedMultiVector<int, int, long long, EpetraNode>(bmap, NumVectors, zeroOut));
331  }
332 
333 #ifdef HAVE_XPETRA_TPETRA
334  if(map->lib() == UseTpetra)
335  {
336  return rcp(new TpetraMultiVector<int, int, long long, EpetraNode>(map, NumVectors, zeroOut));
337  }
338 #endif
339 
340  if(map->lib() == UseEpetra)
341  {
342  return rcp(new EpetraIntMultiVectorT<long long, EpetraNode>(map, NumVectors, zeroOut));
343  }
344 
346 }
347 
348 
351 Build(const Teuchos::RCP<const Map<int, long long, Node>>& map,
352  const Teuchos::ArrayView<const Teuchos::ArrayView<const int>>& ArrayOfPtrs,
353  size_t NumVectors)
354 {
355  XPETRA_MONITOR("MultiVectorFactory::Build");
356 
357 #ifdef HAVE_XPETRA_TPETRA
358  if(map->lib() == UseTpetra)
359  {
360  return rcp(new TpetraMultiVector<int, int, long long, EpetraNode>(map, ArrayOfPtrs, NumVectors));
361  }
362 #endif
363 
364  if(map->lib() == UseEpetra)
365  {
366  return rcp(new EpetraIntMultiVectorT<long long, EpetraNode>(map, ArrayOfPtrs, NumVectors));
367  }
368 
370 }
371 
372 
376  Teuchos::DataAccess copyOrView)
377 {
378  XPETRA_MONITOR("MultiVectorFactory::Build");
379 
380 #ifdef HAVE_XPETRA_TPETRA
381  if(source->getMap()->lib() == UseTpetra)
382  {
383  return rcp(new TpetraMultiVector<int, int, long long, EpetraNode>(*source, copyOrView));
384  }
385 #endif
386 
387  if(source->getMap()->lib() == UseEpetra)
388  {
389  return rcp(new EpetraIntMultiVectorT<long long, EpetraNode>(*source, copyOrView));
390  }
391 
393 }
394 
395 
396 #endif // END !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
397 
398 #endif // END !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
399 
400 #endif // END HAVE_XPETRA_EPETRA
401 
402 
403 } // namespace Xpetra
#define XPETRA_MONITOR(funcName)
#define XPETRA_FACTORY_END
bool is_null() const
MultiVectorFactory()
Private constructor. This is a static class.
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.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Xpetra namespace