43 #ifndef IFPACK2_CONTAINERFACTORY_DEF_H 44 #define IFPACK2_CONTAINERFACTORY_DEF_H 47 #include "Ifpack2_TriDiContainer.hpp" 48 #include "Ifpack2_DenseContainer.hpp" 49 #include "Ifpack2_SparseContainer.hpp" 50 #include "Ifpack2_BandedContainer.hpp" 51 #include "Ifpack2_BlockTriDiContainer.hpp" 52 #include "Ifpack2_ILUT.hpp" 53 #include "Teuchos_ArrayView.hpp" 59 template<
typename MatrixType>
60 void ContainerFactory<MatrixType>::
63 registerContainer<Ifpack2::TriDiContainer<MatrixType, scalar_type>>(
"TriDi");
64 registerContainer<Ifpack2::DenseContainer<MatrixType, scalar_type>>(
"Dense");
65 registerContainer<Ifpack2::BandedContainer<MatrixType, scalar_type>>(
"Banded");
66 registerContainer<SparseContainer<MatrixType, ILUT<MatrixType>>>(
"SparseILUT");
67 #ifdef HAVE_IFPACK2_AMESOS2 68 registerContainer<SparseContainer<MatrixType, Details::Amesos2Wrapper<MatrixType>>>(
"SparseAmesos");
69 registerContainer<SparseContainer<MatrixType, Details::Amesos2Wrapper<MatrixType>>>(
"SparseAmesos2");
71 #ifdef HAVE_IFPACK2_EXPERIMENTAL_KOKKOSKERNELS_FEATURES 72 registerContainer<Ifpack2::BlockTriDiContainer<MatrixType>>(
"BlockTriDi");
74 registeredDefaults =
true;
77 template<
typename MatrixType>
78 template<
typename ContainerType>
83 table[containerType] = Teuchos::rcp(
new Details::ContainerFactoryEntry<MatrixType, ContainerType>());
86 template<
typename MatrixType>
87 Teuchos::RCP<typename ContainerFactory<MatrixType>::BaseContainer>
89 build(std::string containerType,
const Teuchos::RCP<const MatrixType>& A,
90 const Teuchos::Array<Teuchos::Array<local_ordinal_type>>& localRows,
const Teuchos::RCP<const import_type> importer,
93 if(!registeredDefaults)
98 #ifndef HAVE_IFPACK2_AMESOS2 99 if(containerType ==
"SparseAmesos" || containerType ==
"SparseAmesos2")
101 throw std::invalid_argument(
"Container type SparseAmesos (aka SparseAmesos2) was requested but Amesos2 isn't enabled.\n" 102 "Add the CMake option \"-D Trilinos_ENABLE_Amesos2=ON\" to enable it.");
105 auto it = table.find(containerType);
106 if(it == table.end())
108 std::ostringstream oss;
109 oss <<
"Container type \"" << containerType <<
"\" not registered.\n";
110 oss <<
"Call ContainerFactory<MatrixType>::registerContainer<ContainerType>(containerName) first.\n";
111 oss <<
"Currently registered Container types: ";
114 oss <<
'\"' << r.first <<
"\" ";
117 auto str = oss.str();
118 str = str.substr(0, str.length() - 1);
119 throw std::invalid_argument(str);
121 return it->second->build(A, localRows, importer, OverlapLevel, DampingFactor);
124 template<
typename MatrixType>
128 auto it = table.find(containerType);
129 if(it != table.end())
137 template<
typename MatrixType>
140 template<
typename MatrixType>
146 #define IFPACK2_CONTAINERFACTORY_INSTANT(S,LO,GO,N) \ 147 template struct Ifpack2::ContainerFactory<Tpetra::RowMatrix<S, LO, GO, N>>; 149 #endif // IFPACK2_DETAILS_CONTAINERFACTORY_H static Teuchos::RCP< BaseContainer > build(std::string containerType, const Teuchos::RCP< const MatrixType > &A, const Teuchos::Array< Teuchos::Array< local_ordinal_type >> &localRows, const Teuchos::RCP< const import_type > importer, int OverlapLevel, scalar_type DampingFactor)
Build a specialization of Ifpack2::Container given a key that has been registered.
Definition: Ifpack2_ContainerFactory_def.hpp:89
static void registerContainer(std::string containerType)
Registers a specialization of Ifpack2::Container by binding a key (string) to it. ...
Definition: Ifpack2_ContainerFactory_def.hpp:80
A static "factory" that provides a way to register and construct arbitrary Ifpack2::Container subclas...
Definition: Ifpack2_ContainerFactory_decl.hpp:113
static void deregisterContainer(std::string containerType)
Registers a specialization of Ifpack2::Container by binding a key (string) to it. ...
Definition: Ifpack2_ContainerFactory_def.hpp:126
Preconditioners and smoothers for Tpetra sparse matrices.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:72
MatrixType::scalar_type scalar_type
The type of the entries of the input MatrixType.
Definition: Ifpack2_ContainerFactory_decl.hpp:119
Ifpack2::ContainerFactory class declaration.