Xpetra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Xpetra_EpetraVectorFactory.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Xpetra: A linear algebra interface package
4 //
5 // Copyright 2012 NTESS and the Xpetra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #include "Xpetra_VectorFactory.hpp"
11 #include "Xpetra_Vector.hpp"
12 #include "Xpetra_BlockedVector.hpp"
13 
14 namespace Xpetra {
15 
16 #if defined(HAVE_XPETRA_EPETRA)
17 
18 // we need the Epetra specialization only if Epetra is enabled
19 #if !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
20 
21 RCP<Xpetra::Vector<double, int, int, EpetraNode>>
23  Build(const Teuchos::RCP<const Xpetra::Map<int, int, EpetraNode>>& map, bool zeroOut) {
24  XPETRA_MONITOR("VectorFactory::Build");
25 
26  RCP<const Xpetra::BlockedMap<LocalOrdinal, GlobalOrdinal, Node>>
27  bmap = Teuchos::rcp_dynamic_cast<const Xpetra::BlockedMap<LocalOrdinal, GlobalOrdinal, Node>>(map);
28 
29  if (!bmap.is_null()) {
31  }
32 
33 #ifdef HAVE_XPETRA_TPETRA
34  if (map->lib() == UseTpetra) {
35  return rcp(new TpetraVector(map, zeroOut));
36  }
37 #endif // HAVE_XPETRA_TPETRA
38 
39  if (map->lib() == UseEpetra) {
40  return rcp(new EpetraVectorT<GlobalOrdinal, EpetraNode>(map, zeroOut));
41  }
42 
44 }
45 
46 #endif // #if !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
47 
48 #if !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
49 
50 RCP<Xpetra::Vector<double, int, long long, EpetraNode>>
52  Build(const Teuchos::RCP<const Xpetra::Map<int, long long, EpetraNode>>& map, bool zeroOut) {
53  XPETRA_MONITOR("VectorFactory::Build");
54 
55  RCP<const Xpetra::BlockedMap<LocalOrdinal, GlobalOrdinal, Node>> bmap =
56  Teuchos::rcp_dynamic_cast<const Xpetra::BlockedMap<LocalOrdinal, GlobalOrdinal, Node>>(map);
57  if (!bmap.is_null()) {
59  }
60 
61 #ifdef HAVE_XPETRA_TPETRA
62  if (map->lib() == UseTpetra) {
63  return rcp(new TpetraVector(map, zeroOut));
64  }
65 #endif
66 
67  if (map->lib() == UseEpetra) {
68  return rcp(new EpetraVectorT<GlobalOrdinal, Node>(map, zeroOut));
69  }
70 
72 }
73 
74 #endif // #if !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
75 
76 // we need the Epetra specialization only if Epetra is enabled
77 #if !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
78 
79 RCP<Xpetra::Vector<int, int, int, EpetraNode>>
81  Build(const Teuchos::RCP<const Xpetra::Map<int, int, EpetraNode>>& map, bool zeroOut) {
82  XPETRA_MONITOR("VectorFactory::Build");
83 
84  RCP<const Xpetra::BlockedMap<LocalOrdinal, GlobalOrdinal, Node>> bmap =
85  Teuchos::rcp_dynamic_cast<const Xpetra::BlockedMap<LocalOrdinal, GlobalOrdinal, Node>>(map);
86  if (!bmap.is_null()) {
88  }
89 
90 #ifdef HAVE_XPETRA_TPETRA
91  if (map->lib() == UseTpetra) {
92  return rcp(new TpetraVector(map, zeroOut));
93  }
94 #endif // HAVE_XPETRA_TPETRA
95 
96  if (map->lib() == UseEpetra) {
97  return rcp(new EpetraIntVectorT<GlobalOrdinal, Node>(map, zeroOut));
98  }
99 
101 }
102 
103 #endif // #if !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
104 
105 #if !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
106 
107 RCP<Xpetra::Vector<int, int, long long, EpetraNode>>
109  Build(const Teuchos::RCP<const Xpetra::Map<int, long long, EpetraNode>>& map, bool zeroOut) {
110  XPETRA_MONITOR("VectorFactory::Build");
111 
112  RCP<const Xpetra::BlockedMap<LocalOrdinal, GlobalOrdinal, Node>> bmap =
113  Teuchos::rcp_dynamic_cast<const Xpetra::BlockedMap<LocalOrdinal, GlobalOrdinal, Node>>(map);
114 
115  if (!bmap.is_null()) {
117  }
118 
119 #ifdef HAVE_XPETRA_TPETRA
120  if (map->lib() == UseTpetra) {
121  return rcp(new TpetraVector(map, zeroOut));
122  }
123 #endif // HAVE_XPETRA_TPETRA
124 
125  if (map->lib() == UseEpetra) {
126  return rcp(new EpetraIntVectorT<GlobalOrdinal, Node>(map, zeroOut));
127  }
128 
130 }
131 
132 #endif // #if !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
133 
134 #endif // #if defined(HAVE_XPETRA_EPETRA)
135 
136 } // namespace Xpetra
static Teuchos::RCP< Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node >> &map, bool zeroOut=true)
Constructor specifying the number of non-zeros for all rows.
#define XPETRA_FACTORY_END
#define XPETRA_MONITOR(funcName)