8 #ifndef PACKAGES_MUELU_ADAPTERS_XPETRA_MUELU_CREATEXPETRAPRECONDITIONER_HPP_ 9 #define PACKAGES_MUELU_ADAPTERS_XPETRA_MUELU_CREATEXPETRAPRECONDITIONER_HPP_ 14 #include <Teuchos_XMLParameterListHelpers.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> 41 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
42 Teuchos::RCP<MueLu::Hierarchy<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
44 const Teuchos::ParameterList& inParamList,
45 Teuchos::RCP<Xpetra::MultiVector<double, LocalOrdinal, GlobalOrdinal, Node> > coords = Teuchos::null,
46 Teuchos::RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> > nullspace = Teuchos::null) {
53 std::string timerName =
"MueLu setup time";
54 RCP<Teuchos::Time> tm = Teuchos::TimeMonitor::getNewTimer(timerName);
57 bool hasParamList = inParamList.numParams();
59 RCP<HierarchyManager> mueLuFactory;
62 Teuchos::ParameterList nonSerialList,paramList;
65 std::string syntaxStr =
"parameterlist: syntax";
66 if (hasParamList && paramList.isParameter(syntaxStr) && paramList.get<std::string>(syntaxStr) ==
"ml") {
67 paramList.remove(syntaxStr);
75 if (hasParamList && paramList.isParameter(
"hierarchy label")) {
76 label = paramList.get<std::string>(
"hierarchy label");
77 paramList.remove(
"hierarchy label");
79 label = op->getObjectLabel();
80 RCP<Hierarchy> H = mueLuFactory->CreateHierarchy(label);
81 H->setlib(op->getDomainMap()->lib());
87 H->GetLevel(0)->Set(
"A", op);
90 if (coords != Teuchos::null)
91 H->GetLevel(0)->Set(
"Coordinates", coords);
94 if (nullspace != Teuchos::null)
95 H->GetLevel(0)->Set(
"Nullspace", nullspace);
97 mueLuFactory->SetupHierarchy(*H);
100 tm->incrementNumCalls();
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;
108 Teuchos::TimeMonitor::summarize(op->getRowMap()->getComm().ptr(), std::cout, alwaysWriteLocal, writeGlobalStats,
109 writeZeroTimers, Teuchos::Union, filter, ignoreZeroTimers);
117 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
118 Teuchos::RCP<MueLu::Hierarchy<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
120 const Teuchos::ParameterList& inParamList,
121 const Teuchos::ParameterList& dummy) {
128 std::string timerName =
"MueLu setup time";
129 RCP<Teuchos::Time> tm = Teuchos::TimeMonitor::getNewTimer(timerName);
132 bool hasParamList = inParamList.numParams();
134 RCP<HierarchyManager> mueLuFactory;
137 Teuchos::ParameterList nonSerialList,paramList;
140 std::string syntaxStr =
"parameterlist: syntax";
141 if (hasParamList && paramList.isParameter(syntaxStr) && paramList.get<std::string>(syntaxStr) ==
"ml") {
142 paramList.remove(syntaxStr);
149 RCP<Hierarchy> H = mueLuFactory->CreateHierarchy();
150 H->setlib(op->getDomainMap()->lib());
156 H->GetLevel(0)->Set(
"A", op);
158 mueLuFactory->SetupHierarchy(*H);
161 tm->incrementNumCalls();
164 const bool alwaysWriteLocal =
true;
165 const bool writeGlobalStats =
true;
166 const bool writeZeroTimers =
false;
167 const bool ignoreZeroTimers =
true;
168 const std::string filter = timerName;
169 Teuchos::TimeMonitor::summarize(op->getRowMap()->getComm().ptr(), std::cout, alwaysWriteLocal, writeGlobalStats,
170 writeZeroTimers, Teuchos::Union, filter, ignoreZeroTimers);
185 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
188 std::string timerName =
"MueLu setup time";
189 RCP<Teuchos::Time> tm = Teuchos::TimeMonitor::getNewTimer(timerName);
193 typedef LocalOrdinal LO;
194 typedef GlobalOrdinal GO;
197 typedef Xpetra::Matrix<SC,LO,GO,NO> Matrix;
198 typedef Xpetra::Operator<SC,LO,GO,NO> Operator;
201 "MueLu::ReuseXpetraPreconditioner: Hierarchy has no levels in it");
203 "MueLu::ReuseXpetraPreconditioner: Hierarchy has no fine level operator");
204 RCP<Level> level0 = H->GetLevel(0);
206 RCP<Operator> O0 = level0->Get<RCP<Operator> >(
"A");
207 RCP<Matrix> A0 = Teuchos::rcp_dynamic_cast<Matrix>(O0);
213 A->SetFixedBlockSize(A0->GetFixedBlockSize());
220 tm->incrementNumCalls();
223 const bool alwaysWriteLocal =
true;
224 const bool writeGlobalStats =
true;
225 const bool writeZeroTimers =
false;
226 const bool ignoreZeroTimers =
true;
227 const std::string filter = timerName;
228 Teuchos::TimeMonitor::summarize(A->getRowMap()->getComm().ptr(), std::cout, alwaysWriteLocal, writeGlobalStats,
229 writeZeroTimers, Teuchos::Union, filter, ignoreZeroTimers);
237 #define XPETRA_CREATEXPETRAPRECONDITIONER_SHORT 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.
static void AddNonSerializableDataToHierarchy(HierarchyManager &HM, Hierarchy &H, const ParameterList &nonSerialList)
Teuchos::RCP< MueLu::Hierarchy< Scalar, LocalOrdinal, GlobalOrdinal, Node > > CreateXpetraPreconditioner(Teuchos::RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > op, const Teuchos::ParameterList &inParamList, Teuchos::RCP< Xpetra::MultiVector< double, LocalOrdinal, GlobalOrdinal, Node > > coords=Teuchos::null, Teuchos::RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > nullspace=Teuchos::null)
Helper function to create a MueLu preconditioner that can be used by Xpetra.Given an Xpetra::Matrix...
Namespace for MueLu classes and methods.
Print statistics that do not involve significant additional computation.
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.
Provides methods to build a multigrid hierarchy and apply multigrid cycles.
long ExtractNonSerializableData(const Teuchos::ParameterList &inList, Teuchos::ParameterList &serialList, Teuchos::ParameterList &nonSerialList)