Xpetra Version of the Day
Loading...
Searching...
No Matches
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
22#endif
23
24#include "Xpetra_Exceptions.hpp"
25
26namespace Xpetra {
27
28template <class LocalOrdinal,
29 class GlobalOrdinal,
30 class Node = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>
32 private:
35
36 public:
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
61template <>
62class ImportFactory<int, int, EpetraNode> {
63 typedef int LocalOrdinal;
64 typedef int GlobalOrdinal;
66
67 private:
70
71 public:
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))
93template <>
94class ImportFactory<int, long long, EpetraNode> {
95 typedef int LocalOrdinal;
96 typedef long long GlobalOrdinal;
98
99 private:
102
103 public:
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
#define XPETRA_MONITOR(funcName)
#define XPETRA_FACTORY_ERROR_IF_EPETRA(lib)
#define XPETRA_FACTORY_END
Exception throws to report errors in the internal logical of the program.
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)
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)
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)
Constructor specifying the number of non-zeros for all rows.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Tpetra::KokkosCompat::KokkosSerialWrapperNode EpetraNode