46 #ifndef MUELU_USERAGGREGATIONFACTORY_DEF_HPP_ 47 #define MUELU_USERAGGREGATIONFACTORY_DEF_HPP_ 49 #include <Xpetra_Map.hpp> 50 #include <Xpetra_Vector.hpp> 51 #include <Xpetra_VectorFactory.hpp> 52 #include <Xpetra_MapFactory.hpp> 58 #include "MueLu_Aggregates.hpp" 60 #include "MueLu_Utilities.hpp" 64 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
66 RCP<ParameterList> validParamList = rcp(
new ParameterList());
69 validParamList->set<std::string>(
"filePrefix",
"",
"The data is read from files of this name: <filePrefix><level>_<PID>.<fileExt>");
70 validParamList->set<std::string>(
"fileExt",
"",
"The data is read from files of this name: <filePrefix><level>_<PID>.<fileExt>");
72 return validParamList;
75 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
84 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
88 const ParameterList& pL = GetParameterList();
90 RCP< const Teuchos::Comm<int> > comm = Teuchos::DefaultComm<int>::getComm();
91 const int myRank = comm->getRank();
93 std::string fileName = pL.get<std::string>(
"filePrefix") +
toString(currentLevel.
GetLevelID()) +
"_" +
toString(myRank) +
"." + pL.get<std::string>(
"fileExt");
94 std::ifstream ifs(fileName.c_str());
97 LO numVertices, numAggregates;
100 ifs >> numAggregates;
101 TEUCHOS_TEST_FOR_EXCEPTION(numVertices <= 0, Exceptions::InvalidArgument, "Number of vertices must be > 0
"); 102 TEUCHOS_TEST_FOR_EXCEPTION(numAggregates <= 0, Exceptions::InvalidArgument, "Number of aggregates must be > 0
"); 104 Xpetra::UnderlyingLib lib = currentLevel.lib(); 105 const int indexBase = 0; 106 RCP<Map> map = MapFactory::Build(lib, numVertices, indexBase, comm); 108 RCP<Aggregates> aggregates = rcp(new Aggregates(map)); 109 aggregates->setObjectLabel("User
"); 111 aggregates->SetNumAggregates(numAggregates); 113 Teuchos::ArrayRCP<LO> vertex2AggId = aggregates->GetVertex2AggId()->getDataNonConst(0); 114 Teuchos::ArrayRCP<LO> procWinner = aggregates->GetProcWinner() ->getDataNonConst(0); 116 for (LO i = 0; i < numAggregates; i++) { 120 std::vector<LO> list(aggSize); 121 for (int k = 0; k < aggSize; k++) { 122 // FIXME: File contains GIDs, we need LIDs 123 // for now, works on a single processor 127 // Mark first node as root node for the aggregate 128 aggregates->SetIsRoot(list[0]); 130 // Fill vertex2AggId and procWinner structure with information 131 for (int k = 0; k < aggSize; k++) { 132 vertex2AggId[list[k]] = i; 133 procWinner [list[k]] = myRank; 137 // FIXME: do the proper check whether aggregates cross interprocessor boundary 138 aggregates->AggregatesCrossProcessors(false); 142 GetOStream(Statistics0) << aggregates->description() << std::endl; 147 #endif /* MUELU_USERAGGREGATIONFACTORY_DEF_HPP_ */ std::string toString(const T &what)
Little helper function to convert non-string types to strings.
Container class for aggregation information.
void DeclareInput(Level ¤tLevel) const
Input.
Timer to be used in factories. Similar to Monitor but with additional timers.
Namespace for MueLu classes and methods.
void Build(Level ¤tLevel) const
Build aggregates.
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
Class that holds all level-specific information.
int GetLevelID() const
Return level number.
Exception throws to report errors in the internal logical of the program.