56 list.set(
"multigrid algorithm",
"combine");
57 list.set(
"combine: numBlks", nBlks_);
60 std::string verbosity = list.get(
"verbosity",
"high");
63 arrayOfParamLists_.resize(nBlks_);
64 for (
int i = 0; i < nBlks_; i++) {
65 std::string listName =
"subblockList" + Teuchos::toString(i);
66 if (list.isSublist(listName)) {
67 arrayOfParamLists_[i] = Teuchos::rcpFromRef(list.sublist(listName));
71 arrayOfParamLists_[i]->set(
"verbosity", arrayOfParamLists_[i]->get(
"verbosity", verbosity));
72 if (OmitSubblockSmoother_) {
73 arrayOfParamLists_[i]->set(
"smoother: pre or post",
"none");
74 arrayOfParamLists_[i]->set(
"smoother: type",
"none");
79 useKokkos_ = !Node::is_serial;
80 useKokkos_ = list.get(
"use kokkos refactor", useKokkos_);
82 paramListMultiphysics_ = Teuchos::rcpFromRef(list);
98 std::string timerLabel;
100 timerLabel =
"MueLu MultiPhys: compute (reuse)";
102 timerLabel =
"MueLu MultiPhys: compute";
103 RCP<Teuchos::TimeMonitor> tmCompute = getTimer(timerLabel);
108 for (
int iii = 0; iii < nBlks_; iii++) {
109 if (arrayOfCoords_ != Teuchos::null) {
110 if (arrayOfCoords_[iii] != Teuchos::null) {
111 arrayOfParamLists_[iii]->sublist(
"user data").set(
"Coordinates", arrayOfCoords_[iii]);
115 if (arrayOfMaterials_ != Teuchos::null) {
116 if (arrayOfMaterials_[iii] != Teuchos::null) {
117 arrayOfParamLists_[iii]->sublist(
"user data").set(
"Material", arrayOfMaterials_[iii]);
121 bool wantToRepartition =
false;
122 if (paramListMultiphysics_->isParameter(
"repartition: enable"))
123 wantToRepartition = paramListMultiphysics_->get<
bool>(
"repartition: enable");
125 arrayOfParamLists_[iii]->set(
"repartition: enable", wantToRepartition);
126 arrayOfParamLists_[iii]->set(
"repartition: rebalance P and R",
true);
127 arrayOfParamLists_[iii]->set(
"repartition: explicit via new copy rebalance P and R",
true);
129 if (paramListMultiphysics_->isParameter(
"repartition: use subcommunicators"))
130 arrayOfParamLists_[iii]->set(
"repartition: use subcommunicators", paramListMultiphysics_->isParameter(
"repartition: use subcommunicators"));
132 arrayOfParamLists_[iii]->set(
"repartition: use subcommunicators",
true);
137 paramListMultiphysics_->set<
bool>(
"repartition: enable",
false);
139 bool useMaxLevels =
false;
140 if (paramListMultiphysics_->isParameter(
"combine: useMaxLevels"))
141 useMaxLevels = paramListMultiphysics_->get<
bool>(
"combine: useMaxLevels");
143 LO maxLevels = useMaxLevels ? 0 : std::numeric_limits<LO>::max();
144 for (
int i = 0; i < nBlks_; i++) {
145 std::string operatorLabel =
"MultiPhys (" + Teuchos::toString(i) +
"," + Teuchos::toString(i) +
")";
146 arrayOfAuxMatrices_[i]->setObjectLabel(operatorLabel);
148 LO tempNlevels = arrayOfHierarchies_[i]->GetGlobalNumLevels();
150 if (tempNlevels > maxLevels) maxLevels = tempNlevels;
152 if (tempNlevels < maxLevels) maxLevels = tempNlevels;
156 hierarchyMultiphysics_ = rcp(
new Hierarchy(
"Combo"));
157 for (LO i = 0; i < maxLevels; i++) {
158 hierarchyMultiphysics_->AddNewLevel();
160 for (
int i = 0; i < nBlks_; i++) {
161 std::string subblkName =
"Psubblock" + Teuchos::toString(i);
164 std::string subblkOpName =
"Operatorsubblock" + Teuchos::toString(i);
169 const auto numLevelsBlk = arrayOfHierarchies_[i]->GetNumLevels();
170 const auto numGlobalLevelsBlk = arrayOfHierarchies_[i]->GetGlobalNumLevels();
171 if (numLevelsBlk == numGlobalLevelsBlk) {
172 auto crsLevel = arrayOfHierarchies_[i]->GetLevel(numLevelsBlk - 1);
173 TEUCHOS_ASSERT(crsLevel->IsAvailable(
"A"));
174 for (
int levelId = numLevelsBlk; levelId < maxLevels; ++levelId) {
175 auto level = hierarchyMultiphysics_->GetLevel(levelId);
181 paramListMultiphysics_->set(
"coarse: max size", 1);
182 paramListMultiphysics_->set(
"max levels", maxLevels);
184 AmatMultiphysics_->setObjectLabel(
"A: block " + Teuchos::toString(nBlks_) +
" x " + Teuchos::toString(nBlks_) +
"multiphysics matrix");
187 Teuchos::ParameterList nonSerialListMultiphysics, processedListMultiphysics;
192 Teuchos::ParameterList stripped;
193 for (ParameterList::ConstIterator inListEntry = processedListMultiphysics.begin(); inListEntry != processedListMultiphysics.end(); inListEntry++) {
194 const std::string& levelName = inListEntry->first;
195 if (levelName.find(
"subblockList") != 0) stripped.setEntry(inListEntry->first, inListEntry->second);
199 hierarchyMultiphysics_->setlib(AmatMultiphysics_->getDomainMap()->lib());
200 hierarchyMultiphysics_->SetProcRankVerbose(AmatMultiphysics_->getDomainMap()->getComm()->getRank());
203 hierarchyMultiphysics_->GetLevel(0)->Set(
"A", AmatMultiphysics_);
208 mueLuFactory->SetupHierarchy(*hierarchyMultiphysics_);
278 describe(Teuchos::FancyOStream& out,
const Teuchos::EVerbosityLevel )
const {
279 std::ostringstream oss;
281 RCP<const Teuchos::Comm<int>> comm = AmatMultiphysics_->getDomainMap()->getComm();
283 oss <<
"\n--------------------------------------------------------------------------------\n"
284 <<
"--- MultiPhysics Summary ---\n"
285 "--------------------------------------------------------------------------------"
292 AmatMultiphysics_->getRowMap()->getComm()->barrier();
294 for (
int i = 0; i < nBlks_; i++) {
295 numRows = arrayOfAuxMatrices_[i]->getGlobalNumRows();
296 nnz = arrayOfAuxMatrices_[i]->getGlobalNumEntries();
297 Xpetra::global_size_t tt = numRows;
310 oss <<
"block " << std::setw(rowspacer) <<
" rows " << std::setw(nnzspacer) <<
" nnz " << std::setw(9) <<
" nnz/row" << std::endl;
311 oss <<
"(" << Teuchos::toString(i) <<
", " << Teuchos::toString(i) <<
")" << std::setw(rowspacer) << numRows << std::setw(nnzspacer) << nnz << std::setw(9) << as<double>(nnz) / numRows << std::endl;
317 for (
int i = 0; i < nBlks_; i++) {
318 arrayOfHierarchies_[i]->describe(out, GetVerbLevel());
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,...