44Teuchos::RCP<MueLu::Hierarchy<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
46 const Teuchos::ParameterList& inParamList) {
57 bool hasParamList = inParamList.numParams();
59 RCP<HierarchyManager> mueLuFactory;
62 Teuchos::ParameterList nonSerialList, paramList;
66 if (hasParamList && paramList.isParameter(
"hierarchy label")) {
67 label = paramList.get<std::string>(
"hierarchy label");
69 label = op->getObjectLabel();
71 RCP<Teuchos::Time> tm;
72 std::string timerName;
75 if (paramList.isSublist(
"kokkos tuning: muelu parameter mapping") &&
76 paramList.sublist(
"kokkos tuning: muelu parameter mapping").isParameter(
"kokkos context id")) {
79 timerName =
"MueLu tuning time (" + label +
")";
81 timerName =
"MueLu tuning time";
82 tm = Teuchos::TimeMonitor::getNewTimer(timerName);
89 tm->incrementNumCalls();
95 timerName =
"MueLu setup time (" + label +
")";
97 timerName =
"MueLu setup time";
99 tm = Teuchos::TimeMonitor::getNewTimer(timerName);
102 std::string syntaxStr =
"parameterlist: syntax";
103 if (hasParamList && paramList.isParameter(syntaxStr) && paramList.get<std::string>(syntaxStr) ==
"ml") {
104 paramList.remove(syntaxStr);
106 paramList = *Teuchos::getParametersFromXmlString(paramXML);
109 bool Minv_Supplied =
false, M_Supplied =
false, MinvA_Supplied =
false;
110 if (inParamList.isSublist(
"user data")) {
111 const Teuchos::ParameterList& userList = inParamList.sublist(
"user data");
112 if (userList.isParameter(
"M")) M_Supplied =
true;
113 if (userList.isParameter(
"Minv")) Minv_Supplied =
true;
114 if (userList.isParameter(
"MinvA")) Minv_Supplied =
true;
116 if (inParamList.isParameter(
"aggregation: strength-of-connection: matrix") && (inParamList.get<std::string>(
"aggregation: strength-of-connection: matrix") ==
"MinvA")) {
117 if (inParamList.isSublist(
"project auxiliary matrices")) {
118 auto projectList = inParamList.sublist(
"project auxiliary matrices");
119 TEUCHOS_TEST_FOR_EXCEPTION(projectList.isParameter(
"M") && !M_Supplied,
Exceptions::Incompatible,
"MueLu_CreateXpetraPreconditioner: Must supply M as it is listed in the project auxiliary matrices sublist");
120 TEUCHOS_TEST_FOR_EXCEPTION(projectList.isParameter(
"Minv") && (projectList.get(
"Minv",
"") ==
"NoFactory") && !Minv_Supplied,
Exceptions::Incompatible,
121 "MueLu_CreateXpetraPreconditioner: Must supply Minv as NoFactory is listed as supplier of Minv in the project auxiliary matrices sublist");
122 TEUCHOS_TEST_FOR_EXCEPTION(projectList.isParameter(
"MinvA") && (projectList.get(
"MinvA",
"") ==
"NoFactory") && !MinvA_Supplied,
Exceptions::Incompatible,
123 "MueLu_CreateXpetraPreconditioner: Must supply MinvA as NoFactory is listed as supplier of MinvA in the project auxiliary matrices sublist");
125 TEUCHOS_TEST_FOR_EXCEPTION(!M_Supplied,
Exceptions::Incompatible,
"MueLu_CreateXpetraPreconditioner: Must supply M when 'aggregation: strength-of-connection: matrix'= MinvA and sublist('project auxiliary matrices') not supplied.");
132 RCP<Hierarchy> H = mueLuFactory->CreateHierarchy(label);
133 H->setlib(op->getDomainMap()->lib());
136 H->GetLevel(0)->Set(
"A", op);
137 H->SetProcRankVerbose(op->getDomainMap()->getComm()->getRank());
142 mueLuFactory->SetupHierarchy(*H);
145 tm->incrementNumCalls();
148 const bool alwaysWriteLocal =
true;
149 const bool writeGlobalStats =
true;
150 const bool writeZeroTimers =
false;
151 const bool ignoreZeroTimers =
true;
152 const std::string filter = timerName;
153 Teuchos::TimeMonitor::summarize(op->getRowMap()->getComm().ptr(), H->GetOStream(
Statistics0), alwaysWriteLocal, writeGlobalStats,
154 writeZeroTimers, Teuchos::Union, filter, ignoreZeroTimers);
171Teuchos::RCP<MueLu::Hierarchy<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
173 const std::string& xmlFileName) {
174 Teuchos::ParameterList paramList;
175 Teuchos::updateParametersFromXmlFileAndBroadcast(xmlFileName, Teuchos::Ptr<Teuchos::ParameterList>(¶mList), *op->getDomainMap()->getComm());
176 return CreateXpetraPreconditioner<Scalar, LocalOrdinal, GlobalOrdinal, Node>(op, paramList);
187Teuchos::RCP<MueLu::Hierarchy<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
189 Teuchos::ParameterList paramList;
190 return CreateXpetraPreconditioner<Scalar, LocalOrdinal, GlobalOrdinal, Node>(op, paramList);
203 std::string label = H->GetLevel(0)->getObjectLabel();
205 std::string timerName;
207 timerName =
"MueLu setup time (" + label +
")";
209 timerName =
"MueLu setup time";
210 RCP<Teuchos::Time> tm = Teuchos::TimeMonitor::getNewTimer(timerName);
218 typedef Xpetra::Matrix<SC, LO, GO, NO> Matrix;
219 typedef Xpetra::Operator<SC, LO, GO, NO> Operator;
222 "MueLu::ReuseXpetraPreconditioner: Hierarchy has no levels in it");
224 "MueLu::ReuseXpetraPreconditioner: Hierarchy has no fine level operator");
225 RCP<Level> level0 = H->GetLevel(0);
227 RCP<Operator> O0 = level0->Get<RCP<Operator>>(
"A");
228 RCP<Matrix> A0 = Teuchos::rcp_dynamic_cast<Matrix>(O0);
234 A->SetFixedBlockSize(A0->GetFixedBlockSize());
241 tm->incrementNumCalls();
244 const bool alwaysWriteLocal =
true;
245 const bool writeGlobalStats =
true;
246 const bool writeZeroTimers =
false;
247 const bool ignoreZeroTimers =
true;
248 const std::string filter = timerName;
249 Teuchos::TimeMonitor::summarize(A->getRowMap()->getComm().ptr(), H->GetOStream(
Statistics0), alwaysWriteLocal, writeGlobalStats,
250 writeZeroTimers, Teuchos::Union, filter, ignoreZeroTimers);
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.
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,...