Xpetra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Xpetra_MultiVectorFactory_def.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_DEF_HPP
11 #define XPETRA_MULTIVECTORFACTORY_DEF_HPP
12 
14 
15 #include "Xpetra_BlockedMultiVector.hpp"
16 
17 #include "Xpetra_BlockedMap.hpp"
18 
19 namespace Xpetra {
20 
21 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
22 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
24  Build(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>& map,
25  size_t NumVectors,
26  bool zeroOut) {
27  XPETRA_MONITOR("MultiVectorFactory::Build");
28 
29  RCP<const BlockedMap<LocalOrdinal, GlobalOrdinal, Node>> bmap =
30  Teuchos::rcp_dynamic_cast<const BlockedMap<LocalOrdinal, GlobalOrdinal, Node>>(map);
31 
32  if (!bmap.is_null()) {
33  return rcp(new Xpetra::BlockedMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(bmap, NumVectors, zeroOut));
34  }
35 
36 #ifdef HAVE_XPETRA_TPETRA
37  if (map->lib() == UseTpetra) {
38  return rcp(new TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(map, NumVectors, zeroOut));
39  }
40 #endif
41 
44 }
45 
46 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
47 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
49  Build(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>& map,
50  const Teuchos::ArrayView<const Teuchos::ArrayView<const Scalar>>& ArrayOfPtrs,
51  size_t NumVectors) {
52  XPETRA_MONITOR("MultiVectorFactory::Build");
53 
54 #ifdef HAVE_XPETRA_TPETRA
55  if (map->lib() == UseTpetra) {
56  return rcp(new TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(map, ArrayOfPtrs, NumVectors));
57  }
58 #endif
59 
62 }
63 
64 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
65 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
68  Teuchos::DataAccess copyOrView) {
69  XPETRA_MONITOR("MultiVectorFactory::Build");
70 
71 #ifdef HAVE_XPETRA_TPETRA
72  if (source->getMap()->lib() == UseTpetra) {
73  return rcp(new TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(*source, copyOrView));
74  }
75 #endif
76 
77  XPETRA_FACTORY_ERROR_IF_EPETRA(source->getMap()->lib());
79 }
80 
81 } // namespace Xpetra
82 
83 #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.
#define XPETRA_FACTORY_ERROR_IF_EPETRA(lib)
#define XPETRA_FACTORY_END
#define XPETRA_MONITOR(funcName)