53#ifndef MUELU_AMALGAMATIONINFO_DEF_HPP_
54#define MUELU_AMALGAMATIONINFO_DEF_HPP_
56#include <Xpetra_MapFactory.hpp>
57#include <Xpetra_Vector.hpp>
62#include "MueLu_Aggregates.hpp"
66 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
69 Teuchos::ArrayRCP<LocalOrdinal>& aggStart,
70 Teuchos::ArrayRCP<GlobalOrdinal>& aggToRowMap)
const {
73 aggregates.GetProcWinner(),
74 aggregates.GetVertex2AggId(),
75 aggregates.GetNumAggregates(),
81 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
84 const RCP<LOVector> &procWinnerVec,
85 const RCP<LOMultiVector> &vertex2AggIdVec,
86 const GO numAggregates,
87 Teuchos::ArrayRCP<LocalOrdinal>& aggStart,
88 Teuchos::ArrayRCP<GlobalOrdinal>& aggToRowMap)
const {
90 int myPid = nodeMap->getComm()->getRank();
91 Teuchos::ArrayView<const GO> nodeGlobalElts = nodeMap->getLocalElementList();
92 Teuchos::ArrayRCP<LO> procWinner = procWinnerVec->getDataNonConst(0);
93 Teuchos::ArrayRCP<LO> vertex2AggId = vertex2AggIdVec->getDataNonConst(0);
94 const LO size = procWinner.size();
96 std::vector<LO> sizes(numAggregates);
98 for (LO lnode = 0; lnode < size; ++lnode) {
99 LO myAgg = vertex2AggId[lnode];
100 if (procWinner[lnode] == myPid)
104 for (LO lnode = 0; lnode < size; ++lnode) {
105 LO myAgg = vertex2AggId[lnode];
106 if (procWinner[lnode] == myPid) {
107 GO gnodeid = nodeGlobalElts[lnode];
110 if (
columnMap_->isNodeGlobalElement(gDofIndex))
116 aggStart = ArrayRCP<LO>(numAggregates+1,0);
117 aggStart[0] = Teuchos::ScalarTraits<LO>::zero();
118 for (GO i=0; i<numAggregates; ++i) {
119 aggStart[i+1] = aggStart[i] + sizes[i];
121 aggToRowMap = ArrayRCP<GO>(aggStart[numAggregates],0);
124 Array<LO> numDofs(numAggregates, 0);
127 for (LO lnode = 0; lnode < size; ++lnode) {
128 LO myAgg = vertex2AggId[lnode];
129 if (procWinner[lnode] == myPid) {
130 aggToRowMap[ aggStart[myAgg] + numDofs[myAgg] ] =
ComputeGlobalDOF(nodeGlobalElts[lnode]);
135 for (LO lnode = 0; lnode < size; ++lnode) {
136 LO myAgg = vertex2AggId[lnode];
138 if (procWinner[lnode] == myPid) {
139 GO gnodeid = nodeGlobalElts[lnode];
142 if (
columnMap_->isNodeGlobalElement(gDofIndex)) {
143 aggToRowMap[ aggStart[myAgg] + numDofs[myAgg] ] = gDofIndex;
154 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
157 Teuchos::ArrayRCP<LO>& aggStart,
158 Teuchos::ArrayRCP<LO>& aggToRowMap)
const {
159 UnamalgamateAggregatesLO(aggregates.GetMap(),
160 aggregates.GetProcWinner(),
161 aggregates.GetVertex2AggId(),
162 aggregates.GetNumAggregates(),
167 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
170 const RCP<LOVector> &procWinnerVec,
171 const RCP<LOMultiVector> &vertex2AggIdVec,
172 const GO numAggregates,
173 Teuchos::ArrayRCP<LO>& aggStart,
174 Teuchos::ArrayRCP<LO>& aggToRowMap)
const {
176 int myPid = nodeMap->getComm()->getRank();
177 Teuchos::ArrayView<const GO> nodeGlobalElts = nodeMap->getLocalElementList();
179 Teuchos::ArrayRCP<LO> procWinner = procWinnerVec ->getDataNonConst(0);
180 Teuchos::ArrayRCP<LO> vertex2AggId = vertex2AggIdVec->getDataNonConst(0);
184 const LO size = procWinner.size();
186 std::vector<LO> sizes(numAggregates);
187 if (stridedblocksize_ == 1) {
188 for (LO lnode = 0; lnode < size; lnode++)
189 if (procWinner[lnode] == myPid)
190 sizes[vertex2AggId[lnode]]++;
192 for (LO lnode = 0; lnode < size; lnode++)
193 if (procWinner[lnode] == myPid) {
194 GO nodeGID = nodeGlobalElts[lnode];
196 for (LO k = 0; k < stridedblocksize_; k++) {
197 GO GID = ComputeGlobalDOF(nodeGID, k);
198 if (columnMap_->isNodeGlobalElement(GID))
199 sizes[vertex2AggId[lnode]]++;
204 aggStart = ArrayRCP<LO>(numAggregates+1);
206 for (GO i = 0; i < numAggregates; i++)
207 aggStart[i+1] = aggStart[i] + sizes[i];
209 aggToRowMap = ArrayRCP<LO>(aggStart[numAggregates], 0);
212 Array<LO> numDofs(numAggregates, 0);
213 if (stridedblocksize_ == 1) {
214 for (LO lnode = 0; lnode < size; ++lnode)
215 if (procWinner[lnode] == myPid) {
216 LO myAgg = vertex2AggId[lnode];
217 aggToRowMap[aggStart[myAgg] + numDofs[myAgg]] = lnode;
221 for (LO lnode = 0; lnode < size; ++lnode)
222 if (procWinner[lnode] == myPid) {
223 LO myAgg = vertex2AggId[lnode];
224 GO nodeGID = nodeGlobalElts[lnode];
226 for (LO k = 0; k < stridedblocksize_; k++) {
227 GO GID = ComputeGlobalDOF(nodeGID, k);
228 if (columnMap_->isNodeGlobalElement(GID)) {
229 aggToRowMap[aggStart[myAgg] + numDofs[myAgg]] = lnode*stridedblocksize_ + k;
239 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
243 if (!(verbLevel &
Debug))
246 out <<
"AmalgamationInfo -- Striding information:"
254 out <<
"AmalgamationInfo -- DOFs to nodes mapping:\n"
256 <<
"\n\n Mapping of column DOFs to column nodes:" << *
colTranslation_()
259 out <<
"AmalgamationInfo -- row node map:" << std::endl;
262 out <<
"AmalgamationInfo -- column node map:" << std::endl;
268 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
274 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
278 Teuchos::RCP<std::vector<GO> > myDofGids = Teuchos::rcp(
new std::vector<GO>);
279 Teuchos::ArrayView<const GO> gEltList = nodeMap->getLocalElementList();
280 LO nodeElements = Teuchos::as<LO>(nodeMap->getLocalNumElements());
282 for (LO n = 0; n<nodeElements; n++) {
284 myDofGids->push_back(gDofIndex);
287 for (LO n = 0; n<nodeElements; n++) {
290 if (
columnMap_->isNodeGlobalElement(gDofIndex))
291 myDofGids->push_back(gDofIndex);
296 Teuchos::ArrayRCP<GO> arr_myDofGids = Teuchos::arcp( myDofGids );
297 Teuchos::RCP<Map> importDofMap = MapFactory::Build(nodeMap->lib(), Teuchos::OrdinalTraits<Xpetra::global_size_t>::invalid(), arr_myDofGids(), nodeMap->getIndexBase(), nodeMap->getComm());
303 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
312 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
319 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
MueLu::DefaultLocalOrdinal LocalOrdinal
MueLu::DefaultGlobalOrdinal GlobalOrdinal
Container class for aggregation information.
RCP< const Map > columnMap_
DOF map (really column map of A).
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
RCP< const Map > nodeRowMap_
node row and column map of graph (built from row and column map of A)
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...
RCP< const Map > nodeColMap_
RCP< Array< LO > > rowTranslation_
Arrays containing local node ids given local dof ids.
RCP< Array< LO > > colTranslation_
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.