Xpetra
Version of the Day
Toggle main menu visibility
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
53
# include "
Xpetra_TpetraVector_decl.hpp
"
54
#endif
55
#ifdef HAVE_XPETRA_EPETRA
56
# include "
Xpetra_EpetraVector.hpp
"
57
# include "
Xpetra_EpetraIntVector.hpp
"
58
#endif
59
60
#include "
Xpetra_BlockedMap_decl.hpp
"
61
#include "
Xpetra_BlockedVector_decl.hpp
"
62
#include "
Xpetra_Exceptions.hpp
"
63
64
65
66
namespace
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*/
>
74
class
VectorFactory
75
{
76
#undef XPETRA_VECTORFACTORY_SHORT
77
#include "
Xpetra_UseShortNames.hpp
"
78
79
private
:
80
82
VectorFactory
() =
default
;
83
84
public
:
85
87
static
Teuchos::RCP<Xpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node>
>
88
Build
(
const
Teuchos::RCP
<
const
Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node>
> &map,
bool
zeroOut=
true
)
89
{
90
XPETRA_MONITOR
(
"VectorFactory::Build"
);
91
92
RCP<const Xpetra::BlockedMap<LocalOrdinal,GlobalOrdinal,Node>
>
93
bmap = Teuchos::rcp_dynamic_cast<const Xpetra::BlockedMap<LocalOrdinal, GlobalOrdinal, Node>>(map);
94
95
if
(!bmap.
is_null
())
96
{
97
return
rcp
(
new
Xpetra::BlockedVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(bmap, zeroOut));
98
}
99
100
#ifdef HAVE_XPETRA_TPETRA
101
if
(map->lib() ==
UseTpetra
)
102
{
103
return
rcp
(
new
TpetraVector
(map, zeroOut));
104
}
105
#endif
106
107
XPETRA_FACTORY_ERROR_IF_EPETRA
(map->lib());
108
XPETRA_FACTORY_END
;
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
;
132
typedef
EpetraNode
Node
;
133
134
#undef XPETRA_VECTORFACTORY_SHORT
135
#include "
Xpetra_UseShortNames.hpp
"
136
137
private
:
138
140
VectorFactory
() =
default
;
141
142
public
:
143
144
static
RCP<Xpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node>
>
145
Build
(
const
Teuchos::RCP
<
const
Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node>
>& map,
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
;
165
typedef
EpetraNode
Node
;
166
167
#undef XPETRA_VECTORFACTORY_SHORT
168
#include "
Xpetra_UseShortNames.hpp
"
169
170
private
:
171
173
VectorFactory
() =
default
;
174
175
public
:
176
177
static
RCP<Xpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node>
>
178
Build
(
const
Teuchos::RCP
<
const
Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node>
>& map,
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
;
200
typedef
EpetraNode
Node
;
201
202
#undef XPETRA_VECTORFACTORY_SHORT
203
#include "
Xpetra_UseShortNames.hpp
"
204
205
private
:
206
208
VectorFactory
() =
default
;
209
210
public
:
211
212
static
RCP<Xpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node>
>
213
Build(
const
Teuchos::RCP
<
const
Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node>
>& map,
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
;
234
typedef
EpetraNode
Node
;
235
236
#undef XPETRA_VECTORFACTORY_SHORT
237
#include "
Xpetra_UseShortNames.hpp
"
238
239
private
:
240
242
VectorFactory
() =
default
;
243
244
public
:
245
246
static
RCP<Xpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node>
>
247
Build
(
const
Teuchos::RCP
<
const
Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node>
>& map,
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
XPETRA_MONITOR
#define XPETRA_MONITOR(funcName)
Xpetra_BlockedMap_decl.hpp
Xpetra_BlockedVector_decl.hpp
Xpetra_ConfigDefs.hpp
Xpetra_EpetraIntVector.hpp
Xpetra_EpetraVector.hpp
Xpetra_Exceptions.hpp
XPETRA_FACTORY_ERROR_IF_EPETRA
#define XPETRA_FACTORY_ERROR_IF_EPETRA(lib)
Definition
Xpetra_Exceptions.hpp:70
XPETRA_FACTORY_END
#define XPETRA_FACTORY_END
Definition
Xpetra_Exceptions.hpp:77
Xpetra_TpetraVector_decl.hpp
Xpetra_UseShortNames.hpp
Xpetra_Vector.hpp
Teuchos::RCP
Teuchos::RCP::is_null
bool is_null() const
Xpetra::Map
Definition
Xpetra_Map_decl.hpp:89
Xpetra::VectorFactory< double, int, int, EpetraNode >::Scalar
double Scalar
Definition
Xpetra_VectorFactory_decl.hpp:129
Xpetra::VectorFactory< double, int, int, EpetraNode >::GlobalOrdinal
int GlobalOrdinal
Definition
Xpetra_VectorFactory_decl.hpp:131
Xpetra::VectorFactory< double, int, int, EpetraNode >::Node
EpetraNode Node
Definition
Xpetra_VectorFactory_decl.hpp:132
Xpetra::VectorFactory< double, int, int, EpetraNode >::LocalOrdinal
int LocalOrdinal
Definition
Xpetra_VectorFactory_decl.hpp:130
Xpetra::VectorFactory< double, int, int, EpetraNode >::VectorFactory
VectorFactory()=default
Private constructor. This is a static class.
Xpetra::VectorFactory< double, int, long long, EpetraNode >::Node
EpetraNode Node
Definition
Xpetra_VectorFactory_decl.hpp:165
Xpetra::VectorFactory< double, int, long long, EpetraNode >::LocalOrdinal
int LocalOrdinal
Definition
Xpetra_VectorFactory_decl.hpp:163
Xpetra::VectorFactory< double, int, long long, EpetraNode >::GlobalOrdinal
long long GlobalOrdinal
Definition
Xpetra_VectorFactory_decl.hpp:164
Xpetra::VectorFactory< double, int, long long, EpetraNode >::Scalar
double Scalar
Definition
Xpetra_VectorFactory_decl.hpp:162
Xpetra::VectorFactory< double, int, long long, EpetraNode >::Build
static RCP< Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > &map, bool zeroOut=true)
Xpetra::VectorFactory< double, int, long long, EpetraNode >::VectorFactory
VectorFactory()=default
Private constructor. This is a static class.
Xpetra::VectorFactory< int, int, int, EpetraNode >::Scalar
int Scalar
Definition
Xpetra_VectorFactory_decl.hpp:197
Xpetra::VectorFactory< int, int, int, EpetraNode >::VectorFactory
VectorFactory()=default
Private constructor. This is a static class.
Xpetra::VectorFactory< int, int, int, EpetraNode >::LocalOrdinal
int LocalOrdinal
Definition
Xpetra_VectorFactory_decl.hpp:198
Xpetra::VectorFactory< int, int, int, EpetraNode >::GlobalOrdinal
int GlobalOrdinal
Definition
Xpetra_VectorFactory_decl.hpp:199
Xpetra::VectorFactory< int, int, int, EpetraNode >::Node
EpetraNode Node
Definition
Xpetra_VectorFactory_decl.hpp:200
Xpetra::VectorFactory< int, int, long long, EpetraNode >::Build
static RCP< Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > &map, bool zeroOut=true)
Xpetra::VectorFactory< int, int, long long, EpetraNode >::VectorFactory
VectorFactory()=default
Private constructor. This is a static class.
Xpetra::VectorFactory< int, int, long long, EpetraNode >::Node
EpetraNode Node
Definition
Xpetra_VectorFactory_decl.hpp:234
Xpetra::VectorFactory< int, int, long long, EpetraNode >::GlobalOrdinal
long long GlobalOrdinal
Definition
Xpetra_VectorFactory_decl.hpp:233
Xpetra::VectorFactory< int, int, long long, EpetraNode >::Scalar
int Scalar
Definition
Xpetra_VectorFactory_decl.hpp:231
Xpetra::VectorFactory< int, int, long long, EpetraNode >::LocalOrdinal
int LocalOrdinal
Definition
Xpetra_VectorFactory_decl.hpp:232
Xpetra::VectorFactory::TpetraVector
Xpetra::TpetraVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > TpetraVector
Xpetra::VectorFactory::VectorFactory
VectorFactory()=default
Private constructor. This is a static class.
Xpetra::VectorFactory::Build
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.
Definition
Xpetra_VectorFactory_decl.hpp:88
Xpetra
Xpetra namespace
Definition
Xpetra_BlockedCrsMatrix.hpp:89
Xpetra::EpetraNode
Tpetra::KokkosCompat::KokkosSerialWrapperNode EpetraNode
Definition
Xpetra_Map_decl.hpp:71
Xpetra::rcp
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Xpetra::UseTpetra
@ UseTpetra
Definition
Xpetra_Map_decl.hpp:79
src
Vector
Xpetra_VectorFactory_decl.hpp
Generated by
1.17.0