Xpetra Version of the Day
Loading...
Searching...
No Matches
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
22#endif
23
26#include "Xpetra_Exceptions.hpp"
27
28namespace Xpetra {
29
30template <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*/>
35#undef XPETRA_VECTORFACTORY_SHORT
37
38 private:
40 VectorFactory() = default;
41
42 public:
45 Build(const Teuchos::RCP<const Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>>& map, bool zeroOut = true) {
46 XPETRA_MONITOR("VectorFactory::Build");
47
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
78template <>
79class VectorFactory<double, int, int, EpetraNode> {
80 typedef double Scalar;
81 typedef int LocalOrdinal;
82 typedef int GlobalOrdinal;
84
85#undef XPETRA_VECTORFACTORY_SHORT
87
88 private:
90 VectorFactory() = default;
91
92 public:
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
104template <>
105class VectorFactory<double, int, long long, EpetraNode> {
106 typedef double Scalar;
107 typedef int LocalOrdinal;
108 typedef long long GlobalOrdinal;
110
111#undef XPETRA_VECTORFACTORY_SHORT
113
114 private:
116 VectorFactory() = default;
117
118 public:
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
132template <>
133class VectorFactory<int, int, int, EpetraNode> {
134 typedef int Scalar;
135 typedef int LocalOrdinal;
136 typedef int GlobalOrdinal;
138
139#undef XPETRA_VECTORFACTORY_SHORT
141
142 private:
144 VectorFactory() = default;
145
146 public:
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
160template <>
161class VectorFactory<int, int, long long, EpetraNode> {
162 typedef int Scalar;
163 typedef int LocalOrdinal;
164 typedef long long GlobalOrdinal;
166
167#undef XPETRA_VECTORFACTORY_SHORT
169
170 private:
172 VectorFactory() = default;
173
174 public:
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
#define XPETRA_MONITOR(funcName)
#define XPETRA_FACTORY_ERROR_IF_EPETRA(lib)
#define XPETRA_FACTORY_END
bool is_null() const
VectorFactory()=default
Private constructor. This is a static class.
static RCP< Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > &map, bool zeroOut=true)
VectorFactory()=default
Private constructor. This is a static class.
VectorFactory()=default
Private constructor. This is a static class.
static RCP< Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > &map, bool zeroOut=true)
VectorFactory()=default
Private constructor. This is a static class.
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 TEUCHOS_UNREACHABLE_RETURN(dummyReturnVal)
Tpetra::KokkosCompat::KokkosSerialWrapperNode EpetraNode