Xpetra Version of the Day
Loading...
Searching...
No Matches
Xpetra_VectorFactory_decl.hpp
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#ifndef XPETRA_VECTORFACTORY_DECL_HPP
47#define XPETRA_VECTORFACTORY_DECL_HPP
48
49#include "Xpetra_ConfigDefs.hpp"
50#include "Xpetra_Vector.hpp"
51
52#ifdef HAVE_XPETRA_TPETRA
54#endif
55#ifdef HAVE_XPETRA_EPETRA
58#endif
59
62#include "Xpetra_Exceptions.hpp"
63
64
65
66namespace Xpetra {
67
68
69
70 template <class Scalar /* = Vector<>::scalar_type*/,
71 class LocalOrdinal /* = typename Vector<Scalar>::local_ordinal_type*/,
72 class GlobalOrdinal /* = typename Vector<Scalar, LocalOrdinal>::local_ordinal_type*/,
73 class Node /* = typename Vector<Scalar, LocalOrdinal, GlobalOrdinal>::node_type*/>
75 {
76 #undef XPETRA_VECTORFACTORY_SHORT
78
79 private:
80
82 VectorFactory() = default;
83
84 public:
85
89 {
90 XPETRA_MONITOR("VectorFactory::Build");
91
93 bmap = Teuchos::rcp_dynamic_cast<const Xpetra::BlockedMap<LocalOrdinal, GlobalOrdinal, Node>>(map);
94
95 if(!bmap.is_null())
96 {
98 }
99
100 #ifdef HAVE_XPETRA_TPETRA
101 if(map->lib() == UseTpetra)
102 {
103 return rcp(new TpetraVector(map, zeroOut));
104 }
105 #endif
106
109 }
110
111 }; // class VectorFactory
112
113#define XPETRA_VECTORFACTORY_SHORT
114
115
116
117#if defined(HAVE_XPETRA_EPETRA)
118
119
120// we need the Epetra specialization only if Epetra is enabled
121#if !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
122
123 // Specialization for Scalar=double, LO=GO=int and EpetraNode node
124 // Used both for Epetra and Tpetra
125 // For any other node definition the general default implementation is used which allows Tpetra only
126 template <>
127 class VectorFactory<double, int, int, EpetraNode>
128 {
129 typedef double Scalar;
130 typedef int LocalOrdinal;
131 typedef int GlobalOrdinal;
133
134#undef XPETRA_VECTORFACTORY_SHORT
136
137 private:
138
140 VectorFactory() = default;
141
142 public:
143
146 bool zeroOut=true);
147
148 };
149#endif // #if !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
150
151
152
153 // Specialization for Scalar=double, LO=int, GO=long long and EpetraNode
154 // Used both for Epetra and Tpetra
155 // For any other node definition the general default implementation is used which allows Tpetra only
156#if !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
157
158 template <>
159 class VectorFactory<double, int, long long, EpetraNode>
160 {
161
162 typedef double Scalar;
163 typedef int LocalOrdinal;
164 typedef long long GlobalOrdinal;
166
167#undef XPETRA_VECTORFACTORY_SHORT
169
170 private:
171
173 VectorFactory() = default;
174
175 public:
176
179 bool zeroOut=true);
180
181 };
182#endif // #if !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
183#define XPETRA_VECTORFACTORY_SHORT
184
185
186
187// we need the Epetra specialization only if Epetra is enabled
188#if !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
189
190 // Specialization for Scalar=int, LO=GO=int and EpetraNode
191 // Used both for Epetra and Tpetra
192 // For any other node definition the general default implementation is used which allows Tpetra only
193 template <>
194 class VectorFactory<int, int, int, EpetraNode>
195 {
196
197 typedef int Scalar;
198 typedef int LocalOrdinal;
199 typedef int GlobalOrdinal;
201
202#undef XPETRA_VECTORFACTORY_SHORT
204
205 private:
206
208 VectorFactory() = default;
209
210 public:
211
214 bool zeroOut=true);
215
216 };
217#endif // #if !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
218
219
220
221// we need the Epetra specialization only if Epetra is enabled
222#if !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
223
224 // Specialization for Scalar=int, LO=int, GO=long long and Serial node
225 // Used both for Epetra and Tpetra
226 // For any other node definition the general default implementation is used which allows Tpetra only
227
228 template <>
229 class VectorFactory<int, int, long long, EpetraNode>
230 {
231 typedef int Scalar;
232 typedef int LocalOrdinal;
233 typedef long long GlobalOrdinal;
235
236#undef XPETRA_VECTORFACTORY_SHORT
238
239 private:
240
242 VectorFactory() = default;
243
244 public:
245
248 bool zeroOut=true);
249
250 };
251#endif // !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
252
253
254#endif // #if defined(HAVE_XPETRA_EPETRA)
255
256
257} // namespace Xpetra
258
259
260#define XPETRA_VECTORFACTORY_SHORT
261#endif // XPETRA_VECTORFACTORY_DECL_HPP
262
263
#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.
Xpetra namespace