Ifpack2 Templated Preconditioning Package Version 1.0
Loading...
Searching...
No Matches
Ifpack2_ContainerFactory_decl.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Ifpack2: Templated Object-Oriented Algebraic Preconditioner Package
4//
5// Copyright 2009 NTESS and the Ifpack2 contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef IFPACK2_CONTAINERFACTORY_DECL_H
11#define IFPACK2_CONTAINERFACTORY_DECL_H
12
13#include "Ifpack2_Container.hpp"
14#include "Ifpack2_Partitioner.hpp"
15#ifdef HAVE_IFPACK2_AMESOS2
16#include "Ifpack2_Details_Amesos2Wrapper.hpp"
17#endif
18#include "Tpetra_RowMatrix.hpp"
19#include "Teuchos_RCP.hpp"
20#include "Teuchos_Ptr.hpp"
21#include <string>
22#include <map>
23
26
27namespace Ifpack2 {
28namespace Details {
29
30// The default container type names:
31//
32// Dense
33// SparseILUT
34// SparseAmesos, alias SparseAmesos2
35// TriDi
36// Banded
37
38template <typename MatrixType>
39struct ContainerFactoryEntryBase {
40 virtual Teuchos::RCP<Ifpack2::Container<MatrixType>> build(
41 const Teuchos::RCP<const MatrixType>& A,
42 const Teuchos::Array<Teuchos::Array<typename MatrixType::local_ordinal_type>>& partitions,
43 const Teuchos::RCP<const Tpetra::Import<
44 typename MatrixType::local_ordinal_type,
45 typename MatrixType::global_ordinal_type,
46 typename MatrixType::node_type>>
47 importer,
48 bool pointIndexed) = 0;
49 virtual ~ContainerFactoryEntryBase() {}
50};
51
52template <typename MatrixType, typename ContainerType>
53struct ContainerFactoryEntry : public ContainerFactoryEntryBase<MatrixType> {
54 Teuchos::RCP<Ifpack2::Container<MatrixType>> build(
55 const Teuchos::RCP<const MatrixType>& A,
56 const Teuchos::Array<Teuchos::Array<typename MatrixType::local_ordinal_type>>& partitions,
57 const Teuchos::RCP<const Tpetra::Import<
58 typename MatrixType::local_ordinal_type,
59 typename MatrixType::global_ordinal_type,
60 typename MatrixType::node_type>>
61 importer,
62 bool pointIndexed) {
63 return Teuchos::rcp(new ContainerType(A, partitions, importer, pointIndexed));
64 }
65 ~ContainerFactoryEntry() {}
66};
67
68} // namespace Details
69
75
76template <typename MatrixType>
79
80
82 typedef typename MatrixType::scalar_type scalar_type;
84 typedef typename MatrixType::local_ordinal_type local_ordinal_type;
86 typedef typename MatrixType::global_ordinal_type global_ordinal_type;
88 typedef typename MatrixType::node_type node_type;
89
91 typedef Tpetra::RowMatrix<scalar_type, local_ordinal_type, global_ordinal_type, node_type> row_matrix_type;
93 typedef Tpetra::Import<local_ordinal_type, global_ordinal_type, node_type> import_type;
96
97 static_assert(std::is_same<typename std::decay<MatrixType>::type, row_matrix_type>::value,
98 "MatrixType must be a Tpetra::RowMatrix specialization.");
99
100 // \name Functions
102
107 template <typename ContainerType>
108 static void registerContainer(std::string containerType);
109
111
118 static Teuchos::RCP<BaseContainer> build(std::string containerType, const Teuchos::RCP<const MatrixType>& A,
119 const Teuchos::Array<Teuchos::Array<local_ordinal_type>>& partitions, const Teuchos::RCP<const import_type> importer, bool pointIndexed);
120
122
125 static void deregisterContainer(std::string containerType);
127
128 private:
129 static std::map<std::string, Teuchos::RCP<Details::ContainerFactoryEntryBase<MatrixType>>> table;
130 static bool registeredDefaults; // this will initially be false
131 static void registerDefaults();
132};
133
134} // namespace Ifpack2
135
136#endif // IFPACK2_DETAILS_CONTAINERFACTORY_H
Interface for creating and solving a set of local linear problems.
Definition Ifpack2_Container_decl.hpp:79
Ifpack2 implementation details.
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
MatrixType::scalar_type scalar_type
The type of the entries of the input MatrixType.
Definition Ifpack2_ContainerFactory_decl.hpp:82
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
MatrixType::local_ordinal_type local_ordinal_type
The local_ordinal_type from the input MatrixType.
Definition Ifpack2_ContainerFactory_decl.hpp:84
MatrixType::node_type node_type
The node_type from the input MatrixType.
Definition Ifpack2_ContainerFactory_decl.hpp:88
Tpetra::RowMatrix< scalar_type, local_ordinal_type, global_ordinal_type, node_type > row_matrix_type
Tpetra::RowMatrix specialization (superclass of MatrixType)
Definition Ifpack2_ContainerFactory_decl.hpp:91
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
Tpetra::Import< local_ordinal_type, global_ordinal_type, node_type > import_type
Tpetra::Importer specialization for use with MatrixType and compatible MultiVectors.
Definition Ifpack2_ContainerFactory_decl.hpp:93
MatrixType::global_ordinal_type global_ordinal_type
The global_ordinal_type from the input MatrixType.
Definition Ifpack2_ContainerFactory_decl.hpp:86