Ifpack2 Templated Preconditioning Package Version 1.0
Loading...
Searching...
No Matches
Ifpack2_SparseContainer_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_SPARSECONTAINER_DECL_HPP
11#define IFPACK2_SPARSECONTAINER_DECL_HPP
12
15
16#include "Ifpack2_Container.hpp"
18#include "Tpetra_MultiVector.hpp"
19#include "Tpetra_Map.hpp"
20#include "Tpetra_RowMatrix.hpp"
21#include "Tpetra_CrsMatrix.hpp"
22#include "Teuchos_ParameterList.hpp"
23#include "Ifpack2_ILUT_decl.hpp"
24#include <vector>
25#ifdef HAVE_IFPACK2_AMESOS2
26#include "Ifpack2_Details_Amesos2Wrapper.hpp"
27#endif
28
29namespace Ifpack2 {
30
100template <typename MatrixType, typename InverseType>
102 : public ContainerImpl<MatrixType, typename InverseType::scalar_type> {
104
105 private:
112 using matrix_type = MatrixType;
118 using inverse_type = InverseType;
119
120 using typename Container<MatrixType>::SC;
121 using typename Container<MatrixType>::LO;
122 using typename Container<MatrixType>::GO;
123 using typename Container<MatrixType>::NO;
124
125 using typename Container<MatrixType>::mv_type;
126 using typename Container<MatrixType>::map_type;
127 using typename Container<MatrixType>::vector_type;
128 using typename Container<MatrixType>::import_type;
129
130 using InverseScalar = typename InverseType::scalar_type;
131 using InverseLocalOrdinal = typename InverseType::local_ordinal_type;
132 using InverseGlobalOrdinal = typename InverseType::global_ordinal_type;
133 using InverseNode = typename InverseType::node_type;
134
135 using typename ContainerImpl<MatrixType, InverseScalar>::block_crs_matrix_type;
136
137 using inverse_mv_type = Tpetra::MultiVector<InverseScalar, InverseLocalOrdinal, InverseGlobalOrdinal, InverseNode>;
138 using InverseCrs = Tpetra::CrsMatrix<InverseScalar, InverseLocalOrdinal, InverseGlobalOrdinal, InverseNode>;
139 using InverseMap = typename Tpetra::Map<InverseLocalOrdinal, InverseGlobalOrdinal, InverseNode>;
140 using InverseGraph = typename InverseCrs::crs_graph_type;
141 using typename Container<MatrixType>::HostView;
142 using typename Container<MatrixType>::ConstHostView;
143 using HostViewInverse = typename inverse_mv_type::dual_view_type::t_host;
144
145 static_assert(std::is_same<MatrixType,
146 Tpetra::RowMatrix<SC, LO, GO, NO>>::value,
147 "Ifpack2::SparseContainer: Please use MatrixType = Tpetra::RowMatrix.");
148
157 using typename Container<MatrixType>::row_matrix_type;
159
160 public:
162
163
174 SparseContainer(const Teuchos::RCP<const row_matrix_type>& matrix,
175 const Teuchos::Array<Teuchos::Array<LO>>& partitions,
176 const Teuchos::RCP<const import_type>& importer,
177 bool pointIndexed);
178
180 virtual ~SparseContainer();
181
183
185
187 virtual void setParameters(const Teuchos::ParameterList& List);
188
190
192
194 virtual void initialize();
195
197 virtual void compute();
198
202 void clearBlocks();
203
205 virtual void
206 apply(ConstHostView X,
207 HostView Y,
208 int blockIndex,
209 Teuchos::ETransp mode = Teuchos::NO_TRANS,
210 SC alpha = Teuchos::ScalarTraits<SC>::one(),
211 SC beta = Teuchos::ScalarTraits<SC>::zero()) const;
212
214 virtual void
215 weightedApply(ConstHostView X,
216 HostView Y,
217 ConstHostView W,
218 int blockIndex,
219 Teuchos::ETransp mode = Teuchos::NO_TRANS,
220 SC alpha = Teuchos::ScalarTraits<SC>::one(),
221 SC beta = Teuchos::ScalarTraits<SC>::zero()) const;
222
224
226
230 virtual std::ostream& print(std::ostream& os) const;
231
233
235
237 virtual std::string description() const;
238
240 virtual void
241 describe(Teuchos::FancyOStream& out,
242 const Teuchos::EVerbosityLevel verbLevel =
243 Teuchos::Describable::verbLevel_default) const;
245
247 static std::string getName();
248
249 private:
252
254 void extract();
255 void extractGraph();
256 void extractValues();
257
269 void
270 solveBlockMV(const inverse_mv_type& X,
271 inverse_mv_type& Y,
272 int blockIndex,
273 Teuchos::ETransp mode,
274 InverseScalar alpha,
275 InverseScalar beta) const;
276
278 std::vector<Teuchos::RCP<InverseCrs>> diagBlocks_;
279
281 mutable std::vector<inverse_mv_type> invX;
283 mutable std::vector<inverse_mv_type> invY;
284
292 mutable Teuchos::Array<Teuchos::RCP<InverseType>> Inverses_;
294 Teuchos::RCP<Teuchos::Comm<int>> localComm_;
295
297 Teuchos::ParameterList List_;
298};
299
300} // namespace Ifpack2
301
302#endif // IFPACK2_SPARSECONTAINER_HPP
Declaration and definition of the Ifpack2::Details::MultiVectorLocalGatherScatter class.
Declaration of ILUT preconditioner.
The implementation of the numerical features of Container (Jacobi, Gauss-Seidel, SGS)....
Definition Ifpack2_Container_decl.hpp:311
typename mv_type::dual_view_type::t_host HostView
Definition Ifpack2_Container_decl.hpp:109
Store and solve a local sparse linear problem.
Definition Ifpack2_SparseContainer_decl.hpp:102
virtual void apply(ConstHostView X, HostView Y, int blockIndex, Teuchos::ETransp mode=Teuchos::NO_TRANS, SC alpha=Teuchos::ScalarTraits< SC >::one(), SC beta=Teuchos::ScalarTraits< SC >::zero()) const
Compute Y := alpha * M^{-1} X + beta*Y.
Definition Ifpack2_SparseContainer_def.hpp:145
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to the given FancyOStream.
Definition Ifpack2_SparseContainer_def.hpp:458
virtual void weightedApply(ConstHostView X, HostView Y, ConstHostView W, int blockIndex, Teuchos::ETransp mode=Teuchos::NO_TRANS, SC alpha=Teuchos::ScalarTraits< SC >::one(), SC beta=Teuchos::ScalarTraits< SC >::zero()) const
Compute Y := alpha * diag(D) * M^{-1} (diag(D) * X) + beta*Y.
Definition Ifpack2_SparseContainer_def.hpp:271
static std::string getName()
Get the name of this container type for Details::constructContainer()
Definition Ifpack2_SparseContainer_def.hpp:853
virtual void initialize()
Do all set-up operations that only require matrix structure.
Definition Ifpack2_SparseContainer_def.hpp:54
void clearBlocks()
Definition Ifpack2_SparseContainer_def.hpp:107
virtual void compute()
Initialize and compute all blocks.
Definition Ifpack2_SparseContainer_def.hpp:84
virtual ~SparseContainer()
Destructor (declared virtual for memory safety of derived classes).
Definition Ifpack2_SparseContainer_def.hpp:44
virtual std::ostream & print(std::ostream &os) const
Print information about this object to the given output stream.
Definition Ifpack2_SparseContainer_def.hpp:426
virtual std::string description() const
A one-line description of this object.
Definition Ifpack2_SparseContainer_def.hpp:435
virtual void setParameters(const Teuchos::ParameterList &List)
Set all necessary parameters.
Definition Ifpack2_SparseContainer_def.hpp:48
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:40