8 #ifndef PACKAGES_MUELU_ADAPTERS_XPETRA_MUELU_CREATEXPETRAPRECONDITIONER_HPP_
9 #define PACKAGES_MUELU_ADAPTERS_XPETRA_MUELU_CREATEXPETRAPRECONDITIONER_HPP_
15 #include <Xpetra_CrsMatrix.hpp>
16 #include <Xpetra_MultiVector.hpp>
21 #include <MueLu_Hierarchy.hpp>
23 #include <MueLu_MLParameterListInterpreter.hpp>
24 #include <MueLu_ParameterListInterpreter.hpp>
25 #include <MueLu_Utilities.hpp>
26 #include <MueLu_HierarchyUtils.hpp>
40 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
55 bool hasParamList = inParamList.
numParams();
64 if (hasParamList && paramList.
isParameter(
"hierarchy label")) {
65 label = paramList.
get<std::string>(
"hierarchy label");
66 paramList.
remove(
"hierarchy label");
68 label = op->getObjectLabel();
70 std::string timerName;
72 timerName =
"MueLu setup time (" + label +
")";
74 timerName =
"MueLu setup time";
78 std::string syntaxStr =
"parameterlist: syntax";
79 if (hasParamList && paramList.
isParameter(syntaxStr) && paramList.
get<std::string>(syntaxStr) ==
"ml") {
80 paramList.
remove(syntaxStr);
88 H->
setlib(op->getDomainMap()->lib());
103 const bool alwaysWriteLocal =
true;
104 const bool writeGlobalStats =
true;
105 const bool writeZeroTimers =
false;
106 const bool ignoreZeroTimers =
true;
107 const std::string filter = timerName;
109 writeZeroTimers, Teuchos::Union, filter, ignoreZeroTimers);
125 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
128 const std::string& xmlFileName) {
131 return CreateXpetraPreconditioner<Scalar, LocalOrdinal, GlobalOrdinal, Node>(op, paramList);
141 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
145 return CreateXpetraPreconditioner<Scalar, LocalOrdinal, GlobalOrdinal, Node>(op, paramList);
155 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
158 std::string label = H->GetLevel(0)->getObjectLabel();
160 std::string timerName;
162 timerName =
"MueLu setup time (" + label +
")";
164 timerName =
"MueLu setup time";
173 typedef Xpetra::Matrix<SC,LO,GO,NO> Matrix;
174 typedef Xpetra::Operator<SC,LO,GO,NO> Operator;
177 "MueLu::ReuseXpetraPreconditioner: Hierarchy has no levels in it");
179 "MueLu::ReuseXpetraPreconditioner: Hierarchy has no fine level operator");
183 RCP<Matrix> A0 = Teuchos::rcp_dynamic_cast<Matrix>(O0);
189 A->SetFixedBlockSize(A0->GetFixedBlockSize());
199 const bool alwaysWriteLocal =
true;
200 const bool writeGlobalStats =
true;
201 const bool writeZeroTimers =
false;
202 const bool ignoreZeroTimers =
true;
203 const std::string filter = timerName;
205 writeZeroTimers, Teuchos::Union, filter, ignoreZeroTimers);
215 #define XPETRA_CREATEXPETRAPRECONDITIONER_SHORT
MueLu::DefaultLocalOrdinal LocalOrdinal
RCP< Level > & GetLevel(const int levelID=0)
Retrieve a certain level from hierarchy.
static void AddNonSerializableDataToHierarchy(HierarchyManager &HM, Hierarchy &H, const ParameterList &nonSerialList)
Add non-serializable data to Hierarchy.
T & get(const std::string &name, T def_value)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Ordinal numParams() const
static RCP< Time > getNewTimer(const std::string &name)
int SetProcRankVerbose(int procRank) const
Set proc rank used for printing.
bool isParameter(const std::string &name) const
VerbLevel GetVerbLevel() const
Get the verbosity level.
Print statistics that do not involve significant additional computation.
bool remove(std::string const &name, bool throwIfNotExists=true)
void start(bool reset=false)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
MueLu::DefaultScalar Scalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
static void summarize(Ptr< const Comm< int > > comm, std::ostream &out=std::cout, const bool alwaysWriteLocal=false, const bool writeGlobalStats=true, const bool writeZeroTimers=true, const ECounterSetOp setOp=Intersection, const std::string &filter="", const bool ignoreZeroTimers=false)
void ReuseXpetraPreconditioner(const Teuchos::RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &A, Teuchos::RCP< MueLu::Hierarchy< Scalar, LocalOrdinal, GlobalOrdinal, Node >> &H)
Helper function to reuse an existing MueLu preconditioner.
Teuchos::RCP< MueLu::Hierarchy< Scalar, LocalOrdinal, GlobalOrdinal, Node > > CreateXpetraPreconditioner(Teuchos::RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > op, const Teuchos::ParameterList &inParamList)
Helper function to create a MueLu preconditioner that can be used by Xpetra.Given an Xpetra::Matrix...
Teuchos::FancyOStream & GetOStream(MsgType type, int thisProcRankOnly=0) const
Get an output stream for outputting the input message type.
Class that accepts ML-style parameters and builds a MueLu preconditioner. This interpreter uses the s...
Exception throws to report errors in the internal logical of the program.
void setlib(Xpetra::UnderlyingLib inlib)
virtual RCP< Hierarchy > CreateHierarchy() const
Create an empty Hierarchy object.
Provides methods to build a multigrid hierarchy and apply multigrid cycles.
long ExtractNonSerializableData(const Teuchos::ParameterList &inList, Teuchos::ParameterList &serialList, Teuchos::ParameterList &nonSerialList)
Extract non-serializable data from level-specific sublists and move it to a separate parameter list...
virtual void SetupHierarchy(Hierarchy &H) const
Setup Hierarchy object.