46#ifndef MUELU_NODEPARTITIONINTERFACE_DEF_HPP
47#define MUELU_NODEPARTITIONINTERFACE_DEF_HPP
54#include <Teuchos_Utils.hpp>
55#include <Teuchos_DefaultMpiComm.hpp>
56#include <Teuchos_OpaqueWrapper.hpp>
61#include "MueLu_Utilities.hpp"
66 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
69 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
71 RCP<ParameterList> validParamList = rcp(
new ParameterList());
72#define SET_VALID_ENTRY(name) validParamList->setEntry(name, MasterList::getEntry(name))
76 validParamList->set< RCP<const FactoryBase> > (
"A", Teuchos::null,
"Factory of the matrix A");
77 validParamList->set< RCP<const FactoryBase> > (
"number of partitions", Teuchos::null,
"Instance of RepartitionHeuristicFactory.");
78 validParamList->set< RCP<const FactoryBase> > (
"Node Comm", Teuchos::null,
"Generating factory of the node level communicator");
81 validParamList->set< RCP<const FactoryBase> > (
"Coordinates", Teuchos::null,
"Factory of the coordinates");
82 return validParamList;
86 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
88 Input(currentLevel,
"A");
89 Input(currentLevel,
"number of partitions");
90 Input(currentLevel,
"Node Comm");
91 Input(currentLevel,
"Coordinates");
94 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
97 RCP<Matrix> A = Get<RCP<Matrix> >(level,
"A");
98 RCP<const Map> rowMap = A->getRowMap();
100 int numParts = Get<int>(level,
"number of partitions");
101 if (numParts == 1 || numParts == -1) {
103 RCP<Xpetra::Vector<GO,LO,GO,NO> > decomposition = Xpetra::VectorFactory<GO, LO, GO, NO>::Build(rowMap,
true);
104 Set(level,
"Partition", decomposition);
109 RCP<const Teuchos::Comm<int> > NodeComm = Get< RCP<const Teuchos::Comm<int> > >(level,
"Node Comm");
110 TEUCHOS_TEST_FOR_EXCEPTION(NodeComm.is_null(),
Exceptions::RuntimeError,
"MueLu::NodePartitionInterface::Build(): NodeComm is null.");
113 int nodeZeroRank =A->getMap()->getComm()->getRank();
114 Teuchos::broadcast<int,int>(*NodeComm,0,Teuchos::inOutArg(nodeZeroRank));
118 RCP<Xpetra::Vector<GO,LO,GO,NO> > decomposition = Xpetra::VectorFactory<GO,LO,GO,NO>::Build(rowMap,
false);
119 decomposition->putScalar(Teuchos::as<GO>(nodeZeroRank));
121 Set(level,
"Partition", decomposition);
#define SET_VALID_ENTRY(name)
Exception throws to report errors in the internal logical of the program.
Timer to be used in factories. Similar to Monitor but with additional timers.
Class that holds all level-specific information.
NodePartitionInterface()
Constructor.
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
void DeclareInput(Level ¤tLevel) const
Specifies the data that this class needs, and the factories that generate that data.
void Build(Level ¤tLevel) const
Build an object with this factory.
Namespace for MueLu classes and methods.