8 #ifndef PACKAGES_MUELU_ADAPTERS_XPETRA_MUELU_CREATEXPETRAPRECONDITIONER_HPP_
9 #define PACKAGES_MUELU_ADAPTERS_XPETRA_MUELU_CREATEXPETRAPRECONDITIONER_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>
45 using LO = LocalOrdinal;
46 using GO = GlobalOrdinal;
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";
169 typedef LocalOrdinal
LO;
170 typedef GlobalOrdinal
GO;
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);
212 #ifdef HAVE_MUELU_DEPRECATED_CODE
224 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
234 userParamList.
set<RCP<Xpetra::MultiVector<typename Teuchos::ScalarTraits<Scalar>::coordinateType, LocalOrdinal, GlobalOrdinal, Node> > >(
"Coordinates", coords);
237 userParamList.
set<RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> > >(
"Nullspace", nullspace);
253 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
263 userParamList.
set<RCP<Xpetra::MultiVector<typename Teuchos::ScalarTraits<Scalar>::coordinateType, LocalOrdinal, GlobalOrdinal, Node> > >(
"Coordinates", coords);
268 #endif // HAVE_MUELU_DEPRECATED_CODE
272 #define XPETRA_CREATEXPETRAPRECONDITIONER_SHORT
RCP< Level > & GetLevel(const int levelID=0)
Retrieve a certain level from hierarchy.
static void AddNonSerializableDataToHierarchy(HierarchyManager &HM, Hierarchy &H, const ParameterList &nonSerialList)
T & get(const std::string &name, T def_value)
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
bool nonnull(const std::shared_ptr< T > &p)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Ordinal numParams() const
static RCP< Time > getNewTimer(const std::string &name)
bool isParameter(const std::string &name) const
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)
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.
VerbLevel GetVerbLevel() const
Get the verbosity level.
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...
Class that accepts ML-style parameters and builds a MueLu preconditioner. This interpreter uses the s...
int SetProcRankVerbose(int procRank) const
Set proc rank used for printing.
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
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)
virtual void SetupHierarchy(Hierarchy &H) const
Setup Hierarchy object.