10 #ifndef IFPACK2_CONTAINERFACTORY_DEF_H
11 #define IFPACK2_CONTAINERFACTORY_DEF_H
14 #include "Ifpack2_TriDiContainer.hpp"
15 #include "Ifpack2_DenseContainer.hpp"
16 #include "Ifpack2_SparseContainer.hpp"
17 #include "Ifpack2_BandedContainer.hpp"
18 #include "Ifpack2_BlockTriDiContainer.hpp"
19 #include "Ifpack2_ILUT.hpp"
20 #include "Teuchos_ArrayView.hpp"
26 template <
typename MatrixType>
27 void ContainerFactory<MatrixType>::
29 registerContainer<Ifpack2::TriDiContainer<MatrixType, scalar_type>>(
"TriDi");
30 registerContainer<Ifpack2::DenseContainer<MatrixType, scalar_type>>(
"Dense");
31 registerContainer<Ifpack2::BandedContainer<MatrixType, scalar_type>>(
"Banded");
32 registerContainer<SparseContainer<MatrixType, ILUT<MatrixType>>>(
"SparseILUT");
33 #ifdef HAVE_IFPACK2_AMESOS2
34 registerContainer<SparseContainer<MatrixType, Details::Amesos2Wrapper<MatrixType>>>(
"SparseAmesos");
35 registerContainer<SparseContainer<MatrixType, Details::Amesos2Wrapper<MatrixType>>>(
"SparseAmesos2");
37 #ifdef HAVE_IFPACK2_EXPERIMENTAL_KOKKOSKERNELS_FEATURES
38 registerContainer<Ifpack2::BlockTriDiContainer<MatrixType>>(
"BlockTriDi");
40 registeredDefaults =
true;
43 template <
typename MatrixType>
44 template <
typename ContainerType>
48 table[containerType] =
Teuchos::rcp(
new Details::ContainerFactoryEntry<MatrixType, ContainerType>());
51 template <
typename MatrixType>
54 build(std::string containerType,
59 if (!registeredDefaults) {
63 #ifndef HAVE_IFPACK2_AMESOS2
64 if (containerType ==
"SparseAmesos" || containerType ==
"SparseAmesos2") {
65 throw std::invalid_argument(
66 "Container type SparseAmesos (aka SparseAmesos2) was requested but Amesos2 isn't enabled.\n"
67 "Add the CMake option \"-D Trilinos_ENABLE_Amesos2=ON\" to enable it.");
70 if (containerType ==
"BlockTriDi" && pointIndexed) {
71 throw std::runtime_error(
"Ifpack2::BlockTriDi does not support decoupled blocks or split rows.\n");
73 auto it = table.find(containerType);
74 if (it == table.end()) {
75 std::ostringstream oss;
76 oss <<
"Container type \"" << containerType <<
"\" not registered.\n";
77 oss <<
"Call ContainerFactory<MatrixType>::registerContainer<ContainerType>(containerName) first.\n";
78 oss <<
"Currently registered Container types: ";
79 for (
auto r : table) {
80 oss <<
'\"' << r.first <<
"\" ";
84 str = str.substr(0, str.length() - 1);
85 throw std::invalid_argument(str);
87 return it->second->build(A, localRows, importer, pointIndexed);
90 template <
typename MatrixType>
93 auto it = table.find(containerType);
94 if (it != table.end()) {
101 template <
typename MatrixType>
104 template <
typename MatrixType>
109 #define IFPACK2_CONTAINERFACTORY_INSTANT(S, LO, GO, N) \
110 template struct Ifpack2::ContainerFactory<Tpetra::RowMatrix<S, LO, GO, N>>;
112 #endif // IFPACK2_DETAILS_CONTAINERFACTORY_H
static void registerContainer(std::string containerType)
Registers a specialization of Ifpack2::Container by binding a key (string) to it. ...
Definition: Ifpack2_ContainerFactory_def.hpp:46
A static "factory" that provides a way to register and construct arbitrary Ifpack2::Container subclas...
Definition: Ifpack2_ContainerFactory_decl.hpp:77
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
static void deregisterContainer(std::string containerType)
Registers a specialization of Ifpack2::Container by binding a key (string) to it. ...
Definition: Ifpack2_ContainerFactory_def.hpp:92
static Teuchos::RCP< BaseContainer > build(std::string containerType, const Teuchos::RCP< const MatrixType > &A, const Teuchos::Array< Teuchos::Array< local_ordinal_type >> &partitions, const Teuchos::RCP< const import_type > importer, bool pointIndexed)
Build a specialization of Ifpack2::Container given a key that has been registered.
Definition: Ifpack2_ContainerFactory_def.hpp:54
Ifpack2::ContainerFactory class declaration.