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>::
30 registerContainer<Ifpack2::TriDiContainer<MatrixType, scalar_type>>(
"TriDi");
31 registerContainer<Ifpack2::DenseContainer<MatrixType, scalar_type>>(
"Dense");
32 registerContainer<Ifpack2::BandedContainer<MatrixType, scalar_type>>(
"Banded");
33 registerContainer<SparseContainer<MatrixType, ILUT<MatrixType>>>(
"SparseILUT");
34 #ifdef HAVE_IFPACK2_AMESOS2
35 registerContainer<SparseContainer<MatrixType, Details::Amesos2Wrapper<MatrixType>>>(
"SparseAmesos");
36 registerContainer<SparseContainer<MatrixType, Details::Amesos2Wrapper<MatrixType>>>(
"SparseAmesos2");
38 #ifdef HAVE_IFPACK2_EXPERIMENTAL_KOKKOSKERNELS_FEATURES
39 registerContainer<Ifpack2::BlockTriDiContainer<MatrixType>>(
"BlockTriDi");
41 registeredDefaults =
true;
44 template<
typename MatrixType>
45 template<
typename ContainerType>
50 table[containerType] =
Teuchos::rcp(
new Details::ContainerFactoryEntry<MatrixType, ContainerType>());
53 template<
typename MatrixType>
56 build(std::string containerType,
62 if(!registeredDefaults)
67 #ifndef HAVE_IFPACK2_AMESOS2
68 if(containerType ==
"SparseAmesos" || containerType ==
"SparseAmesos2")
70 throw std::invalid_argument(
"Container type SparseAmesos (aka SparseAmesos2) was requested but Amesos2 isn't enabled.\n"
71 "Add the CMake option \"-D Trilinos_ENABLE_Amesos2=ON\" to enable it.");
74 if(containerType ==
"BlockTriDi" && pointIndexed)
76 throw std::runtime_error(
"Ifpack2::BlockTriDi does not support decoupled blocks or split rows.\n");
78 auto it = table.find(containerType);
81 std::ostringstream oss;
82 oss <<
"Container type \"" << containerType <<
"\" not registered.\n";
83 oss <<
"Call ContainerFactory<MatrixType>::registerContainer<ContainerType>(containerName) first.\n";
84 oss <<
"Currently registered Container types: ";
87 oss <<
'\"' << r.first <<
"\" ";
91 str = str.substr(0, str.length() - 1);
92 throw std::invalid_argument(str);
94 return it->second->build(A, localRows, importer, pointIndexed);
97 template<
typename MatrixType>
101 auto it = table.find(containerType);
102 if(it != table.end())
110 template<
typename MatrixType>
113 template<
typename MatrixType>
119 #define IFPACK2_CONTAINERFACTORY_INSTANT(S,LO,GO,N) \
120 template struct Ifpack2::ContainerFactory<Tpetra::RowMatrix<S, LO, GO, N>>;
122 #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:47
A static "factory" that provides a way to register and construct arbitrary Ifpack2::Container subclas...
Definition: Ifpack2_ContainerFactory_decl.hpp:78
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:99
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:56
Ifpack2::ContainerFactory class declaration.