Xpetra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Xpetra_VectorFactory_decl.hpp
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 #ifndef XPETRA_VECTORFACTORY_DECL_HPP
11 #define XPETRA_VECTORFACTORY_DECL_HPP
12 
13 #include "Xpetra_ConfigDefs.hpp"
14 #include "Xpetra_Vector.hpp"
15 
16 #ifdef HAVE_XPETRA_TPETRA
18 #endif
19 #ifdef HAVE_XPETRA_EPETRA
20 #include "Xpetra_EpetraVector.hpp"
22 #endif
23 
26 #include "Xpetra_Exceptions.hpp"
27 
28 namespace Xpetra {
29 
30 template <class Scalar /* = Vector<>::scalar_type*/,
31  class LocalOrdinal /* = typename Vector<Scalar>::local_ordinal_type*/,
32  class GlobalOrdinal /* = typename Vector<Scalar, LocalOrdinal>::local_ordinal_type*/,
33  class Node /* = typename Vector<Scalar, LocalOrdinal, GlobalOrdinal>::node_type*/>
34 class VectorFactory {
35 #undef XPETRA_VECTORFACTORY_SHORT
36 #include "Xpetra_UseShortNames.hpp"
37 
38  private:
40  VectorFactory() = default;
41 
42  public:
44  static Teuchos::RCP<Xpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
45  Build(const Teuchos::RCP<const Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>>& map, bool zeroOut = true) {
46  XPETRA_MONITOR("VectorFactory::Build");
47 
48  RCP<const Xpetra::BlockedMap<LocalOrdinal, GlobalOrdinal, Node>>
49  bmap = Teuchos::rcp_dynamic_cast<const Xpetra::BlockedMap<LocalOrdinal, GlobalOrdinal, Node>>(map);
50 
51  if (!bmap.is_null()) {
53  }
54 
55 #ifdef HAVE_XPETRA_TPETRA
56  if (map->lib() == UseTpetra) {
57  return rcp(new TpetraVector(map, zeroOut));
58  }
59 #endif
60 
63  TEUCHOS_UNREACHABLE_RETURN(Teuchos::null);
64  }
65 
66 }; // class VectorFactory
67 
68 #define XPETRA_VECTORFACTORY_SHORT
69 
70 #if defined(HAVE_XPETRA_EPETRA)
71 
72 // we need the Epetra specialization only if Epetra is enabled
73 #if !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
74 
75 // Specialization for Scalar=double, LO=GO=int and EpetraNode node
76 // Used both for Epetra and Tpetra
77 // For any other node definition the general default implementation is used which allows Tpetra only
78 template <>
79 class VectorFactory<double, int, int, EpetraNode> {
80  typedef double Scalar;
81  typedef int LocalOrdinal;
82  typedef int GlobalOrdinal;
83  typedef EpetraNode Node;
84 
85 #undef XPETRA_VECTORFACTORY_SHORT
86 #include "Xpetra_UseShortNames.hpp"
87 
88  private:
90  VectorFactory() = default;
91 
92  public:
93  static RCP<Xpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
94  Build(const Teuchos::RCP<const Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>>& map,
95  bool zeroOut = true);
96 };
97 #endif // #if !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
98 
99 // Specialization for Scalar=double, LO=int, GO=long long and EpetraNode
100 // Used both for Epetra and Tpetra
101 // For any other node definition the general default implementation is used which allows Tpetra only
102 #if !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
103 
104 template <>
105 class VectorFactory<double, int, long long, EpetraNode> {
106  typedef double Scalar;
107  typedef int LocalOrdinal;
108  typedef long long GlobalOrdinal;
109  typedef EpetraNode Node;
110 
111 #undef XPETRA_VECTORFACTORY_SHORT
112 #include "Xpetra_UseShortNames.hpp"
113 
114  private:
116  VectorFactory() = default;
117 
118  public:
119  static RCP<Xpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
120  Build(const Teuchos::RCP<const Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>>& map,
121  bool zeroOut = true);
122 };
123 #endif // #if !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
124 #define XPETRA_VECTORFACTORY_SHORT
125 
126 // we need the Epetra specialization only if Epetra is enabled
127 #if !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
128 
129 // Specialization for Scalar=int, LO=GO=int and EpetraNode
130 // Used both for Epetra and Tpetra
131 // For any other node definition the general default implementation is used which allows Tpetra only
132 template <>
133 class VectorFactory<int, int, int, EpetraNode> {
134  typedef int Scalar;
135  typedef int LocalOrdinal;
136  typedef int GlobalOrdinal;
137  typedef EpetraNode Node;
138 
139 #undef XPETRA_VECTORFACTORY_SHORT
140 #include "Xpetra_UseShortNames.hpp"
141 
142  private:
144  VectorFactory() = default;
145 
146  public:
147  static RCP<Xpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
148  Build(const Teuchos::RCP<const Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>>& map,
149  bool zeroOut = true);
150 };
151 #endif // #if !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
152 
153 // we need the Epetra specialization only if Epetra is enabled
154 #if !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
155 
156 // Specialization for Scalar=int, LO=int, GO=long long and Serial node
157 // Used both for Epetra and Tpetra
158 // For any other node definition the general default implementation is used which allows Tpetra only
159 
160 template <>
161 class VectorFactory<int, int, long long, EpetraNode> {
162  typedef int Scalar;
163  typedef int LocalOrdinal;
164  typedef long long GlobalOrdinal;
165  typedef EpetraNode Node;
166 
167 #undef XPETRA_VECTORFACTORY_SHORT
168 #include "Xpetra_UseShortNames.hpp"
169 
170  private:
172  VectorFactory() = default;
173 
174  public:
175  static RCP<Xpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
176  Build(const Teuchos::RCP<const Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>>& map,
177  bool zeroOut = true);
178 };
179 #endif // !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
180 
181 #endif // #if defined(HAVE_XPETRA_EPETRA)
182 
183 } // namespace Xpetra
184 
185 #define XPETRA_VECTORFACTORY_SHORT
186 #endif // XPETRA_VECTORFACTORY_DECL_HPP
VectorFactory()=default
Private constructor. This is a static class.
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_ERROR_IF_EPETRA(lib)
#define XPETRA_FACTORY_END
Tpetra::KokkosCompat::KokkosSerialWrapperNode EpetraNode
#define XPETRA_MONITOR(funcName)