Xpetra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Xpetra_EpetraMapFactory.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
46 #include "Xpetra_MapFactory.hpp"
47 
48 #include "Xpetra_BlockedMap.hpp"
49 #include "Xpetra_EpetraMap.hpp"
50 #ifdef HAVE_XPETRA_TPETRA
51 #include "Xpetra_TpetraMap.hpp"
52 #endif
53 
54 namespace Xpetra {
55 
56 #if defined(HAVE_XPETRA_EPETRA)
57 
58 
59 #if !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
60 
61 
64  {
65  }
66 
67 
68 
69 
70  RCP<Map<int, int, EpetraNode>>
73  global_size_t numGlobalElements,
74  int indexBase,
75  const Teuchos::RCP<const Teuchos::Comm<int> > &comm,
76  LocalGlobal lg)
77  {
78  XPETRA_MONITOR("MapFactory::Build");
79 
80 #ifdef HAVE_XPETRA_TPETRA
81  if (lib == UseTpetra)
82  return rcp( new Xpetra::TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (numGlobalElements, indexBase, comm, lg) );
83 #endif
84 
85  if (lib == UseEpetra)
86  return rcp( new EpetraMapT<int, Node>(numGlobalElements, indexBase, comm, lg) );
87 
89  }
90 
91 
92 
93 
94  RCP<Map<int, int, EpetraNode> >
97  global_size_t numGlobalElements,
98  size_t numLocalElements,
99  int indexBase,
100  const Teuchos::RCP<const Teuchos::Comm<int> > &comm)
101  {
102  XPETRA_MONITOR("MapFactory::Build");
103 
104 #ifdef HAVE_XPETRA_TPETRA
105  if (lib == UseTpetra)
106  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (numGlobalElements, numLocalElements, indexBase, comm) );
107 #endif
108 
109  if (lib == UseEpetra)
110  return rcp( new EpetraMapT<int, Node>(numGlobalElements, numLocalElements, indexBase, comm) );
111 
113  }
114 
115 
116 
117 
118  RCP<Map<int, int, EpetraNode> >
121  global_size_t numGlobalElements,
122  const Teuchos::ArrayView<const int> &elementList,
123  int indexBase,
124  const Teuchos::RCP<const Teuchos::Comm<int> > &comm)
125  {
126 
127  XPETRA_MONITOR("MapFactory::Build");
128 #ifdef HAVE_XPETRA_TPETRA
129  if (lib == UseTpetra)
130  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (numGlobalElements, elementList, indexBase, comm) );
131 #endif // HAVE_XPETRA_TPETRA
132 
133  if (lib == UseEpetra)
134  return rcp( new EpetraMapT<int, Node>(numGlobalElements, elementList, indexBase, comm) );
135 
137  }
138 
139 
142  Teuchos::RCP<Map<int, int, EpetraNode> >
144  Build(const Teuchos::RCP<const Map<int, int, EpetraNode> >& map,
145  int numDofPerNode)
146  {
147  XPETRA_MONITOR("MapFactory::Build");
148 
149  RCP<const BlockedMap<LocalOrdinal, GlobalOrdinal, Node> > bmap = Teuchos::rcp_dynamic_cast<const BlockedMap<LocalOrdinal, GlobalOrdinal, Node> >(map);
150  if(!bmap.is_null())
151  {
152  TEUCHOS_TEST_FOR_EXCEPTION(numDofPerNode!=1, Xpetra::Exceptions::RuntimeError,
153  "Xpetra::MapFactory::Build: When provided a BlockedMap numDofPerNode must set to be one. It is set to " << numDofPerNode << ".");
154  return rcp(new BlockedMap<LocalOrdinal, GlobalOrdinal, Node>(*bmap));
155  }
156 
157  LocalOrdinal N = Teuchos::as<LocalOrdinal>(map->getNodeNumElements());
158  Teuchos::ArrayView<const GlobalOrdinal> oldElements = map->getNodeElementList();
159  Teuchos::Array<GlobalOrdinal> newElements(map->getNodeNumElements()*numDofPerNode);
160  for (LocalOrdinal i = 0; i < N; i++)
161  {
162  for (LocalOrdinal j = 0; j < numDofPerNode; j++)
163  {
164  newElements[i*numDofPerNode + j] = oldElements[i]*numDofPerNode + j;
165  }
166  }
167 
168 #ifdef HAVE_XPETRA_TPETRA
169  if (map->lib() == UseTpetra)
170  {
171  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (map->getGlobalNumElements()*numDofPerNode, newElements, map->getIndexBase(), map->getComm()) );
172  }
173 #endif // HAVE_XPETRA_TPETRA
174 
175  if (map->lib() == UseEpetra)
176  {
177  return rcp( new EpetraMapT<int, Node>(map->getGlobalNumElements()*numDofPerNode, newElements, map->getIndexBase(), map->getComm()) );
178  }
179 
181  }
182 
183 
184  Teuchos::RCP<const Map<int, int, EpetraNode> >
187  size_t numElements,
188  const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
189  {
190  XPETRA_MONITOR("MapFactory::Build");
191 
192 #ifdef HAVE_XPETRA_TPETRA
193  if (lib == UseTpetra)
194 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_INT))) || \
195  (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_INT))))
196  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createLocalMapWithNode<LocalOrdinal,GlobalOrdinal, Node>(numElements, comm)));
197 #else
198  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError,
199  "Xpetra::MapFactory::createLocalMap: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=int");
200 #endif
201 #endif // HAVE_XPETRA_TPETRA
202 
203  if (lib == UseEpetra) {
204  Teuchos::RCP< EpetraMapT<int, Node> > map;
205  map = Teuchos::rcp( new EpetraMapT<int, Node>( (Xpetra::global_size_t)numElements, // num elements, global and local
206  0, // index base is zero
207  comm, LocallyReplicated)
208  );
209  return map.getConst();
210  }
211 
213  }
214 
215 
216  // TODO remove this
217 
218 
219 
220  Teuchos::RCP< const Map<int, int, EpetraNode> >
223  size_t numElements,
224  const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
225  {
226  XPETRA_MONITOR("MapFactory::Build");
227 
228 #ifdef HAVE_XPETRA_TPETRA
229  if (lib == UseTpetra)
230 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_INT))) || \
231  (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_INT))))
232  return rcp (new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createLocalMapWithNode<int, GlobalOrdinal, Node> (numElements, comm)));
233 #else
234  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError,
235  "Xpetra::MapFactory::createLocalMapWithNode: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=int");
236 #endif
237 #endif // HAVE_XPETRA_TPETRA
238 
239  if (lib == UseEpetra) {
240  Teuchos::RCP< EpetraMapT<int, Node> > map;
241  map = Teuchos::rcp( new EpetraMapT<int, Node>((Xpetra::global_size_t)numElements, // num elements, global and local
242  0, // index base is zero
243  comm, LocallyReplicated));
244  return map.getConst();
245  }
246 
248  }
249 
250 
251 
252  // TODO remove this
253 
254 
255 
256  Teuchos::RCP< const Map<int, int, EpetraNode> >
259  global_size_t numElements,
260  const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
261  {
262  XPETRA_MONITOR("MapFactory::Build");
263 
264 #ifdef HAVE_XPETRA_TPETRA
265  if (lib == UseTpetra)
266 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_INT))) || \
267  (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_INT))))
268  return rcp (new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createUniformContigMapWithNode<int,GlobalOrdinal,Node> (numElements, comm)));
269 #else
270  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError,
271  "Xpetra::MapFactory::createUniformContigMapWithNode: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=int");
272 #endif
273 #endif // HAVE_XPETRA_TPETRA
274 
275  if (lib == UseEpetra) {
276  Teuchos::RCP< EpetraMapT<int,Node> > map;
277  map = Teuchos::rcp( new EpetraMapT<int,Node>(numElements, // num elements, global and local
278  0, //index base is zero
279  comm, GloballyDistributed));
280  return map.getConst();
281  }
282 
284  }
285 
286 
287  Teuchos::RCP< const Map<int, int, EpetraNode> >
290  global_size_t numElements,
291  const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
292  {
293  XPETRA_MONITOR("MapFactory::Build");
294 
295 #ifdef HAVE_XPETRA_TPETRA
296  if (lib == UseTpetra)
297 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_INT))) || \
298  (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_INT))))
299  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal, Node>(numElements, comm)));
300 #else
301  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError,
302  "Xpetra::MapFactory::createUniformContigMapWithNode: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=int");
303 #endif
304 #endif // HAVE_XPETRA_TPETRA
305 
306  if (lib == UseEpetra)
307  {
308  Teuchos::RCP< EpetraMapT<int,Node> > map;
309  map = Teuchos::rcp( new EpetraMapT<int,Node>(numElements, // num elements, global and local
310  0, //index base is zero
311  comm, GloballyDistributed));
312  return map.getConst();
313  }
315  }
316 
317 
318  Teuchos::RCP< const Map<int, int, EpetraNode> >
321  global_size_t numElements,
322  size_t localNumElements,
323  const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
324  {
325  XPETRA_MONITOR("MapFactory::Build");
326 
327  #ifdef HAVE_XPETRA_TPETRA
328  if (lib == UseTpetra)
329  #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_INT))) || \
330  (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_INT))))
331  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createContigMapWithNode<int,GlobalOrdinal,Node>(numElements, localNumElements, comm)));
332  #else
333  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError,
334  "Xpetra::MapFactory::createContigMap: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=int");
335  #endif
336  #endif
337 
338  if (lib == UseEpetra)
339  {
340  return MapFactory<int, GlobalOrdinal, Node>::createContigMapWithNode(lib, numElements, localNumElements, comm);
341  }
342 
344  }
345 
346 
347 
348 
349  Teuchos::RCP< const Map<int, int, EpetraNode> >
352  global_size_t numElements,
353  size_t localNumElements,
354  const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
355  {
356  XPETRA_MONITOR("MapFactory::Build");
357 
358 #ifdef HAVE_XPETRA_TPETRA
359  if (lib == UseTpetra)
360 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_INT))) || \
361  (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_INT))))
362  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createContigMapWithNode<int,GlobalOrdinal,Node>(numElements, localNumElements, comm)));
363 #else
364  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError,
365  "Xpetra::MapFactory::createContigMapWithNode: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=int");
366 #endif
367 #endif
368 
369  if (lib == UseEpetra)
370  {
371  Teuchos::RCP< EpetraMapT<int, Node> > map;
372  map = Teuchos::rcp( new EpetraMapT<int, Node>(numElements,localNumElements,
373  0, // index base is zero
374  comm) );
375  return map.getConst();
376  }
378  }
379 
380 
381 
382 #endif // #if !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
383 
384 
385 
386 
387 
388 
389 
390 
391 // we need the Epetra specialization only if Epetra is enabled
392 #if !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
393 
394 
395 
399  {
400  }
401 
402 
403 
404 
405  RCP<Map<int, long long, EpetraNode>>
408  global_size_t numGlobalElements,
409  int indexBase,
410  const Teuchos::RCP<const Teuchos::Comm<int> > &comm,
411  LocalGlobal lg)
412  {
413  XPETRA_MONITOR("MapFactory::Build");
414 
415 #ifdef HAVE_XPETRA_TPETRA
416  if (lib == UseTpetra)
417  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (numGlobalElements, indexBase, comm, lg) );
418 #endif
419 
420  if (lib == UseEpetra)
421  return rcp( new EpetraMapT<long long, Node>(numGlobalElements, indexBase, comm, lg) );
422 
424  }
425 
426 
427 
428 
429  RCP<Map<int, long long, EpetraNode> >
432  global_size_t numGlobalElements,
433  size_t numLocalElements,
434  int indexBase,
435  const Teuchos::RCP<const Teuchos::Comm<int> > &comm)
436  {
437  XPETRA_MONITOR("MapFactory::Build");
438 
439 #ifdef HAVE_XPETRA_TPETRA
440  if (lib == UseTpetra)
441  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (numGlobalElements, numLocalElements, indexBase, comm) );
442 #endif
443 
444  if (lib == UseEpetra)
445  return rcp( new EpetraMapT<long long, Node>(numGlobalElements, numLocalElements, indexBase, comm) );
446 
448  }
449 
450 
451 
452 
453  RCP<Map<int, long long, EpetraNode> >
456  global_size_t numGlobalElements,
457  const Teuchos::ArrayView<const long long> &elementList,
458  int indexBase,
459  const Teuchos::RCP<const Teuchos::Comm<int> > &comm)
460  {
461  XPETRA_MONITOR("MapFactory::Build");
462 
463 #ifdef HAVE_XPETRA_TPETRA
464  if (lib == UseTpetra)
465  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (numGlobalElements, elementList, indexBase, comm) );
466 #endif
467 
468  if (lib == UseEpetra)
469  return rcp( new EpetraMapT<long long, Node>(numGlobalElements, elementList, indexBase, comm) );
470 
472  }
473 
476  Teuchos::RCP<Map<int, long long, EpetraNode> >
478  Build(const Teuchos::RCP<const Map<int, long long, EpetraNode> >& map,
479  int numDofPerNode)
480  {
481  XPETRA_MONITOR("MapFactory::Build");
482 
483  RCP<const BlockedMap<LocalOrdinal, GlobalOrdinal, Node> > bmap = Teuchos::rcp_dynamic_cast<const BlockedMap<LocalOrdinal, GlobalOrdinal, Node> >(map);
484  if(!bmap.is_null()) {
485  TEUCHOS_TEST_FOR_EXCEPTION(numDofPerNode!=1, Xpetra::Exceptions::RuntimeError,
486  "Xpetra::MapFactory::Build: When provided a BlockedMap numDofPerNode must set to be one. It is set to " << numDofPerNode << ".");
488  }
489 
490  LocalOrdinal N = map->getNodeNumElements();
491  Teuchos::ArrayView<const GlobalOrdinal> oldElements = map->getNodeElementList();
492  Teuchos::Array<GlobalOrdinal> newElements(map->getNodeNumElements()*numDofPerNode);
493  for (LocalOrdinal i = 0; i < N; i++)
494  for (LocalOrdinal j = 0; j < numDofPerNode; j++)
495  newElements[i*numDofPerNode + j] = oldElements[i]*numDofPerNode + j;
496 
497 #ifdef HAVE_XPETRA_TPETRA
498  if (map->lib() == UseTpetra)
499  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (map->getGlobalNumElements()*numDofPerNode, newElements, map->getIndexBase(), map->getComm()) );
500 #endif
501 
502  if (map->lib() == UseEpetra)
503  return rcp( new EpetraMapT<long long, Node>(map->getGlobalNumElements()*numDofPerNode, newElements, map->getIndexBase(), map->getComm()) );
504 
506  }
507 
508 
509  Teuchos::RCP<const Map<int, long long, EpetraNode> >
512  size_t numElements,
513  const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
514  {
515  XPETRA_MONITOR("MapFactory::Build");
516 
517 #ifdef HAVE_XPETRA_TPETRA
518  if (lib == UseTpetra)
519 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || \
520  (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
521  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createLocalMapWithNode<LocalOrdinal,GlobalOrdinal, Node>(numElements, comm)));
522 #else
523  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError,
524  "Xpetra::MapFactory::createLocalMap: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=long long");
525 #endif
526 #endif
527 
528  if (lib == UseEpetra)
529  return MapFactory<int, GlobalOrdinal, Node>::createLocalMapWithNode (lib, numElements, comm);
530 
532  }
533 
534 
535 
536 
537  Teuchos::RCP< const Map<int, long long, EpetraNode> >
540  size_t numElements,
541  const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
542  {
543  XPETRA_MONITOR("MapFactory::Build");
544 
545 #ifdef HAVE_XPETRA_TPETRA
546  if (lib == UseTpetra)
547 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || \
548  (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
549  return rcp (new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createLocalMapWithNode<int, GlobalOrdinal, Node> (numElements, comm)));
550 #else
551  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError,
552  "Xpetra::MapFactory::createLocalMapWithNode: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=long long");
553 #endif
554 #endif
555 
556  if (lib == UseEpetra)
557  {
558  Teuchos::RCP< EpetraMapT<long long, Node> > map;
559  map = Teuchos::rcp( new EpetraMapT<long long, Node>((Xpetra::global_size_t)numElements, // num elements, global and local
560  0, // index base is zero
561  comm, LocallyReplicated));
562  return map.getConst();
563  }
565  }
566 
567 
568 
569 
570  Teuchos::RCP< const Map<int, long long, EpetraNode> >
573  global_size_t numElements,
574  const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
575  {
576  XPETRA_MONITOR("MapFactory::Build");
577 
578 #ifdef HAVE_XPETRA_TPETRA
579  if (lib == UseTpetra)
580 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || \
581  (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
582  return rcp (new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createUniformContigMapWithNode<int,GlobalOrdinal,Node> (numElements, comm)));
583 #else
584  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError,
585  "Xpetra::MapFactory::createUniformContigMapWithNode: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=long long");
586 #endif
587 #endif
588 
589  if (lib == UseEpetra)
590  {
591  Teuchos::RCP< EpetraMapT<long long, Node> > map;
592  map = Teuchos::rcp( new EpetraMapT<long long, Node>(numElements, // num elements, global and local
593  0, //index base is zero
594  comm, GloballyDistributed));
595  return map.getConst();
596  }
598  }
599 
600 
601  Teuchos::RCP< const Map<int, long long, EpetraNode> >
604  global_size_t numElements,
605  const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
606  {
607  XPETRA_MONITOR("MapFactory::Build");
608 
609 #ifdef HAVE_XPETRA_TPETRA
610  if (lib == UseTpetra)
611 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || \
612  (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
613  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal, Node>(numElements, comm)));
614 #else
615  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError,
616  "Xpetra::MapFactory::createUniformContigMap: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=long long");
617 #endif
618 #endif
619 
620  if (lib == UseEpetra)
622 
624  }
625 
626 
627  Teuchos::RCP<const Map<int, long long, EpetraNode>>
629  global_size_t numElements,
630  size_t localNumElements,
631  const Teuchos::RCP<const Teuchos::Comm<int>>& comm)
632  {
633  XPETRA_MONITOR("MapFactory::Build");
634 
635 #ifdef HAVE_XPETRA_TPETRA
636  if(lib == UseTpetra)
637 #if((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))) \
638  || (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
640  Tpetra::createContigMapWithNode<int, GlobalOrdinal, Node>(numElements, localNumElements, comm)));
641 #else
642  TEUCHOS_TEST_FOR_EXCEPTION(true,
644  "Xpetra::MapFactory::createContigMap: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on "
645  "EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=long long");
646 #endif
647 #endif
648 
649  if(lib == UseEpetra)
650  return MapFactory<int, GlobalOrdinal, Node>::createContigMapWithNode(lib, numElements, localNumElements, comm);
651 
653  }
654 
655 
656 
657 
658  Teuchos::RCP<const Map<int, long long, EpetraNode>>
661  global_size_t numElements,
662  size_t localNumElements,
663  const Teuchos::RCP<const Teuchos::Comm<int>>& comm)
664  {
665  XPETRA_MONITOR("MapFactory::Build");
666 
667 #ifdef HAVE_XPETRA_TPETRA
668  if(lib == UseTpetra)
669 #if((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))) \
670  || (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
672  Tpetra::createContigMapWithNode<int, GlobalOrdinal, Node>(numElements, localNumElements, comm)));
673 #else
674  TEUCHOS_TEST_FOR_EXCEPTION(true,
676  "Xpetra::MapFactory::createContigMapWithNode: Cannot create Xpetra::TpetraMap, since Tpetra is not "
677  "instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=long long");
678 #endif
679 #endif // HAVE_XPETRA_TPETRA
680 
681  if(lib == UseEpetra)
682  {
683  Teuchos::RCP<EpetraMapT<long long, Node>> map;
684  map = Teuchos::rcp(new EpetraMapT<long long, Node>(numElements,
685  localNumElements,
686  0, // index base is zero
687  comm));
688  return map.getConst();
689  }
690 
692  }
693 
694 
695 
696 #endif // #if !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
697 
698 
699 #endif // #if defined(HAVE_XPETRA_EPETRA)
700 
701 
702 
703 } // namespace Xpetra
704 
705 // EOF
static Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createLocalMap(UnderlyingLib lib, size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int >> &comm)
Create a locally replicated Map with the default node.
static Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createContigMap(UnderlyingLib lib, global_size_t numElements, size_t localNumElements, const Teuchos::RCP< const Teuchos::Comm< int >> &comm)
Create a (potentially) non-uniform, contiguous Map with the default node.
Exception throws to report errors in the internal logical of the program.
MapFactory()
Private constructor. This is a static class.
static Teuchos::RCP< Map< LocalOrdinal, GlobalOrdinal, Node > > Build(UnderlyingLib lib, global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int >> &comm, LocalGlobal lg=Xpetra::GloballyDistributed)
Map constructor with Xpetra-defined contiguous uniform distribution.
static Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createContigMapWithNode(UnderlyingLib lib, global_size_t numElements, size_t localNumElements, const Teuchos::RCP< const Teuchos::Comm< int >> &comm)
Create a (potentially) non-uniform, contiguous Map with a user-specified node.
#define XPETRA_FACTORY_END
size_t global_size_t
Global size_t object.
static Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createUniformContigMapWithNode(UnderlyingLib lib, global_size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int >> &comm)
Create a uniform, contiguous Map with a user-specified node.
static Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createLocalMapWithNode(UnderlyingLib lib, size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int >> &comm)
Create a locally replicated Map with a specified node.
#define XPETRA_MONITOR(funcName)
static Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createUniformContigMap(UnderlyingLib lib, global_size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int >> &comm)
Create a uniform, contiguous Map with the default node.