MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_MueLuPreconditionerFactory_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // MueLu: A package for multigrid based preconditioning
4 //
5 // Copyright 2012 NTESS and the MueLu contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef THYRA_MUELU_PRECONDITIONER_FACTORY_DECL_HPP
11 #define THYRA_MUELU_PRECONDITIONER_FACTORY_DECL_HPP
12 
13 #include <MueLu_ConfigDefs.hpp>
14 
15 #if defined(HAVE_MUELU_STRATIMIKOS) && defined(HAVE_MUELU_THYRA)
16 
17 // Stratimikos needs Thyra, so we don't need special guards for Thyra here
18 #include "Thyra_DefaultPreconditioner.hpp"
19 #include "Thyra_BlockedLinearOpBase.hpp"
20 #include "Thyra_DiagonalLinearOpBase.hpp"
21 #include "Thyra_XpetraLinearOp.hpp"
22 #include "Thyra_TpetraLinearOp.hpp"
23 #include "Thyra_TpetraThyraWrappers.hpp"
24 #ifdef HAVE_MUELU_EPETRA
25 #include "Thyra_EpetraLinearOp.hpp"
26 #endif
27 
28 #include "Teuchos_Ptr.hpp"
30 #include "Teuchos_Assert.hpp"
31 #include "Teuchos_Time.hpp"
32 
33 #include <Xpetra_CrsMatrixWrap.hpp>
34 #include <Xpetra_CrsMatrix.hpp>
35 #include <Xpetra_Matrix.hpp>
36 #include <Xpetra_ThyraUtils.hpp>
37 
38 #include <MueLu_Hierarchy.hpp>
40 #include <MueLu_HierarchyUtils.hpp>
41 #include <MueLu_Utilities.hpp>
42 #include <MueLu_ParameterListInterpreter.hpp>
43 #include <MueLu_MasterList.hpp>
44 #include <MueLu_XpetraOperator_decl.hpp> // todo fix me
46 #include <MueLu_TpetraOperator.hpp>
47 #include <Xpetra_TpetraHalfPrecisionOperator.hpp>
48 #ifdef HAVE_MUELU_EPETRA
49 #include <MueLu_EpetraOperator.hpp>
50 #endif
51 
52 #include "Thyra_PreconditionerFactoryBase.hpp"
53 
54 #include <Tpetra_KokkosCompat_DefaultNode.hpp>
55 
56 #include <list>
57 
58 namespace Thyra {
59 
60 using Teuchos::RCP;
61 using Teuchos::rcp;
62 
63 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
64 struct Converters {
65  static bool replaceWithXpetra(ParameterList& paramList, std::string parameterName);
66 };
67 
68 #ifdef HAVE_MUELU_EPETRA
69 template <class GlobalOrdinal>
70 struct Converters<double, int, GlobalOrdinal, Tpetra::KokkosCompat::KokkosSerialWrapperNode> {
71  static bool replaceWithXpetra(ParameterList& paramList, std::string parameterName);
72 };
73 #endif
74 
80 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>
81 class MueLuPreconditionerFactory : public PreconditionerFactoryBase<Scalar> {
82  public:
85 
87  MueLuPreconditionerFactory();
88 
89  ~MueLuPreconditionerFactory();
91 
94 
96  bool isCompatible(const LinearOpSourceBase<Scalar>& fwdOp) const;
98  Teuchos::RCP<PreconditionerBase<Scalar> > createPrec() const;
100  void initializePrec(const Teuchos::RCP<const LinearOpSourceBase<Scalar> >& fwdOp,
101  PreconditionerBase<Scalar>* prec,
102  const ESupportSolveUse supportSolveUse) const;
104  void uninitializePrec(PreconditionerBase<Scalar>* prec,
105  Teuchos::RCP<const LinearOpSourceBase<Scalar> >* fwdOp,
106  ESupportSolveUse* supportSolveUse) const;
107 
109 
112 
114  void setParameterList(const Teuchos::RCP<Teuchos::ParameterList>& paramList);
116  Teuchos::RCP<Teuchos::ParameterList> unsetParameterList();
118  Teuchos::RCP<Teuchos::ParameterList> getNonconstParameterList();
120  Teuchos::RCP<const Teuchos::ParameterList> getParameterList() const;
124 
127 
129  std::string description() const;
130 
131  // ToDo: Add an override of describe(...) to give more detail!
132 
134 
135  private:
136  // Teuchos::RCP<MueLu::Hierarchy<Scalar,LocalOrdinal,GlobalOrdinal,Node> > CreateXpetraPreconditioner(Teuchos::RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > op, const Teuchos::ParameterList& paramList, Teuchos::RCP<Xpetra::MultiVector<typename Teuchos::ScalarTraits<Scalar>::magnitudeType, LocalOrdinal, GlobalOrdinal, Node> > coords, Teuchos::RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> > nullspace) const;
137 
139 };
140 
141 } // namespace Thyra
142 
143 #endif // #ifdef HAVE_MUELU_STRATIMIKOS
144 
145 #endif // THYRA_MUELU_PRECONDITIONER_FACTORY_DECL_HPP
Various adapters that will create a MueLu preconditioner that is an Xpetra::Matrix.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
MueLu::DefaultGlobalOrdinal GlobalOrdinal
void getValidParameters(Teuchos::ParameterList &params)