Xpetra Version of the Day
Loading...
Searching...
No Matches
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
54namespace Xpetra {
55
56#if defined(HAVE_XPETRA_EPETRA)
57
58
59#if !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
60
61
66
67
68
69
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
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
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
145 const int numDofPerNode, const int gidOffset)
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 {
153 "Xpetra::MapFactory::Build: When provided a BlockedMap numDofPerNode must set to be one. It is set to " << numDofPerNode << ".");
155 }
156
157 LocalOrdinal N = Teuchos::as<LocalOrdinal>(map->getLocalNumElements());
158 Teuchos::ArrayView<const GlobalOrdinal> oldElements = map->getLocalElementList();
159 Teuchos::Array<GlobalOrdinal> newElements(map->getLocalNumElements()*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 + gidOffset;
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
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
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) {
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
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
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) {
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
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
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) {
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
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
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 {
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
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
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
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
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 {
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
383 const Teuchos::RCP<const Teuchos::Comm<int>>& newComm) {
384 XPETRA_MONITOR("MapFactory::Build");
387
388 size_t Nlocal = oldmap->getLocalNumElements();
389 global_size_t Nglobal = oldmap->getGlobalNumElements();
390
391 // Sanity check -- if there's no comm, we can't keep elements on the map (vice versa is OK)
392 TEUCHOS_TEST_FOR_EXCEPTION( Nlocal && newComm.is_null(),
393 std::logic_error, "MapFactory::copyMapWithNewComm needs the comm to match the map.");
394
395 // We'll return null if we don't have a Comm on this rank
397 if(!newComm.is_null()) {
398 if(oldmap->isContiguous()) {
399 newMap = XMF::Build(oldmap->lib(),INVALID,Nlocal,oldmap->getIndexBase(),newComm);
400 }
401 else {
402 newMap = XMF::Build(oldmap->lib(),Nglobal,oldmap->getLocalElementList(),oldmap->getIndexBase(),newComm);
403 }
404 }
405
406 return newMap;
408}
409
410
411
412#endif // #if !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
413
414
415
416
417
418
419
420
421// we need the Epetra specialization only if Epetra is enabled
422#if !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
423
424
425
429 {
430 }
431
432
433
434
435 RCP<Map<int, long long, EpetraNode>>
438 global_size_t numGlobalElements,
439 int indexBase,
440 const Teuchos::RCP<const Teuchos::Comm<int> > &comm,
441 LocalGlobal lg)
442 {
443 XPETRA_MONITOR("MapFactory::Build");
444
445#ifdef HAVE_XPETRA_TPETRA
446 if (lib == UseTpetra)
447 return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (numGlobalElements, indexBase, comm, lg) );
448#endif
449
450 if (lib == UseEpetra)
451 return rcp( new EpetraMapT<long long, Node>(numGlobalElements, indexBase, comm, lg) );
452
454 }
455
456
457
458
459 RCP<Map<int, long long, EpetraNode> >
462 global_size_t numGlobalElements,
463 size_t numLocalElements,
464 int indexBase,
465 const Teuchos::RCP<const Teuchos::Comm<int> > &comm)
466 {
467 XPETRA_MONITOR("MapFactory::Build");
468
469#ifdef HAVE_XPETRA_TPETRA
470 if (lib == UseTpetra)
471 return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (numGlobalElements, numLocalElements, indexBase, comm) );
472#endif
473
474 if (lib == UseEpetra)
475 return rcp( new EpetraMapT<long long, Node>(numGlobalElements, numLocalElements, indexBase, comm) );
476
478 }
479
480
481
482
483 RCP<Map<int, long long, EpetraNode> >
486 global_size_t numGlobalElements,
487 const Teuchos::ArrayView<const long long> &elementList,
488 int indexBase,
489 const Teuchos::RCP<const Teuchos::Comm<int> > &comm)
490 {
491 XPETRA_MONITOR("MapFactory::Build");
492
493#ifdef HAVE_XPETRA_TPETRA
494 if (lib == UseTpetra)
495 return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (numGlobalElements, elementList, indexBase, comm) );
496#endif
497
498 if (lib == UseEpetra)
499 return rcp( new EpetraMapT<long long, Node>(numGlobalElements, elementList, indexBase, comm) );
500
502 }
503
508 Build(const Teuchos::RCP<const Map<int, long long, EpetraNode> >& map,
509 int numDofPerNode)
510 {
511 XPETRA_MONITOR("MapFactory::Build");
512
513 RCP<const BlockedMap<LocalOrdinal, GlobalOrdinal, Node> > bmap = Teuchos::rcp_dynamic_cast<const BlockedMap<LocalOrdinal, GlobalOrdinal, Node> >(map);
514 if(!bmap.is_null()) {
516 "Xpetra::MapFactory::Build: When provided a BlockedMap numDofPerNode must set to be one. It is set to " << numDofPerNode << ".");
518 }
519
520 LocalOrdinal N = map->getLocalNumElements();
521 Teuchos::ArrayView<const GlobalOrdinal> oldElements = map->getLocalElementList();
522 Teuchos::Array<GlobalOrdinal> newElements(map->getLocalNumElements()*numDofPerNode);
523 for (LocalOrdinal i = 0; i < N; i++)
524 for (LocalOrdinal j = 0; j < numDofPerNode; j++)
525 newElements[i*numDofPerNode + j] = oldElements[i]*numDofPerNode + j;
526
527#ifdef HAVE_XPETRA_TPETRA
528 if (map->lib() == UseTpetra)
529 return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (map->getGlobalNumElements()*numDofPerNode, newElements, map->getIndexBase(), map->getComm()) );
530#endif
531
532 if (map->lib() == UseEpetra)
533 return rcp( new EpetraMapT<long long, Node>(map->getGlobalNumElements()*numDofPerNode, newElements, map->getIndexBase(), map->getComm()) );
534
536 }
537
538
542 size_t numElements,
543 const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
544 {
545 XPETRA_MONITOR("MapFactory::Build");
546
547#ifdef HAVE_XPETRA_TPETRA
548 if (lib == UseTpetra)
549#if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || \
550 (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
551 return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createLocalMapWithNode<LocalOrdinal,GlobalOrdinal, Node>(numElements, comm)));
552#else
554 "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");
555#endif
556#endif
557
558 if (lib == UseEpetra)
560
562 }
563
564
565
566
570 size_t numElements,
571 const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
572 {
573 XPETRA_MONITOR("MapFactory::Build");
574
575#ifdef HAVE_XPETRA_TPETRA
576 if (lib == UseTpetra)
577#if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || \
578 (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
579 return rcp (new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createLocalMapWithNode<int, GlobalOrdinal, Node> (numElements, comm)));
580#else
582 "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");
583#endif
584#endif
585
586 if (lib == UseEpetra)
587 {
589 map = Teuchos::rcp( new EpetraMapT<long long, Node>((Xpetra::global_size_t)numElements, // num elements, global and local
590 0, // index base is zero
591 comm, LocallyReplicated));
592 return map.getConst();
593 }
595 }
596
597
598
599
603 global_size_t numElements,
604 const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
605 {
606 XPETRA_MONITOR("MapFactory::Build");
607
608#ifdef HAVE_XPETRA_TPETRA
609 if (lib == UseTpetra)
610#if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || \
611 (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
612 return rcp (new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createUniformContigMapWithNode<int,GlobalOrdinal,Node> (numElements, comm)));
613#else
615 "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");
616#endif
617#endif
618
619 if (lib == UseEpetra)
620 {
622 map = Teuchos::rcp( new EpetraMapT<long long, Node>(numElements, // num elements, global and local
623 0, //index base is zero
624 comm, GloballyDistributed));
625 return map.getConst();
626 }
628 }
629
630
634 global_size_t numElements,
635 const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
636 {
637 XPETRA_MONITOR("MapFactory::Build");
638
639#ifdef HAVE_XPETRA_TPETRA
640 if (lib == UseTpetra)
641#if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || \
642 (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
643 return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal, Node>(numElements, comm)));
644#else
646 "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");
647#endif
648#endif
649
650 if (lib == UseEpetra)
652
654 }
655
656
659 global_size_t numElements,
660 size_t localNumElements,
661 const Teuchos::RCP<const Teuchos::Comm<int>>& comm)
662 {
663 XPETRA_MONITOR("MapFactory::Build");
664
665#ifdef HAVE_XPETRA_TPETRA
666 if(lib == UseTpetra)
667#if((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))) \
668 || (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
670 Tpetra::createContigMapWithNode<int, GlobalOrdinal, Node>(numElements, localNumElements, comm)));
671#else
674 "Xpetra::MapFactory::createContigMap: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on "
675 "EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=long long");
676#endif
677#endif
678
679 if(lib == UseEpetra)
680 return MapFactory<int, GlobalOrdinal, Node>::createContigMapWithNode(lib, numElements, localNumElements, comm);
681
683 }
684
685
686
687
691 global_size_t numElements,
692 size_t localNumElements,
693 const Teuchos::RCP<const Teuchos::Comm<int>>& comm)
694 {
695 XPETRA_MONITOR("MapFactory::Build");
696
697#ifdef HAVE_XPETRA_TPETRA
698 if(lib == UseTpetra)
699#if((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))) \
700 || (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
702 Tpetra::createContigMapWithNode<int, GlobalOrdinal, Node>(numElements, localNumElements, comm)));
703#else
706 "Xpetra::MapFactory::createContigMapWithNode: Cannot create Xpetra::TpetraMap, since Tpetra is not "
707 "instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=long long");
708#endif
709#endif // HAVE_XPETRA_TPETRA
710
711 if(lib == UseEpetra)
712 {
714 map = Teuchos::rcp(new EpetraMapT<long long, Node>(numElements,
715 localNumElements,
716 0, // index base is zero
717 comm));
718 return map.getConst();
719 }
720
722 }
723
724
727 const Teuchos::RCP<const Teuchos::Comm<int>>& newComm) {
728 XPETRA_MONITOR("MapFactory::Build");
731
732 size_t Nlocal = oldmap->getLocalNumElements();
733 global_size_t Nglobal = oldmap->getGlobalNumElements();
734
735 // Sanity check -- if there's no comm, we can't keep elements on the map (vice versa is OK)
736 TEUCHOS_TEST_FOR_EXCEPTION( Nlocal && newComm.is_null(),
737 std::logic_error, "MapFactory::copyMapWithNewComm needs the comm to match the map.");
738
739 // We'll return null if we don't have a Comm on this rank
741 if(!newComm.is_null()) {
742 if(oldmap->isContiguous()) {
743 newMap = XMF::Build(oldmap->lib(),INVALID,Nlocal,oldmap->getIndexBase(),newComm);
744 }
745 else {
746 newMap = XMF::Build(oldmap->lib(),Nglobal,oldmap->getLocalElementList(),oldmap->getIndexBase(),newComm);
747 }
748 }
749
750 return newMap;
752}
753
754
755
756
757#endif // #if !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
758
759
760#endif // #if defined(HAVE_XPETRA_EPETRA)
761
762
763
764} // namespace Xpetra
765
766// EOF
#define XPETRA_MONITOR(funcName)
#define XPETRA_FACTORY_END
RCP< const T > getConst() const
bool is_null() const
Exception throws to report errors in the internal logical of the program.
Create an Xpetra::Map instance.
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.
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 > > 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.
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.
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 > > copyMapWithNewComm(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &oldmap, const Teuchos::RCP< const Teuchos::Comm< int > > &newComm)
Create a copy of the map, only using the new Comm object if the Comm would be valid.
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.
MapFactory()
Private constructor. This is a static class.
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.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Xpetra namespace
size_t global_size_t
Global size_t object.