Xpetra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Xpetra_ExportFactory.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_EXPORTFACTORY_HPP
11 #define XPETRA_EXPORTFACTORY_HPP
12 
13 #include "Xpetra_ConfigDefs.hpp"
14 
15 #include "Xpetra_Export.hpp"
16 
17 #ifdef HAVE_XPETRA_TPETRA
18 #include "Xpetra_TpetraExport.hpp"
19 #endif
20 #ifdef HAVE_XPETRA_EPETRA
21 #include "Xpetra_EpetraExport.hpp"
22 #endif
23 
24 #include "Xpetra_Exceptions.hpp"
25 
26 namespace Xpetra {
27 
28 template <class LocalOrdinal,
29  class GlobalOrdinal,
30  class Node = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>
32  private:
35 
36  public:
38  static RCP<Export<LocalOrdinal, GlobalOrdinal, Node> > Build(const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &source, const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &target) {
39  XPETRA_MONITOR("ExportFactory::Build");
40  TEUCHOS_TEST_FOR_EXCEPTION(source->lib() != target->lib(), Xpetra::Exceptions::RuntimeError, "");
41 
42 #ifdef HAVE_XPETRA_TPETRA
43  if (source->lib() == UseTpetra)
44  return rcp(new TpetraExport<LocalOrdinal, GlobalOrdinal, Node>(source, target));
45 #endif
46 
47  XPETRA_FACTORY_ERROR_IF_EPETRA(source->lib());
49  }
50 };
51 
52 // we need the Epetra specialization only if Epetra is enabled
53 #if (defined(HAVE_XPETRA_EPETRA) && !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES))
54 template <>
55 class ExportFactory<int, int, EpetraNode> {
56  typedef int LocalOrdinal;
57  typedef int GlobalOrdinal;
58  typedef EpetraNode Node;
59 
60  private:
63 
64  public:
65  static RCP<Export<LocalOrdinal, GlobalOrdinal, Node> > Build(const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &source, const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &target) {
66  XPETRA_MONITOR("ExportFactory::Build");
67 
68  TEUCHOS_TEST_FOR_EXCEPTION(source->lib() != target->lib(), Xpetra::Exceptions::RuntimeError, "");
69 
70 #ifdef HAVE_XPETRA_TPETRA
71  if (source->lib() == UseTpetra)
72  return rcp(new TpetraExport<LocalOrdinal, GlobalOrdinal, Node>(source, target));
73 #endif
74 
75  if (source->lib() == UseEpetra)
76  return rcp(new EpetraExportT<int, Node>(source, target));
77 
79  }
80 };
81 #endif
82 
83 // we need the Epetra specialization only if Epetra is enabled
84 #if (defined(HAVE_XPETRA_EPETRA) && !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES))
85 template <>
86 class ExportFactory<int, long long, EpetraNode> {
87  typedef int LocalOrdinal;
88  typedef long long GlobalOrdinal;
89  typedef EpetraNode Node;
90 
91  private:
94 
95  public:
96  static RCP<Export<LocalOrdinal, GlobalOrdinal, Node> > Build(const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &source, const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &target) {
97  XPETRA_MONITOR("ExportFactory::Build");
98 
99  TEUCHOS_TEST_FOR_EXCEPTION(source->lib() != target->lib(), Xpetra::Exceptions::RuntimeError, "");
100 
101 #ifdef HAVE_XPETRA_TPETRA
102  if (source->lib() == UseTpetra)
103  return rcp(new TpetraExport<LocalOrdinal, GlobalOrdinal, Node>(source, target));
104 #endif
105 
106  if (source->lib() == UseEpetra)
107  return rcp(new EpetraExportT<long long, Node>(source, target));
108 
110  }
111 };
112 #endif
113 
114 } // namespace Xpetra
115 
116 #define XPETRA_EXPORTFACTORY_SHORT
117 #endif
static RCP< Export< LocalOrdinal, GlobalOrdinal, Node > > Build(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &source, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &target)
Constructor specifying the number of non-zeros for all rows.
ExportFactory()
Private constructor. This is a static class.
ExportFactory()
Private constructor. This is a static class.
Exception throws to report errors in the internal logical of the program.
#define XPETRA_FACTORY_ERROR_IF_EPETRA(lib)
static RCP< Export< LocalOrdinal, GlobalOrdinal, Node > > Build(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &source, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &target)
#define XPETRA_FACTORY_END
ExportFactory()
Private constructor. This is a static class.
Tpetra::KokkosCompat::KokkosSerialWrapperNode EpetraNode
#define XPETRA_MONITOR(funcName)
static RCP< Export< LocalOrdinal, GlobalOrdinal, Node > > Build(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &source, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &target)