Ifpack2 Templated Preconditioning Package  Version 1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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"
23 #include "Ifpack2_ILUT_decl.hpp"
24 #include <vector>
25 #ifdef HAVE_IFPACK2_AMESOS2
26 #include "Ifpack2_Details_Amesos2Wrapper.hpp"
27 #endif
28 
29 namespace Ifpack2 {
30 
100 template<typename MatrixType, typename InverseType>
102 : public ContainerImpl<MatrixType, typename InverseType::scalar_type>
103 {
104 
106 
107 private:
114  using matrix_type = MatrixType;
120  using inverse_type = InverseType;
121 
122  using typename Container<MatrixType>::SC;
123  using typename Container<MatrixType>::LO;
124  using typename Container<MatrixType>::GO;
125  using typename Container<MatrixType>::NO;
126 
127  using typename Container<MatrixType>::mv_type;
128  using typename Container<MatrixType>::map_type;
129  using typename Container<MatrixType>::vector_type;
130  using typename Container<MatrixType>::import_type;
131 
132  using InverseScalar = typename InverseType::scalar_type;
133  using InverseLocalOrdinal = typename InverseType::local_ordinal_type;
134  using InverseGlobalOrdinal = typename InverseType::global_ordinal_type;
135  using InverseNode = typename InverseType::node_type;
136 
137  using typename ContainerImpl<MatrixType, InverseScalar>::block_crs_matrix_type;
138 
139  using inverse_mv_type = Tpetra::MultiVector<InverseScalar, InverseLocalOrdinal, InverseGlobalOrdinal, InverseNode>;
140  using InverseCrs = Tpetra::CrsMatrix<InverseScalar, InverseLocalOrdinal, InverseGlobalOrdinal, InverseNode>;
141  using InverseMap = typename Tpetra::Map<InverseLocalOrdinal, InverseGlobalOrdinal, InverseNode>;
142  using InverseGraph = typename InverseCrs::crs_graph_type;
143  using typename Container<MatrixType>::HostView;
144  using typename Container<MatrixType>::ConstHostView;
145  using HostViewInverse = typename inverse_mv_type::dual_view_type::t_host;
146 
147  static_assert(std::is_same<MatrixType,
148  Tpetra::RowMatrix<SC, LO, GO, NO>>::value, "Ifpack2::SparseContainer: Please use MatrixType = Tpetra::RowMatrix.");
149 
158  using typename Container<MatrixType>::row_matrix_type;
160 
161 public:
163 
164 
176  const Teuchos::Array<Teuchos::Array<LO> >& partitions,
177  const Teuchos::RCP<const import_type>& importer,
178  bool pointIndexed);
179 
181  virtual ~SparseContainer();
182 
184 
186 
188  virtual void setParameters(const Teuchos::ParameterList& List);
189 
191 
193 
195  virtual void initialize();
196 
198  virtual void compute ();
199 
203  void clearBlocks ();
204 
206  virtual void
207  apply (ConstHostView X,
208  HostView Y,
209  int blockIndex,
211  SC alpha = Teuchos::ScalarTraits<SC>::one(),
212  SC beta = Teuchos::ScalarTraits<SC>::zero()) const;
213 
215  virtual void
216  weightedApply (ConstHostView X,
217  HostView Y,
218  ConstHostView W,
219  int blockIndex,
221  SC alpha = Teuchos::ScalarTraits<SC>::one(),
222  SC beta = Teuchos::ScalarTraits<SC>::zero()) const;
223 
225 
227 
231  virtual std::ostream& print(std::ostream& os) const;
232 
234 
236 
238  virtual std::string description () const;
239 
241  virtual void
243  const Teuchos::EVerbosityLevel verbLevel =
246 
248  static std::string getName();
249 
250 private:
251 
254 
256  void extract ();
257  void extractGraph ();
258  void extractValues ();
259 
271  void
272  solveBlockMV(const inverse_mv_type& X,
273  inverse_mv_type& Y,
274  int blockIndex,
275  Teuchos::ETransp mode,
276  InverseScalar alpha,
277  InverseScalar beta) const;
278 
280  std::vector<Teuchos::RCP<InverseCrs>> diagBlocks_;
281 
283  mutable std::vector<inverse_mv_type> invX;
285  mutable std::vector<inverse_mv_type> invY;
286 
294  mutable Teuchos::Array<Teuchos::RCP<InverseType>> Inverses_;
297 
298 
301 };
302 
303 }// namespace Ifpack2
304 
305 #endif // IFPACK2_SPARSECONTAINER_HPP
static std::string getName()
Get the name of this container type for Details::constructContainer()
Definition: Ifpack2_SparseContainer_def.hpp:913
SparseContainer(const Teuchos::RCP< const row_matrix_type > &matrix, const Teuchos::Array< Teuchos::Array< LO > > &partitions, const Teuchos::RCP< const import_type > &importer, bool pointIndexed)
Constructor.
Definition: Ifpack2_SparseContainer_def.hpp:27
Store and solve a local sparse linear problem.
Definition: Ifpack2_SparseContainer_decl.hpp:101
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
The implementation of the numerical features of Container (Jacobi, Gauss-Seidel, SGS). This class allows a custom scalar type (LocalScalarType) to be used for storing blocks and solving the block systems. Hiding this template parameter from the Container interface simplifies the BlockRelaxation and ContainerFactory classes.
Definition: Ifpack2_Container_decl.hpp:310
virtual void initialize()
Do all set-up operations that only require matrix structure.
Definition: Ifpack2_SparseContainer_def.hpp:53
virtual std::ostream & print(std::ostream &os) const
Print information about this object to the given output stream.
Definition: Ifpack2_SparseContainer_def.hpp:421
Declaration and definition of the Ifpack2::Details::MultiVectorLocalGatherScatter class...
virtual std::string description() const
A one-line description of this object.
Definition: Ifpack2_SparseContainer_def.hpp:431
typename mv_type::dual_view_type::t_host HostView
Definition: Ifpack2_Container_decl.hpp:106
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:147
static const EVerbosityLevel verbLevel_default
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
virtual ~SparseContainer()
Destructor (declared virtual for memory safety of derived classes).
Definition: Ifpack2_SparseContainer_def.hpp:42
virtual void setParameters(const Teuchos::ParameterList &List)
Set all necessary parameters.
Definition: Ifpack2_SparseContainer_def.hpp:46
virtual void compute()
Initialize and compute all blocks.
Definition: Ifpack2_SparseContainer_def.hpp:85
Declaration of ILUT preconditioner.
void clearBlocks()
Definition: Ifpack2_SparseContainer_def.hpp:109