From ecb347d6333d5176a96c9209b00438b1cc48663d Mon Sep 17 00:00:00 2001 From: Chris Siefert Date: Mon, 10 Jun 2024 13:26:24 -0600 Subject: [PATCH] MueLu: CLANGgit push origin develop:csiefer-maxwell1-fix! --- .../src/Interface/MueLu_HierarchyManager.hpp | 13 +++---- .../MueLu_ParameterListInterpreter_def.hpp | 2 +- .../src/MueCentral/MueLu_Hierarchy_decl.hpp | 2 +- .../src/Operators/MueLu_Maxwell1_def.hpp | 37 +++++++------------ .../MueLu_RepartitionFactory_def.hpp | 8 ++-- .../MueLu_ReitzingerPFactory_def.hpp | 16 ++++---- packages/muelu/test/maxwell/Maxwell3D.cpp | 20 ++++------ 7 files changed, 40 insertions(+), 58 deletions(-) diff --git a/packages/muelu/src/Interface/MueLu_HierarchyManager.hpp b/packages/muelu/src/Interface/MueLu_HierarchyManager.hpp index fdc04a075acf..d90319f70cd7 100644 --- a/packages/muelu/src/Interface/MueLu_HierarchyManager.hpp +++ b/packages/muelu/src/Interface/MueLu_HierarchyManager.hpp @@ -213,7 +213,6 @@ class HierarchyManager : public HierarchyFactorysecond, iter->first); @@ -262,8 +261,8 @@ class HierarchyManager : public HierarchyFactory:: // Generic data keeping (this keeps the data on all levels) if (paramList.isParameter("keep data")) - this->dataToKeep_ = Teuchos::getArrayFromStringParameter(paramList, "keep data"); + this->dataToKeep_ = Teuchos::getArrayFromStringParameter(paramList, "keep data"); // Export level data if (paramList.isSublist("export data")) { diff --git a/packages/muelu/src/MueCentral/MueLu_Hierarchy_decl.hpp b/packages/muelu/src/MueCentral/MueLu_Hierarchy_decl.hpp index f2eb31d3aa5f..c24911c54cb4 100644 --- a/packages/muelu/src/MueCentral/MueLu_Hierarchy_decl.hpp +++ b/packages/muelu/src/MueCentral/MueLu_Hierarchy_decl.hpp @@ -171,8 +171,8 @@ class Hierarchy : public BaseClass { template friend class Hierarchy; - int LastLevelID() const { return Levels_.size() - 1; } + private: void DumpCurrentGraph(int level) const; diff --git a/packages/muelu/src/Operators/MueLu_Maxwell1_def.hpp b/packages/muelu/src/Operators/MueLu_Maxwell1_def.hpp index 434d8ab98115..2011098323a4 100644 --- a/packages/muelu/src/Operators/MueLu_Maxwell1_def.hpp +++ b/packages/muelu/src/Operators/MueLu_Maxwell1_def.hpp @@ -73,8 +73,6 @@ #include #include - - #ifdef HAVE_MUELU_CUDA #include "cuda_profiler_api.h" #endif @@ -146,14 +144,10 @@ void Maxwell1::setParameters(Teuchos: newList.set("maxwell1: nodal smoother fix zero diagonal threshold", 1e-10); newList.sublist("maxwell1: 22list").set("rap: fix zero diagonals", true); newList.sublist("maxwell1: 22list").set("rap: fix zero diagonals threshold", 1e-10); - + list = newList; } - - - - std::string mode_string = list.get("maxwell1: mode", MasterList::getDefault("maxwell1: mode")); applyBCsTo22_ = list.get("maxwell1: apply BCs to 22", false); dump_matrices_ = list.get("maxwell1: dump matrices", MasterList::getDefault("maxwell1: dump matrices")); @@ -276,7 +270,6 @@ void Maxwell1::compute(bool reuse) { ReitzingerPFactory to generate the edge P and A matrices. */ - #ifdef HAVE_MUELU_CUDA if (parameterList_.get("maxwell1: cuda profile setup", false)) cudaProfilerStart(); #endif @@ -321,14 +314,14 @@ void Maxwell1::compute(bool reuse) { that we need to keep the importers in sync too */ if (precList22_.isParameter("repartition: enable")) { bool repartition = precList22_.get("repartition: enable"); - precList11_.set("repartition: enable", repartition); - + precList11_.set("repartition: enable", repartition); + // If we're repartitioning (2,2), we need to rebalance for (1,1) to do the right thing, // as well as keep the importers if (repartition) { // FIXME: We should probably update rather than clobber - precList22_.set("repartition: save importer",true); - //precList22_.set("repartition: rebalance P and R", false); + precList22_.set("repartition: save importer", true); + // precList22_.set("repartition: rebalance P and R", false); precList22_.set("repartition: rebalance P and R", true); } @@ -400,7 +393,7 @@ void Maxwell1::compute(bool reuse) { } //////////////////////////////////////////////////////////////////////////////// - // Build (2,2) hierarchy + // Build (2,2) hierarchy Hierarchy22_ = MueLu::CreateXpetraPreconditioner(Kn_Matrix_, precList22_); //////////////////////////////////////////////////////////////////////////////// @@ -483,7 +476,7 @@ void Maxwell1::compute(bool reuse) { importer = NodeL->Get >("Importer"); EdgeL->Set("NodeImporter", importer); } - + // If we repartition a processor away, a RCP is stuck // on the level instead of an RCP if (!OldSmootherMatrix.is_null() && !NodalP_ones.is_null()) { @@ -502,7 +495,6 @@ void Maxwell1::compute(bool reuse) { RAPlist.set("rap: fix zero diagonals", false); RCP NewKn = Maxwell_Utils::PtAPWrapper(OldSmootherMatrix, NodalP_ones, RAPlist, labelstr); - // If there's an importer, we need to Rebalance the NewKn if (!importer.is_null()) { ParameterList rebAcParams; @@ -514,15 +506,14 @@ void Maxwell1::compute(bool reuse) { Level fLevel, cLevel; cLevel.SetPreviousLevel(Teuchos::rcpFromRef(fLevel)); - cLevel.Set("InPlaceMap",InPlaceMap); - cLevel.Set("A",NewKn); + cLevel.Set("InPlaceMap", InPlaceMap); + cLevel.Set("A", NewKn); cLevel.Request("A", newAfact.get()); - newAfact->Build(fLevel,cLevel); + newAfact->Build(fLevel, cLevel); NewKn = cLevel.Get >("A", newAfact.get()); EdgeL->Set("NodeMatrix", NewKn); - } - else { + } else { EdgeL->Set("NodeMatrix", NewKn); } @@ -551,7 +542,6 @@ void Maxwell1::compute(bool reuse) { } // end Hierarchy22 loop - //////////////////////////////////////////////////////////////////////////////// // Generating the (1,1) Hierarchy std::string fine_smoother = precList11_.get("smoother: type"); @@ -575,12 +565,11 @@ void Maxwell1::compute(bool reuse) { Hierarchy11_->SetProcRankVerbose(SM_Matrix_->getDomainMap()->getComm()->getRank()); // Stick the non-serializible data on the hierarchy and do setup - if(nonSerialList11.numParams() > 0) { + if (nonSerialList11.numParams() > 0) { HierarchyUtils::AddNonSerializableDataToHierarchy(*mueLuFactory, *Hierarchy11_, nonSerialList11); - } + } mueLuFactory->SetupHierarchy(*Hierarchy11_); - if (refmaxwellCoarseSolve) { GetOStream(Runtime0) << "Maxwell1::compute(): Setting up RefMaxwell coarse solver" << std::endl; auto coarseLvl = Hierarchy11_->GetLevel(Hierarchy11_->GetNumLevels() - 1); diff --git a/packages/muelu/src/Rebalancing/MueLu_RepartitionFactory_def.hpp b/packages/muelu/src/Rebalancing/MueLu_RepartitionFactory_def.hpp index 70346669e79e..b255e7a16838 100644 --- a/packages/muelu/src/Rebalancing/MueLu_RepartitionFactory_def.hpp +++ b/packages/muelu/src/Rebalancing/MueLu_RepartitionFactory_def.hpp @@ -103,7 +103,7 @@ template void RepartitionFactory::DeclareInput(Level& currentLevel) const { Input(currentLevel, "A"); Input(currentLevel, "number of partitions"); - Input(currentLevel, "Partition"); + Input(currentLevel, "Partition"); } template @@ -405,10 +405,10 @@ void RepartitionFactory::Build(Level& // Importer saving bool save_importer = pL.get("repartition: save importer"); - if(save_importer) { - currentLevel.Set("Importer",rowMapImporter,NoFactory::get()); + if (save_importer) { + currentLevel.Set("Importer", rowMapImporter, NoFactory::get()); currentLevel.AddKeepFlag("Importer", NoFactory::get(), MueLu::Final); - currentLevel.RemoveKeepFlag("Importer", NoFactory::get(), MueLu::UserData);//FIXME: This is a hack + currentLevel.RemoveKeepFlag("Importer", NoFactory::get(), MueLu::UserData); // FIXME: This is a hack } // ====================================================================================================== // Print some data diff --git a/packages/muelu/src/Transfers/Smoothed-Aggregation/MueLu_ReitzingerPFactory_def.hpp b/packages/muelu/src/Transfers/Smoothed-Aggregation/MueLu_ReitzingerPFactory_def.hpp index 165087df5073..63590a11cf81 100644 --- a/packages/muelu/src/Transfers/Smoothed-Aggregation/MueLu_ReitzingerPFactory_def.hpp +++ b/packages/muelu/src/Transfers/Smoothed-Aggregation/MueLu_ReitzingerPFactory_def.hpp @@ -298,16 +298,16 @@ void ReitzingerPFactory::BuildP(Level } // Exponential memory reallocation, if needed - if(current + 1 >= max_edges) { - max_edges*=2; + if (current + 1 >= max_edges) { + max_edges *= 2; D0_colind.resize(max_edges); - D0_values.resize(max_edges); + D0_values.resize(max_edges); } - if(current / 2 + 1 >= D0_rowptr.size()) { - D0_rowptr.resize(2*D0_rowptr.size()+1); + if (current / 2 + 1 >= D0_rowptr.size()) { + D0_rowptr.resize(2 * D0_rowptr.size() + 1); } - // NOTE: "i" here might not be a valid local column id, so we read it from the map + // NOTE: "i" here might not be a valid local column id, so we read it from the map D0_colind[current] = local_column_i; D0_values[current] = -1; current++; @@ -325,7 +325,7 @@ void ReitzingerPFactory::BuildP(Level D0_values.resize(current); // Handle empty ranks gracefully - if(num_coarse_edges == 0) { + if (num_coarse_edges == 0) { D0_rowptr[0] = 0; D0_rowptr[1] = 0; } @@ -430,7 +430,7 @@ void ReitzingerPFactory::BuildP(Level // TODO: Something like this *might* work. But this specifically, doesn't // Pe = XMM::Multiply(*D0_Pn_nonghosted,false,*D0_coarse_m,true,dummy,out0,true,true,"(D0*Pn)*D0c'",mm_params); } - + /* Weed out the +/- entries, shrinking the matrix as we go */ { SubFactoryMonitor m2(*this, "Generate Pe (post-fix)", coarseLevel); diff --git a/packages/muelu/test/maxwell/Maxwell3D.cpp b/packages/muelu/test/maxwell/Maxwell3D.cpp index 0d31732153d8..e7e9e0977e8f 100644 --- a/packages/muelu/test/maxwell/Maxwell3D.cpp +++ b/packages/muelu/test/maxwell/Maxwell3D.cpp @@ -553,8 +553,6 @@ int main_(Teuchos::CommandLineProcessor& clp, Xpetra::UnderlyingLib lib, int arg clp.setOption("ensure-kn", "no-ensure-kn", &ensure_kn, "generate a kn matrix if the user doesn't provide one"); - - std::string S_file, D0_file, M1_file, M0_file; if (!Teuchos::ScalarTraits::isComplex) { S_file = "S.mat"; @@ -593,8 +591,7 @@ int main_(Teuchos::CommandLineProcessor& clp, Xpetra::UnderlyingLib lib, int arg clp.setOption("x0", &x0_file); std::string GmhdA_file = ""; clp.setOption("GmhdA", &GmhdA_file); - - + clp.recogniseAllOptions(true); switch (clp.parse(argc, argv)) { case Teuchos::CommandLineProcessor::PARSE_HELP_PRINTED: return EXIT_SUCCESS; @@ -689,20 +686,17 @@ int main_(Teuchos::CommandLineProcessor& clp, Xpetra::UnderlyingLib lib, int arg else Ms_Matrix = M1_Matrix; if (Kn_file != "") { - *out<<"User provided Kn matrix"<::Read(Kn_file, node_map); - } - else if(ensure_kn) { + } else if (ensure_kn) { // The user requested we generate Kn_Matrix with an SpGEMM Teuchos::ParameterList params; - *out<<"Making Kn Matrix as requested by yser"<::PtAPWrapper(SM_Matrix,D0_Matrix,params,"User Kn"); - } - else { - *out<<"NOT using a Kn matrix"<::PtAPWrapper(SM_Matrix, D0_Matrix, params, "User Kn"); + } else { + *out << "NOT using a Kn matrix" << std::endl; } - if ((M0inv_file == "") && (M0_file != "")) { // nodal mass matrix RCP M0_Matrix = Xpetra::IO::Read(M0_file, node_map);