Xpetra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Xpetra_MultiVectorFactory_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_MULTIVECTORFACTORY_DECL_HPP
11 #define XPETRA_MULTIVECTORFACTORY_DECL_HPP
12 
13 #include "Xpetra_ConfigDefs.hpp"
15 
16 #ifdef HAVE_XPETRA_TPETRA
17 #include "Xpetra_TpetraMultiVector.hpp"
18 #endif
19 
20 #ifdef HAVE_XPETRA_EPETRA
23 #endif
24 
25 // #include "Xpetra_BlockedMap.hpp"
26 #include "Xpetra_Exceptions.hpp"
27 
28 namespace Xpetra {
29 
46 template <class Scalar,
47  class LocalOrdinal,
48  class GlobalOrdinal,
49  class Node = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>
51  private:
54 
55  public:
57  static Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
58  Build(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &map, size_t NumVectors, bool zeroOut = true);
59 
61  static Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
62  Build(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &map,
63  const Teuchos::ArrayView<const Teuchos::ArrayView<const Scalar>> &ArrayOfPtrs,
64  size_t NumVectors);
65 
66  static Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
67  Build(const Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>> &source,
68  Teuchos::DataAccess copyOrView);
69 };
70 
71 // we need the Epetra specialization only if Epetra is enabled
72 #if defined(HAVE_XPETRA_EPETRA)
73 
74 #if !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
75 
76 // Specialization for Scalar=double, LO=GO=int and Serial node
77 // Used both for Epetra and Tpetra
78 // For any other node definition the general default implementation is used which allows Tpetra only
79 template <>
80 class MultiVectorFactory<double, int, int, EpetraNode> {
81  typedef double Scalar;
82  typedef int LocalOrdinal;
83  typedef int GlobalOrdinal;
84  typedef EpetraNode Node;
85 
86  private:
89 
90  public:
91  static RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
92  Build(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &map, size_t NumVectors, bool zeroOut = true);
93 
95  static Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
96  Build(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &map,
97  const Teuchos::ArrayView<const Teuchos::ArrayView<const Scalar>> &ArrayOfPtrs,
98  size_t NumVectors);
99 
100  static Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
101  Build(const Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>> &source,
102  Teuchos::DataAccess copyOrView);
103 };
104 
105 template <>
106 class MultiVectorFactory<int, int, int, EpetraNode> {
107  typedef int Scalar;
108  typedef int LocalOrdinal;
109  typedef int GlobalOrdinal;
110  typedef EpetraNode Node;
111 
112  private:
115 
116  public:
117  static RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
118  Build(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &map, size_t NumVectors, bool zeroOut = true);
119 
121  static Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
122  Build(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &map,
123  const Teuchos::ArrayView<const Teuchos::ArrayView<const Scalar>> &ArrayOfPtrs,
124  size_t NumVectors);
125 
126  static Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
127  Build(const Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>> &source,
128  Teuchos::DataAccess copyOrView);
129 };
130 
131 // we need the Epetra specialization only if Epetra is enabled
132 #if !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
133 
134 template <>
135 class MultiVectorFactory<double, int, long long, EpetraNode> {
136  typedef double Scalar;
137  typedef int LocalOrdinal;
138  typedef long long GlobalOrdinal;
139  typedef EpetraNode Node;
140 
141  private:
144 
145  public:
146  static RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
147  Build(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &map,
148  size_t NumVectors,
149  bool zeroOut = true);
150 
152  static Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
153  Build(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &map,
154  const Teuchos::ArrayView<const Teuchos::ArrayView<const Scalar>> &ArrayOfPtrs,
155  size_t NumVectors);
156 
157  static Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
158  Build(const Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>> &source,
159  Teuchos::DataAccess copyOrView);
160 };
161 
162 template <>
163 class MultiVectorFactory<int, int, long long, EpetraNode> {
164  typedef int Scalar;
165  typedef int LocalOrdinal;
166  typedef long long GlobalOrdinal;
167  typedef EpetraNode Node;
168 
169  private:
172 
173  public:
174  static RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
175  Build(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &map,
176  size_t NumVectors,
177  bool zeroOut = true);
178 
180  static Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
181  Build(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &map,
182  const Teuchos::ArrayView<const Teuchos::ArrayView<const Scalar>> &ArrayOfPtrs,
183  size_t NumVectors);
184 
185  static Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
186  Build(const Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>> &source,
187  Teuchos::DataAccess copyOrView);
188 };
189 
190 #endif // END !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
191 
192 #endif // END !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
193 
194 #endif // END HAVE_XPETRA_EPETRA
195 
196 } // namespace Xpetra
197 
198 #define XPETRA_MULTIVECTORFACTORY_SHORT
199 #endif
static Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node >> &map, size_t NumVectors, bool zeroOut=true)
Constructor specifying the number of non-zeros for all rows.
Factory for any type of Xpetra::MultiVector and its derived classes.
MultiVectorFactory()
Private constructor. This is a static class.
Tpetra::KokkosCompat::KokkosSerialWrapperNode EpetraNode