46 #ifndef MUELU_USERAGGREGATIONFACTORY_DEF_HPP_ 47 #define MUELU_USERAGGREGATIONFACTORY_DEF_HPP_ 58 #include "MueLu_Aggregates.hpp" 60 #include "MueLu_Utilities.hpp" 64 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
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>
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;
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.
T & get(const std::string &name, T def_value)
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Timer to be used in factories. Similar to Monitor but with additional timers.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Namespace for MueLu classes and methods.
static Teuchos::RCP< const Comm< OrdinalType > > getComm()
void DeclareInput(Level ¤tLevel) const
Input.
int GetLevelID() const
Return level number.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Class that holds all level-specific information.
void Build(Level ¤tLevel) const
Build aggregates.
Exception throws to report errors in the internal logical of the program.
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.