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"
26template <
typename MatrixType>
27void 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;
43template <
typename MatrixType>
44template <
typename ContainerType>
51template <
typename MatrixType>
52Teuchos::RCP<typename ContainerFactory<MatrixType>::BaseContainer>
54 build(std::string containerType,
55 const Teuchos::RCP<const MatrixType>& A,
56 const Teuchos::Array<Teuchos::Array<local_ordinal_type>>& localRows,
57 const Teuchos::RCP<const import_type> importer,
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);
90template <
typename MatrixType>
93 auto it = table.find(containerType);
94 if (it != table.end()) {
101template <
typename MatrixType>
104template <
typename MatrixType>
109#define IFPACK2_CONTAINERFACTORY_INSTANT(S, LO, GO, N) \
110 template struct Ifpack2::ContainerFactory<Tpetra::RowMatrix<S, LO, GO, N>>;
Ifpack2::ContainerFactory class declaration.
Ifpack2's implementation of Trilinos::Details::LinearSolver interface.
Definition Ifpack2_Details_LinearSolver_decl.hpp:75
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:40
A static "factory" that provides a way to register and construct arbitrary Ifpack2::Container subclas...
Definition Ifpack2_ContainerFactory_decl.hpp:77
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
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