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 
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 
66 RCP<MultiVector<double, int, int, EpetraNode>>
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 
97 Teuchos::RCP<MultiVector<double, int, int, EpetraNode>>
99 Build(const Teuchos::RCP<const Map<int, int, EpetraNode>>& map,
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 
123 {
124 }
125 
126 
127 RCP<MultiVector<int, int, int, EpetraNode>>
129 Build(const Teuchos::RCP<const Map<int, int, EpetraNode>>& map, size_t NumVectors, bool zeroOut)
130 {
131  XPETRA_MONITOR("MultiVectorFactory::Build");
132 
133  RCP<const BlockedMap<int, int, EpetraNode>> bmap = Teuchos::rcp_dynamic_cast<const BlockedMap<int, int, EpetraNode>>(map);
134 
135  if(!bmap.is_null())
136  {
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  {
143  return rcp(new TpetraMultiVector<int, int, int, EpetraNode>(map, NumVectors, zeroOut));
144  }
145 #endif
146 
147  if(map->lib() == UseEpetra)
148  {
149  return rcp(new EpetraIntMultiVectorT<int, EpetraNode>(map, NumVectors, zeroOut));
150  }
151 
153 }
154 
155 
156 Teuchos::RCP<MultiVector<int, int, int, EpetraNode>>
158 Build(const Teuchos::RCP<const Map<int, int, EpetraNode>>& map,
159  const Teuchos::ArrayView<const Teuchos::ArrayView<const int>>& ArrayOfPtrs,
160  size_t NumVectors)
161 {
162  XPETRA_MONITOR("MultiVectorFactory::Build");
163 
164 #ifdef HAVE_XPETRA_TPETRA
165  if(map->lib() == UseTpetra)
166  {
167  return rcp(new TpetraMultiVector<int, int, int, EpetraNode>(map, ArrayOfPtrs, NumVectors));
168  }
169 #endif
170 
171  if(map->lib() == UseEpetra)
172  {
173  return rcp(new EpetraIntMultiVectorT<int, EpetraNode>(map, ArrayOfPtrs, NumVectors));
174  }
175 
177 }
178 
179 
180 
181 // we need the Epetra specialization only if Epetra is enabled
182 #if !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
183 
184 
185 
187 
188 
189 RCP<MultiVector<double, int, long long, EpetraNode>>
191 Build(const Teuchos::RCP<const Map<int, long long, EpetraNode>>& map,
192  size_t NumVectors,
193  bool zeroOut)
194 {
195  XPETRA_MONITOR("MultiVectorFactory::Build");
196 
197  RCP<const BlockedMap<int, long long, EpetraNode>> bmap = Teuchos::rcp_dynamic_cast<const BlockedMap<int, long long, EpetraNode>>(map);
198 
199  if(!bmap.is_null())
200  {
201  return rcp(new BlockedMultiVector<double, int, long long, EpetraNode>(bmap, NumVectors, zeroOut));
202  }
203 
204 #ifdef HAVE_XPETRA_TPETRA
205  if(map->lib() == UseTpetra)
206  {
207  return rcp(new TpetraMultiVector<double, int, long long, EpetraNode>(map, NumVectors, zeroOut));
208  }
209 #endif
210 
211  if(map->lib() == UseEpetra)
212  {
213  return rcp(new EpetraMultiVectorT<long long, EpetraNode>(map, NumVectors, zeroOut));
214  }
215 
217 }
218 
219 
220 Teuchos::RCP<MultiVector<double, int, long long, EpetraNode>>
222 Build(const Teuchos::RCP<const Map<int, long long, EpetraNode>>& map,
223  const Teuchos::ArrayView<const Teuchos::ArrayView<const Scalar>>& ArrayOfPtrs,
224  size_t NumVectors)
225 {
226  XPETRA_MONITOR("MultiVectorFactory::Build");
227 
228 #ifdef HAVE_XPETRA_TPETRA
229  if(map->lib() == UseTpetra)
230  {
231  return rcp(new TpetraMultiVector<double, int, long long, EpetraNode>(map, ArrayOfPtrs, NumVectors));
232  }
233 #endif
234 
235  if(map->lib() == UseEpetra)
236  {
237  return rcp(new EpetraMultiVectorT<long long, EpetraNode>(map, ArrayOfPtrs, NumVectors));
238  }
239 
241 }
242 
243 
246 {
247 }
248 
249 
250 RCP<MultiVector<int, int, long long, EpetraNode>>
252 Build(const Teuchos::RCP<const Map<int, long long, EpetraNode>>& map,
253  size_t NumVectors,
254  bool zeroOut)
255 {
256  XPETRA_MONITOR("MultiVectorFactory::Build");
257 
258  RCP<const BlockedMap<int, long long, EpetraNode>> bmap = Teuchos::rcp_dynamic_cast<const BlockedMap<int, long long, EpetraNode>>(map);
259 
260  if(!bmap.is_null())
261  {
262  return rcp(new BlockedMultiVector<int, int, long long, EpetraNode>(bmap, NumVectors, zeroOut));
263  }
264 
265 #ifdef HAVE_XPETRA_TPETRA
266  if(map->lib() == UseTpetra)
267  {
268  return rcp(new TpetraMultiVector<int, int, long long, EpetraNode>(map, NumVectors, zeroOut));
269  }
270 #endif
271 
272  if(map->lib() == UseEpetra)
273  {
274  return rcp(new EpetraIntMultiVectorT<long long, EpetraNode>(map, NumVectors, zeroOut));
275  }
276 
278 }
279 
280 
281 Teuchos::RCP<MultiVector<int, int, long long, EpetraNode>>
283 Build(const Teuchos::RCP<const Map<int, long long, Node>>& map,
284  const Teuchos::ArrayView<const Teuchos::ArrayView<const int>>& ArrayOfPtrs,
285  size_t NumVectors)
286 {
287  XPETRA_MONITOR("MultiVectorFactory::Build");
288 
289 #ifdef HAVE_XPETRA_TPETRA
290  if(map->lib() == UseTpetra)
291  {
292  return rcp(new TpetraMultiVector<int, int, long long, EpetraNode>(map, ArrayOfPtrs, NumVectors));
293  }
294 #endif
295 
296  if(map->lib() == UseEpetra)
297  {
298  return rcp(new EpetraIntMultiVectorT<long long, EpetraNode>(map, ArrayOfPtrs, NumVectors));
299  }
300 
302 }
303 
304 
305 #endif // END !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
306 
307 #endif // END !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
308 
309 #endif // END HAVE_XPETRA_EPETRA
310 
311 
312 } // 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)