Xpetra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Xpetra_ImportFactory.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_IMPORTFACTORY_HPP
11 #define XPETRA_IMPORTFACTORY_HPP
12 
13 #include "Xpetra_ConfigDefs.hpp"
14 
15 #include "Xpetra_Import.hpp"
16 
17 #ifdef HAVE_XPETRA_TPETRA
18 #include "Xpetra_TpetraImport.hpp"
19 #endif
20 #ifdef HAVE_XPETRA_EPETRA
21 #include "Xpetra_EpetraImport.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<Import<LocalOrdinal, GlobalOrdinal, Node> > Build(const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &source,
39  const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &target,
40  const Teuchos::RCP<Teuchos::ParameterList> &plist = Teuchos::null) {
41  XPETRA_MONITOR("ImportFactory::Build");
42 
43  TEUCHOS_TEST_FOR_EXCEPTION(source->lib() != target->lib(), Xpetra::Exceptions::RuntimeError, "");
44 
45 #ifdef HAVE_XPETRA_TPETRA
46  if (source->lib() == UseTpetra)
47  return rcp(new TpetraImport<LocalOrdinal, GlobalOrdinal, Node>(source, target, plist));
48 #endif
49 
50  XPETRA_FACTORY_ERROR_IF_EPETRA(source->lib());
52  }
53 };
54 
55 // we need the Epetra specialization only if Epetra is enabled
56 #if (defined(HAVE_XPETRA_EPETRA) && !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES))
57 
58 // Specialization on LO=GO=int with serial node.
59 // Used for Epetra and Tpetra
60 // For any other node definition the general default implementation is used which allows Tpetra only
61 template <>
62 class ImportFactory<int, int, EpetraNode> {
63  typedef int LocalOrdinal;
64  typedef int GlobalOrdinal;
65  typedef EpetraNode Node;
66 
67  private:
70 
71  public:
72  static RCP<Import<LocalOrdinal, GlobalOrdinal, Node> > Build(const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &source,
73  const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &target,
74  const Teuchos::RCP<Teuchos::ParameterList> &plist = Teuchos::null) {
75  XPETRA_MONITOR("ImportFactory::Build");
76  TEUCHOS_TEST_FOR_EXCEPTION(source->lib() != target->lib(), Xpetra::Exceptions::RuntimeError, "");
77 
78 #ifdef HAVE_XPETRA_TPETRA
79  if (source->lib() == UseTpetra)
80  return rcp(new TpetraImport<LocalOrdinal, GlobalOrdinal, Node>(source, target, plist));
81 #endif
82 
83  if (source->lib() == UseEpetra)
84  return rcp(new EpetraImportT<int, Node>(source, target));
85 
87  }
88 };
89 #endif
90 
91 // we need the Epetra specialization only if Epetra is enabled
92 #if (defined(HAVE_XPETRA_EPETRA) && !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES))
93 template <>
94 class ImportFactory<int, long long, EpetraNode> {
95  typedef int LocalOrdinal;
96  typedef long long GlobalOrdinal;
97  typedef EpetraNode Node;
98 
99  private:
102 
103  public:
104  static RCP<Import<LocalOrdinal, GlobalOrdinal, Node> > Build(const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &source,
105  const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &target,
106  const Teuchos::RCP<Teuchos::ParameterList> &plist = Teuchos::null) {
107  XPETRA_MONITOR("ImportFactory::Build");
108  TEUCHOS_TEST_FOR_EXCEPTION(source->lib() != target->lib(), Xpetra::Exceptions::RuntimeError, "");
109 
110 #ifdef HAVE_XPETRA_TPETRA
111  if (source->lib() == UseTpetra)
112  return rcp(new TpetraImport<LocalOrdinal, GlobalOrdinal, Node>(source, target, plist));
113 #endif
114 
115  if (source->lib() == UseEpetra)
116  return rcp(new EpetraImportT<long long, Node>(source, target));
117 
119  }
120 };
121 #endif
122 } // namespace Xpetra
123 
124 #define XPETRA_IMPORTFACTORY_SHORT
125 #endif
Exception throws to report errors in the internal logical of the program.
#define XPETRA_FACTORY_ERROR_IF_EPETRA(lib)
#define XPETRA_FACTORY_END
ImportFactory()
Private constructor. This is a static class.
ImportFactory()
Private constructor. This is a static class.
static RCP< Import< LocalOrdinal, GlobalOrdinal, Node > > Build(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &source, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &target, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
static RCP< Import< LocalOrdinal, GlobalOrdinal, Node > > Build(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &source, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &target, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Tpetra::KokkosCompat::KokkosSerialWrapperNode EpetraNode
#define XPETRA_MONITOR(funcName)
ImportFactory()
Private constructor. This is a static class.
static RCP< Import< LocalOrdinal, GlobalOrdinal, Node > > Build(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &source, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &target, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying the number of non-zeros for all rows.