diff --git a/packages/muelu/src/Interface/MueLu_HierarchyManager.hpp b/packages/muelu/src/Interface/MueLu_HierarchyManager.hpp index 1788597532fb..5dff78fb9775 100644 --- a/packages/muelu/src/Interface/MueLu_HierarchyManager.hpp +++ b/packages/muelu/src/Interface/MueLu_HierarchyManager.hpp @@ -63,6 +63,14 @@ #include "MueLu_MasterList.hpp" #include "MueLu_PerfUtils.hpp" +#ifdef HAVE_MUELU_INTREPID2 +#ifdef HAVE_MUELU_INTREPID2_REFACTOR +#include "Kokkos_DynRankView.hpp" +#else +#include "Intrepid2_FieldContainer.hpp" +#endif +#endif + namespace MueLu { // This class stores the configuration of a Hierarchy. @@ -235,6 +243,15 @@ namespace MueLu { WriteData(H, restrictorsToPrint_, "R"); WriteData(H, nullspaceToPrint_, "Nullspace"); WriteData(H, coordinatesToPrint_, "Coordinates"); +#ifdef HAVE_MUELU_INTREPID2 +#ifdef HAVE_MUELU_INTREPID2_REFACTOR + typedef Kokkos::DynRankView FCi; +#else + typedef Intrepid2::FieldContainer FCi; +#endif + WriteDataFC(H,elementToNodeMapsToPrint_, "pcoarsen: element to node map","el2node"); +#endif + } //SetupHierarchy @@ -283,13 +300,14 @@ namespace MueLu { Teuchos::Array restrictorsToPrint_; Teuchos::Array nullspaceToPrint_; Teuchos::Array coordinatesToPrint_; + Teuchos::Array elementToNodeMapsToPrint_; std::map > keep_; private: template - void WriteData(Hierarchy& H, const Teuchos::Array& data, const std::string& name) const { + void WriteData(Hierarchy& H, const Teuchos::Array& data, const std::string& name, bool isFieldContainer=false) const { for (int i = 0; i < data.size(); ++i) { std::string fileName = name + "_" + Teuchos::toString(data[i]) + ".m"; @@ -298,13 +316,63 @@ namespace MueLu { if (L->IsAvailable(name)) { RCP M = L->template Get< RCP >(name); - if (!M.is_null()) - Xpetra::IO::Write(fileName,* M); - } - } + if (!M.is_null()) { + Xpetra::IO::Write(fileName,* M); + } + } + } } } + + template + void WriteDataFC(Hierarchy& H, const Teuchos::Array& data, const std::string& name, const std::string & ofname, bool isFieldContainer=false) const { + for (int i = 0; i < data.size(); ++i) { + const std::string fileName = ofname + "_" + Teuchos::toString(data[i]) + ".m"; + + if (data[i] < H.GetNumLevels()) { + RCP L = H.GetLevel(data[i]); + + if (L->IsAvailable(name)) { + RCP M = L->template Get< RCP >(name); + if (!M.is_null()) { + RCP A = L->template Get >("A"); + RCP AG = A->getCrsGraph(); + WriteFieldContainer(fileName,*M,*AG->getColMap()); + } + } + } + } + } + + // For dumping an IntrepidPCoarsening element-to-node map to disk + template + void WriteFieldContainer(const std::string& fileName, T & fcont,const Map &colMap) const { + typedef LocalOrdinal LO; + typedef GlobalOrdinal GO; + typedef Node NO; + typedef Xpetra::MultiVector GOMultiVector; + + size_t num_els = (size_t) fcont.dimension(0); + size_t num_vecs =(size_t) fcont.dimension(1); + + // Generate rowMap + Teuchos::RCP rowMap = Xpetra::MapFactory::Build(colMap.lib(),Teuchos::OrdinalTraits::invalid(),fcont.dimension(0),colMap.getIndexBase(),colMap.getComm()); + + // Fill multivector to use *petra dump routines + RCP vec = Xpetra::MultiVectorFactory::Build(rowMap,num_vecs); + + for(size_t j=0; j v = vec->getDataNonConst(j); + for(size_t i=0; i::Write(fileName,*vec); + } + + + // Levels Array > levelManagers_; // one FactoryManager per level (the last levelManager is used for all the remaining levels) diff --git a/packages/muelu/src/Interface/MueLu_ParameterListInterpreter_def.hpp b/packages/muelu/src/Interface/MueLu_ParameterListInterpreter_def.hpp index 8f13c15d447f..d4a79e1e2cb9 100644 --- a/packages/muelu/src/Interface/MueLu_ParameterListInterpreter_def.hpp +++ b/packages/muelu/src/Interface/MueLu_ParameterListInterpreter_def.hpp @@ -276,6 +276,8 @@ namespace MueLu { this->nullspaceToPrint_ = Teuchos::getArrayFromStringParameter(printList, "Nullspace"); if (printList.isParameter("Coordinates")) this->coordinatesToPrint_ = Teuchos::getArrayFromStringParameter(printList, "Coordinates"); + if (printList.isParameter("pcoarsen: element to node map")) + this->elementToNodeMapsToPrint_ = Teuchos::getArrayFromStringParameter(printList, "pcoarsen: element to node map"); } // Set verbosity parameter diff --git a/packages/muelu/src/Transfers/PCoarsen/MueLu_IntrepidPCoarsenFactory_decl.hpp b/packages/muelu/src/Transfers/PCoarsen/MueLu_IntrepidPCoarsenFactory_decl.hpp index edc73d93a19e..7102e5b1bdba 100644 --- a/packages/muelu/src/Transfers/PCoarsen/MueLu_IntrepidPCoarsenFactory_decl.hpp +++ b/packages/muelu/src/Transfers/PCoarsen/MueLu_IntrepidPCoarsenFactory_decl.hpp @@ -258,11 +258,10 @@ namespace MueLu { // ! will be stored in seeds. template void FindGeometricSeedOrdinals(Teuchos::RCP basis, const LOFieldContainer &elementToNodeMap, - std::vector> &seeds, + std::vector > &seeds, const Xpetra::Map &rowMap, const Xpetra::Map &columnMap); - }//namespace MueLuIntrepid } //namespace MueLu diff --git a/packages/muelu/src/Transfers/PCoarsen/MueLu_IntrepidPCoarsenFactory_def.hpp b/packages/muelu/src/Transfers/PCoarsen/MueLu_IntrepidPCoarsenFactory_def.hpp index e104676fc22b..deaae97dce97 100644 --- a/packages/muelu/src/Transfers/PCoarsen/MueLu_IntrepidPCoarsenFactory_def.hpp +++ b/packages/muelu/src/Transfers/PCoarsen/MueLu_IntrepidPCoarsenFactory_def.hpp @@ -47,6 +47,7 @@ #define MUELU_IPCFACTORY_DEF_HPP #include +#include #include #include @@ -107,9 +108,11 @@ inline std::string tolower(const std::string & str) { return data; } + +/*********************************************************************************************************/ template void FindGeometricSeedOrdinals(Teuchos::RCP basis, const LOFieldContainer &elementToNodeMap, - std::vector> &seeds, + std::vector > &seeds, const Xpetra::Map &rowMap, const Xpetra::Map &columnMap) { diff --git a/packages/muelu/test/unit_tests/IntrepidPCoarsenFactory.cpp b/packages/muelu/test/unit_tests/IntrepidPCoarsenFactory.cpp index b41e20a4c467..c7c3ff952aaf 100644 --- a/packages/muelu/test/unit_tests/IntrepidPCoarsenFactory.cpp +++ b/packages/muelu/test/unit_tests/IntrepidPCoarsenFactory.cpp @@ -3139,6 +3139,7 @@ TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(IntrepidPCoarsenFactory,BuildP_PseudoPoisson_L dump.set("A","{0,1,2}"); dump.set("P","{0,1}"); dump.set("R","{0,1}"); + dump.set("pcoarsen: element to node map","{0,1,2}"); Params.set("export data",dump); #endif