43 #ifndef IFPACK2_CONTAINERFACTORY_DECL_H
44 #define IFPACK2_CONTAINERFACTORY_DECL_H
47 #include "Ifpack2_Partitioner.hpp"
48 #ifdef HAVE_IFPACK2_AMESOS2
49 # include "Ifpack2_Details_Amesos2Wrapper.hpp"
51 #include "Tpetra_RowMatrix.hpp"
52 #include "Teuchos_RCP.hpp"
53 #include "Teuchos_Ptr.hpp"
71 template<
typename MatrixType>
72 struct ContainerFactoryEntryBase
74 virtual Teuchos::RCP<Ifpack2::Container<MatrixType>> build(
75 const Teuchos::RCP<const MatrixType>& A,
76 const Teuchos::Array<Teuchos::Array<typename MatrixType::local_ordinal_type>>& localRows,
77 const Teuchos::RCP<
const Tpetra::Import<
78 typename MatrixType::local_ordinal_type,
79 typename MatrixType::global_ordinal_type,
80 typename MatrixType::node_type>> importer,
82 typename MatrixType::scalar_type DampingFactor) = 0;
83 virtual ~ContainerFactoryEntryBase<MatrixType>() {}
86 template<
typename MatrixType,
typename ContainerType>
87 struct ContainerFactoryEntry :
public ContainerFactoryEntryBase<MatrixType>
89 Teuchos::RCP<Ifpack2::Container<MatrixType>> build(
90 const Teuchos::RCP<const MatrixType>& A,
91 const Teuchos::Array<Teuchos::Array<typename MatrixType::local_ordinal_type>>& localRows,
92 const Teuchos::RCP<
const Tpetra::Import<
93 typename MatrixType::local_ordinal_type,
94 typename MatrixType::global_ordinal_type,
95 typename MatrixType::node_type>> importer,
97 typename MatrixType::scalar_type DampingFactor)
99 return Teuchos::rcp(
new ContainerType(A, localRows, importer, OverlapLevel, DampingFactor));
101 ~ContainerFactoryEntry<MatrixType, ContainerType>() {}
112 template<
typename MatrixType>
128 typedef Tpetra::RowMatrix<scalar_type, local_ordinal_type, global_ordinal_type, node_type>
row_matrix_type;
130 typedef Tpetra::Import<local_ordinal_type, global_ordinal_type, node_type>
import_type;
134 static_assert (std::is_same<
typename std::decay<MatrixType>::type,
row_matrix_type>::value,
135 "MatrixType must be a Tpetra::RowMatrix specialization.");
144 template<
typename ContainerType>
156 static Teuchos::RCP<BaseContainer>
build(std::string containerType,
const Teuchos::RCP<const MatrixType>& A,
157 const Teuchos::Array<Teuchos::Array<local_ordinal_type>>& localRows,
const Teuchos::RCP<const import_type> importer,
168 static std::map<std::string, Teuchos::RCP<Details::ContainerFactoryEntryBase<MatrixType>>> table;
169 static bool registeredDefaults;
170 static void registerDefaults();
175 #endif // IFPACK2_DETAILS_CONTAINERFACTORY_H