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>
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;
44template<
typename MatrixType>
45template<
typename ContainerType>
50 table[containerType] = Teuchos::rcp(
new Details::ContainerFactoryEntry<MatrixType, ContainerType>());
53template<
typename MatrixType>
54Teuchos::RCP<typename ContainerFactory<MatrixType>::BaseContainer>
56build(std::string containerType,
57 const Teuchos::RCP<const MatrixType>& A,
58 const Teuchos::Array<Teuchos::Array<local_ordinal_type>>& localRows,
59 const Teuchos::RCP<const import_type> importer,
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);
97template<
typename MatrixType>
101 auto it = table.find(containerType);
102 if(it != table.end())
110template<
typename MatrixType>
111std::map<std::string, Teuchos::RCP<Details::ContainerFactoryEntryBase<MatrixType>>> ContainerFactory<MatrixType>::table;
113template<
typename MatrixType>
114bool ContainerFactory<MatrixType>::registeredDefaults;
119#define IFPACK2_CONTAINERFACTORY_INSTANT(S,LO,GO,N) \
120template struct Ifpack2::ContainerFactory<Tpetra::RowMatrix<S, LO, GO, N>>;
Ifpack2::ContainerFactory class declaration.
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:41
A static "factory" that provides a way to register and construct arbitrary Ifpack2::Container subclas...
Definition Ifpack2_ContainerFactory_decl.hpp:79
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
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