15 #include "Teuchos_CommHelpers.hpp"
16 #include "Teuchos_DefaultComm.hpp"
17 #include "Teuchos_RCP.hpp"
18 #include "Teuchos_Array.hpp"
19 #include "Tpetra_Core.hpp"
20 #include "Tpetra_Map.hpp"
28 int main(
int narg,
char **arg)
30 Tpetra::ScopeGuard tscope(&narg, &arg);
31 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
32 int me = comm->getRank();
34 typedef Tpetra::Map<>
map_t;
35 typedef map_t::local_ordinal_type
lno_t;
36 typedef map_t::global_ordinal_type
gno_t;
41 lno_t numLocalCoords = 15;
42 lno_t offset = me * 10;
44 Teuchos::Array<gno_t> gids(numLocalCoords);
45 for (lno_t i = 0 ; i < numLocalCoords; i++)
46 gids[i] = static_cast<gno_t> (offset + i);
49 Teuchos::OrdinalTraits<Tpetra::global_size_t>::invalid();
50 Teuchos::RCP<const map_t> mapWithCopies =
51 rcp(
new map_t(numGlobalCoords, gids(), 0, comm));
54 Teuchos::RCP<const map_t> oneToOneMap =
55 Tpetra::createOneToOne<lno_t, gno_t>(mapWithCopies);
59 std::cout << me <<
" MAP WITH COPIES ("
60 << mapWithCopies->getGlobalNumElements() <<
"): ";
61 lno_t nlocal =
lno_t(mapWithCopies->getLocalNumElements());
62 for (lno_t i = 0; i < nlocal; i++)
63 std::cout << mapWithCopies->getGlobalElement(i) <<
" ";
64 std::cout << std::endl;
66 std::cout << me <<
" ONE TO ONE MAP ("
67 << oneToOneMap->getGlobalNumElements() <<
"): ";
68 nlocal =
lno_t(oneToOneMap->getLocalNumElements());
69 for (lno_t i = 0; i < nlocal; i++)
70 std::cout << oneToOneMap->getGlobalElement(i) <<
" ";
71 std::cout << std::endl;
map_t::global_ordinal_type gno_t
int main(int narg, char **arg)
map_t::local_ordinal_type lno_t
Tpetra::global_size_t global_size_t