53#ifndef MUELU_AMALGAMATIONINFO_DEF_HPP_
54#define MUELU_AMALGAMATIONINFO_DEF_HPP_
56#include <Xpetra_MapFactory.hpp>
57#include <Xpetra_Vector.hpp>
61#include "MueLu_Aggregates.hpp"
65 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
67 Teuchos::ArrayRCP<LocalOrdinal>& aggStart, Teuchos::ArrayRCP<GlobalOrdinal>& aggToRowMap)
const {
68 const int myPid = aggregates.
GetMap()->getComm()->getRank();
69 Teuchos::ArrayView<const GO> nodeGlobalElts = aggregates.
GetMap()->getLocalElementList();
70 Teuchos::ArrayRCP<LO> procWinner = aggregates.
GetProcWinner()->getDataNonConst(0);
71 Teuchos::ArrayRCP<LO> vertex2AggId = aggregates.
GetVertex2AggId()->getDataNonConst(0);
72 const LO size = procWinner.size();
75 Array<LO> sizes(numAggregates);
76 if (stridedblocksize_ == 1) {
77 for (LO lnode = 0; lnode < size; ++lnode) {
78 LO myAgg = vertex2AggId[lnode];
79 if (procWinner[lnode] == myPid)
83 for (LO lnode = 0; lnode < size; ++lnode) {
84 LO myAgg = vertex2AggId[lnode];
85 if (procWinner[lnode] == myPid) {
86 GO gnodeid = nodeGlobalElts[lnode];
89 if (columnMap_->isNodeGlobalElement(gDofIndex))
95 aggStart = ArrayRCP<LO>(numAggregates+1,0);
96 aggStart[0] = Teuchos::ScalarTraits<LO>::zero();
97 for (GO i=0; i<numAggregates; ++i) {
98 aggStart[i+1] = aggStart[i] + sizes[i];
100 aggToRowMap = ArrayRCP<GO>(aggStart[numAggregates],0);
103 Array<LO> numDofs(numAggregates, 0);
105 if (stridedblocksize_ == 1) {
106 for (LO lnode = 0; lnode < size; ++lnode) {
107 LO myAgg = vertex2AggId[lnode];
108 if (procWinner[lnode] == myPid) {
109 aggToRowMap[ aggStart[myAgg] + numDofs[myAgg] ] = ComputeGlobalDOF(nodeGlobalElts[lnode]);
114 for (LO lnode = 0; lnode < size; ++lnode) {
115 LO myAgg = vertex2AggId[lnode];
117 if (procWinner[lnode] == myPid) {
118 GO gnodeid = nodeGlobalElts[lnode];
121 if (columnMap_->isNodeGlobalElement(gDofIndex)) {
122 aggToRowMap[ aggStart[myAgg] + numDofs[myAgg] ] = gDofIndex;
133 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
135 Teuchos::ArrayRCP<LO>& aggStart, Teuchos::ArrayRCP<LO>& aggToRowMap)
const {
137 int myPid = aggregates.
GetMap()->getComm()->getRank();
138 Teuchos::ArrayView<const GO> nodeGlobalElts = aggregates.
GetMap()->getLocalElementList();
140 Teuchos::ArrayRCP<LO> procWinner = aggregates.
GetProcWinner() ->getDataNonConst(0);
141 Teuchos::ArrayRCP<LO> vertex2AggId = aggregates.
GetVertex2AggId()->getDataNonConst(0);
146 const LO size = procWinner.size();
148 std::vector<LO> sizes(numAggregates);
149 if (stridedblocksize_ == 1) {
150 for (LO lnode = 0; lnode < size; lnode++)
151 if (procWinner[lnode] == myPid)
152 sizes[vertex2AggId[lnode]]++;
154 for (LO lnode = 0; lnode < size; lnode++)
155 if (procWinner[lnode] == myPid) {
156 GO nodeGID = nodeGlobalElts[lnode];
158 for (LO k = 0; k < stridedblocksize_; k++) {
159 GO GID = ComputeGlobalDOF(nodeGID, k);
160 if (columnMap_->isNodeGlobalElement(GID))
161 sizes[vertex2AggId[lnode]]++;
166 aggStart = ArrayRCP<LO>(numAggregates+1);
168 for (GO i = 0; i < numAggregates; i++)
169 aggStart[i+1] = aggStart[i] + sizes[i];
171 aggToRowMap = ArrayRCP<LO>(aggStart[numAggregates], 0);
174 Array<LO> numDofs(numAggregates, 0);
175 if (stridedblocksize_ == 1) {
176 for (LO lnode = 0; lnode < size; ++lnode)
177 if (procWinner[lnode] == myPid) {
178 LO myAgg = vertex2AggId[lnode];
179 aggToRowMap[aggStart[myAgg] + numDofs[myAgg]] = lnode;
183 for (LO lnode = 0; lnode < size; ++lnode)
184 if (procWinner[lnode] == myPid) {
185 LO myAgg = vertex2AggId[lnode];
186 GO nodeGID = nodeGlobalElts[lnode];
188 for (LO k = 0; k < stridedblocksize_; k++) {
189 GO GID = ComputeGlobalDOF(nodeGID, k);
190 if (columnMap_->isNodeGlobalElement(GID)) {
191 aggToRowMap[aggStart[myAgg] + numDofs[myAgg]] = lnode*stridedblocksize_ + k;
201 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
205 if (!(verbLevel &
Debug))
208 out <<
"AmalgamationInfo -- Striding information:"
209 <<
"\n fullBlockSize = " << fullblocksize_
210 <<
"\n blockID = " << blockid_
211 <<
"\n stridingOffset = " << nStridedOffset_
212 <<
"\n stridedBlockSize = " << stridedblocksize_
213 <<
"\n indexBase = " << indexBase_
216 out <<
"AmalgamationInfo -- DOFs to nodes mapping:\n"
217 <<
" Mapping of row DOFs to row nodes:" << *rowTranslation_()
218 <<
"\n\n Mapping of column DOFs to column nodes:" << *colTranslation_()
221 out <<
"AmalgamationInfo -- row node map:" << std::endl;
222 nodeRowMap_->describe(out, Teuchos::VERB_EXTREME);
224 out <<
"AmalgamationInfo -- column node map:" << std::endl;
225 nodeColMap_->describe(out, Teuchos::VERB_EXTREME);
230 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
232 Teuchos::RCP<const Map> nodeMap = aggregates.
GetMap();
234 Teuchos::RCP<std::vector<GO> > myDofGids = Teuchos::rcp(
new std::vector<GO>);
235 Teuchos::ArrayView<const GO> gEltList = nodeMap->getLocalElementList();
236 LO nodeElements = Teuchos::as<LO>(nodeMap->getLocalNumElements());
237 if (stridedblocksize_ == 1) {
238 for (LO n = 0; n<nodeElements; n++) {
240 myDofGids->push_back(gDofIndex);
243 for (LO n = 0; n<nodeElements; n++) {
246 if (columnMap_->isNodeGlobalElement(gDofIndex))
247 myDofGids->push_back(gDofIndex);
252 Teuchos::ArrayRCP<GO> arr_myDofGids = Teuchos::arcp( myDofGids );
253 Teuchos::RCP<Map> importDofMap = MapFactory::Build(aggregates.
GetMap()->lib(), Teuchos::OrdinalTraits<Xpetra::global_size_t>::invalid(), arr_myDofGids(), aggregates.
GetMap()->getIndexBase(), aggregates.
GetMap()->getComm());
259 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
261 GlobalOrdinal gDofIndex = offset_ + (gNodeID-indexBase_)*fullblocksize_ + nStridedOffset_ + k + indexBase_;
265 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
272 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
274 return (ldofID - ldofID%fullblocksize_) / fullblocksize_;
MueLu::DefaultLocalOrdinal LocalOrdinal
MueLu::DefaultGlobalOrdinal GlobalOrdinal
Container class for aggregation information.
const RCP< const Map > GetMap() const
returns (overlapping) map of aggregate/node distribution
const RCP< LOMultiVector > & GetVertex2AggId() const
Returns constant vector that maps local node IDs to local aggregates IDs.
const RCP< LOVector > & GetProcWinner() const
Returns constant vector that maps local node IDs to owning processor IDs.
LO GetNumAggregates() const
returns the number of aggregates of the current processor. Note: could/should be renamed to GetNumLoc...
LO ComputeLocalDOF(LocalOrdinal const &lNodeID, LocalOrdinal const &k) const
ComputeLocalDOF return locbal dof id associated with local node id lNodeID and dof index k.
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the object with some verbosity level to an FancyOStream object.
void UnamalgamateAggregatesLO(const Aggregates &aggregates, Teuchos::ArrayRCP< LocalOrdinal > &aggStart, Teuchos::ArrayRCP< LO > &aggToRowMap) const
GO ComputeGlobalDOF(GO const &gNodeID, LO const &k=0) const
ComputeGlobalDOF.
Teuchos::RCP< Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > ComputeUnamalgamatedImportDofMap(const Aggregates &aggregates) const
ComputeUnamalgamatedImportDofMap build overlapping dof row map from aggregates needed for overlapping...
void UnamalgamateAggregates(const Aggregates &aggregates, Teuchos::ArrayRCP< LocalOrdinal > &aggStart, Teuchos::ArrayRCP< GlobalOrdinal > &aggToRowMap) const
UnamalgamateAggregates.
LO ComputeLocalNode(LocalOrdinal const &ldofID) const
Namespace for MueLu classes and methods.
@ Debug
Print additional debugging information.