46 #ifndef MUELU_INTERFACEAGGREGATIONFACTORY_DEF_HPP_
47 #define MUELU_INTERFACEAGGREGATIONFACTORY_DEF_HPP_
52 #include "MueLu_Aggregates.hpp"
54 #include "Xpetra_MapFactory.hpp"
59 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
65 validParamList->
set<
RCP<const FactoryBase>>(
"Aggregates", Teuchos::null,
"Generating factory of the Aggregates (for block 0,0)");
66 validParamList->
set<
RCP<const FactoryBase>>(
"DualNodeID2PrimalNodeID", Teuchos::null,
"Generating factory of the DualNodeID2PrimalNodeID map");
70 return validParamList;
73 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
76 Input(currentLevel,
"A");
77 Input(currentLevel,
"Aggregates");
86 "DualNodeID2PrimalNodeID was not provided by the user on level 0!");
91 Input(currentLevel,
"DualNodeID2PrimalNodeID");
95 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
98 using Map = Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>;
99 using MapFactory = Xpetra::MapFactory<LocalOrdinal, GlobalOrdinal, Node>;
101 using Dual2Primal_type = std::map<LocalOrdinal, LocalOrdinal>;
103 const char prefix[] =
"MueLu::InterfaceAggregationFactory::Build: ";
108 RCP<Matrix> A = Get<RCP<Matrix>>(currentLevel,
"A");
109 RCP<Aggregates> aggs00 = Get<RCP<Aggregates>>(currentLevel,
"Aggregates");
116 if (currentLevel.GetLevelID() == 0)
119 lagr2dof = Get<RCP<Dual2Primal_type>>(currentLevel,
"DualNodeID2PrimalNodeID");
124 const size_t myRank = aggRangeMap->getComm()->getRank();
126 LocalOrdinal globalNumDualNodes = aggRangeMap->getGlobalNumElements() / nDOFPerDualNode;
127 LocalOrdinal numDualNodes = aggRangeMap->getNodeNumElements() / nDOFPerDualNode;
129 TEUCHOS_TEST_FOR_EXCEPTION(numDualNodes !=
LocalOrdinal(lagr2dof->size()), std::runtime_error, prefix <<
" MueLu requires the range map and the DualNodeID2PrimalNodeID map to be compatible.");
133 if (nDOFPerDualNode == 1)
134 aggVertexMap = aggRangeMap;
138 auto comm = aggRangeMap->getComm();
139 std::vector<GlobalOrdinal> myDualNodes = {};
141 for (
size_t i = 0; i < aggRangeMap->getNodeNumElements(); i += nDOFPerDualNode)
142 myDualNodes.push_back((aggRangeMap->getGlobalElement(i) - indexBase) / nDOFPerDualNode + indexBase);
144 aggVertexMap = MapFactory::Build(aggRangeMap->lib(), globalNumDualNodes, myDualNodes, indexBase, comm);
160 for (
LocalOrdinal localDualNodeID = 0; localDualNodeID < numDualNodes; ++localDualNodeID)
163 LocalOrdinal localPrimalNodeID = (*lagr2dof)[localDualNodeID];
166 LocalOrdinal currentAggIdInput = vertex2AggIdInput[localPrimalNodeID];
169 if (coarseDof2Lagr->count(currentAggIdInput) == 0)
172 (*coarseDof2Lagr)[currentAggIdInput] = numAggId;
173 (*coarseLagr2Dof)[numAggId] = currentAggIdInput;
178 vertex2AggId[localDualNodeID] = (*coarseDof2Lagr)[currentAggIdInput];
179 procWinner[localDualNodeID] = myRank;
183 Set(currentLevel,
"Aggregates", aggregates);
184 Set(currentLevel,
"CoarseDualNodeID2PrimalNodeID", coarseLagr2Dof);
MueLu::DefaultLocalOrdinal LocalOrdinal
const RCP< LOVector > & GetProcWinner() const
Returns constant vector that maps local node IDs to owning processor IDs.
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)
static const NoFactory * get()
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
MueLu::DefaultGlobalOrdinal GlobalOrdinal
Class that holds all level-specific information.
void Build(Level ¤tLevel) const override
Build aggregates.
virtual void setObjectLabel(const std::string &objectLabel)
const RCP< LOMultiVector > & GetVertex2AggId() const
Returns constant vector that maps local node IDs to local aggregates IDs.
void DeclareInput(Level ¤tLevel) const override
Input.
RCP< const ParameterList > GetValidParameterList() const override
Return a const parameter list of valid parameters that setParameterList() will accept.
int GetLevelID() const
Return level number.
Exception throws to report errors in the internal logical of the program.
std::string description() const
Return a simple one-line description of this object.
void AggregatesCrossProcessors(const bool &flag)
Record whether aggregates include DOFs from other processes.
void DeclareInput(const std::string &ename, const FactoryBase *factory, const FactoryBase *requestedBy=NoFactory::get())
Callback from FactoryBase::CallDeclareInput() and FactoryBase::DeclareInput()
bool IsAvailable(const std::string &ename, const FactoryBase *factory=NoFactory::get()) const
Test whether a need's value has been saved.
void SetNumAggregates(LO nAggregates)
Set number of local aggregates on current processor.