10 #ifndef MUELU_TENTATIVEPFACTORY_DEF_HPP
11 #define MUELU_TENTATIVEPFACTORY_DEF_HPP
13 #include <Xpetra_MapFactory.hpp>
14 #include <Xpetra_Map.hpp>
20 #include <Xpetra_MultiVectorFactory.hpp>
24 #include <Xpetra_CrsMatrixWrap.hpp>
25 #include <Xpetra_StridedMap.hpp>
26 #include <Xpetra_StridedMapFactory.hpp>
29 #include "Xpetra_TpetraBlockCrsMatrix.hpp"
33 #include "MueLu_Aggregates.hpp"
34 #include "MueLu_AmalgamationInfo.hpp"
37 #include "MueLu_PerfUtils.hpp"
38 #include "MueLu_Utilities.hpp"
42 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
46 #define SET_VALID_ENTRY(name) validParamList->setEntry(name, MasterList::getEntry(name))
50 #undef SET_VALID_ENTRY
51 validParamList->
set<std::string>(
"Nullspace name",
"Nullspace",
"Name for the input nullspace");
56 validParamList->
set<
RCP<const FactoryBase> >(
"Scaled Nullspace", Teuchos::null,
"Generating factory of the scaled nullspace");
57 validParamList->
set<
RCP<const FactoryBase> >(
"UnAmalgamationInfo", Teuchos::null,
"Generating factory of UnAmalgamationInfo");
60 validParamList->
set<
RCP<const FactoryBase> >(
"Node Comm", Teuchos::null,
"Generating factory of the node level communicator");
64 norecurse.disableRecursiveValidation();
65 validParamList->
set<
ParameterList>(
"matrixmatrix: kernel params", norecurse,
"MatrixMatrix kernel parameters");
67 return validParamList;
70 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
74 std::string nspName =
"Nullspace";
75 if (pL.
isParameter(
"Nullspace name")) nspName = pL.
get<std::string>(
"Nullspace name");
77 Input(fineLevel,
"A");
78 Input(fineLevel,
"Aggregates");
79 Input(fineLevel, nspName);
80 Input(fineLevel,
"UnAmalgamationInfo");
81 Input(fineLevel,
"CoarseMap");
84 pL.
get<
bool>(
"tentative: build coarse coordinates")) {
85 bTransferCoordinates_ =
true;
86 Input(fineLevel,
"Coordinates");
87 }
else if (bTransferCoordinates_) {
88 Input(fineLevel,
"Coordinates");
92 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
94 return BuildP(fineLevel, coarseLevel);
97 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
105 std::string nspName =
"Nullspace";
106 if (pL.
isParameter(
"Nullspace name")) nspName = pL.
get<std::string>(
"Nullspace name");
110 RCP<Aggregates> aggregates = Get<RCP<Aggregates> >(fineLevel,
"Aggregates");
113 if (aggregates->GetNumGlobalAggregatesComputeIfNeeded() == 0) {
114 Ptentative = Teuchos::null;
115 Set(coarseLevel,
"P", Ptentative);
120 RCP<MultiVector> fineNullspace = Get<RCP<MultiVector> >(fineLevel, nspName);
121 RCP<const Map> coarseMap = Get<RCP<const Map> >(fineLevel,
"CoarseMap");
123 if (bTransferCoordinates_) {
124 fineCoords = Get<RCP<RealValuedMultiVector> >(fineLevel,
"Coordinates");
128 if (fineLevel.IsAvailable(
"Node Comm")) {
130 Set<RCP<const Teuchos::Comm<int> > >(coarseLevel,
"Node Comm", nodeComm);
140 if (bTransferCoordinates_) {
145 if (rcp_dynamic_cast<const StridedMap>(coarseMap) != Teuchos::null) {
146 blkSize = rcp_dynamic_cast<
const StridedMap>(coarseMap)->getFixedBlockSize();
148 GO indexBase = coarseMap->getIndexBase();
149 LO numCoarseNodes = Teuchos::as<LO>(elementAList.
size() / blkSize);
151 const int numDimensions = fineCoords->getNumVectors();
153 for (
LO i = 0; i < numCoarseNodes; i++) {
154 nodeList[i] = (elementAList[i * blkSize] - indexBase) / blkSize + indexBase;
156 RCP<const Map> coarseCoordsMap = MapFactory::Build(fineCoords->getMap()->lib(),
160 fineCoords->getMap()->getComm());
161 coarseCoords = RealValuedMultiVectorFactory::Build(coarseCoordsMap, numDimensions);
165 if (aggregates->AggregatesCrossProcessors()) {
169 ghostedCoords = RealValuedMultiVectorFactory::Build(aggMap, numDimensions);
172 ghostedCoords = fineCoords;
176 int myPID = coarseCoordsMap->getComm()->getRank();
177 LO numAggs = aggregates->GetNumAggregates();
178 ArrayRCP<LO> aggSizes = aggregates->ComputeAggregateSizesArrayRCP();
183 for (
int dim = 0; dim < numDimensions; ++dim) {
187 for (
LO lnode = 0; lnode < Teuchos::as<LO>(vertex2AggID.
size()); lnode++) {
188 if (procWinner[lnode] == myPID &&
189 lnode < fineCoordsData.
size() &&
190 vertex2AggID[lnode] < coarseCoordsData.
size() &&
192 coarseCoordsData[vertex2AggID[lnode]] += fineCoordsData[lnode];
195 for (
LO agg = 0; agg < numAggs; agg++) {
196 coarseCoordsData[agg] /= aggSizes[agg];
201 if (!aggregates->AggregatesCrossProcessors()) {
203 BuildPuncoupledBlockCrs(A, aggregates, amalgInfo, fineNullspace, coarseMap, Ptentative, coarseNullspace, coarseLevel.
GetLevelID());
205 BuildPuncoupled(A, aggregates, amalgInfo, fineNullspace, coarseMap, Ptentative, coarseNullspace, coarseLevel.
GetLevelID());
208 BuildPcoupled(A, aggregates, amalgInfo, fineNullspace, coarseMap, Ptentative, coarseNullspace);
218 if (A->IsView(
"stridedMaps") ==
true)
219 Ptentative->CreateView(
"stridedMaps", A->getRowMap(
"stridedMaps"), coarseMap);
221 Ptentative->CreateView(
"stridedMaps", Ptentative->getRangeMap(), coarseMap);
223 if (bTransferCoordinates_) {
224 Set(coarseLevel,
"Coordinates", coarseCoords);
226 Set(coarseLevel,
"Nullspace", coarseNullspace);
227 Set(coarseLevel,
"P", Ptentative);
231 params->
set(
"printLoadBalancingInfo",
true);
236 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
253 const size_t numFineBlockRows = rowMap->getLocalNumElements();
257 const SC zero = STS::zero();
258 const SC one = STS::one();
262 const size_t NSDim = fineNullspace->getNumVectors();
269 const size_t numCoarseBlockRows = coarsePointMap->getLocalNumElements() / NSDim;
270 RCP<const Map> coarseBlockMap = MapFactory::Build(coarsePointMap->lib(),
273 coarsePointMap->getIndexBase(),
274 coarsePointMap->getComm());
277 const bool&
doQRStep = pL.get<
bool>(
"tentative: calculate qr");
278 const bool& constantColSums = pL.get<
bool>(
"tentative: constant column sums");
281 "MueLu::TentativePFactory::MakeTentative: cannot use 'constant column sums' and 'calculate qr' at the same time");
299 GetOStream(
Runtime1) <<
"Column map is consistent with the row map, good." << std::endl;
301 throw std::runtime_error(
"TentativePFactory::PuncoupledBlockCrs: Inconsistent maps not currently supported");
304 coarseNullspace = MultiVectorFactory::Build(coarsePointMap, NSDim);
309 for (
size_t i = 0; i < NSDim; i++) {
310 fineNS[i] = fineNullspace->getData(i);
311 if (coarsePointMap->getLocalNumElements() > 0)
312 coarseNS[i] = coarseNullspace->getDataNonConst(i);
318 RCP<CrsGraph> BlockGraph = CrsGraphFactory::Build(rowMap, coarseBlockMap, 0);
321 BlockGraph->allocateAllIndices(numFineBlockRows, iaPtent, jaPtent);
325 for (
size_t i = 0; i < numFineBlockRows; i++) {
329 ia[numCoarseBlockRows] = numCoarseBlockRows;
331 for (
GO agg = 0; agg < numAggs; agg++) {
332 LO aggSize = aggStart[agg + 1] - aggStart[agg];
335 for (
LO j = 0; j < aggSize; j++) {
337 const LO localRow = aggToRowMapLO[aggStart[agg] + j];
338 const size_t rowStart = ia[localRow];
339 ja[rowStart] = offset;
345 size_t ia_tmp = 0, nnz = 0;
346 for (
size_t i = 0; i < numFineBlockRows; i++) {
347 for (
size_t j = ia_tmp; j < ia[i + 1]; j++)
348 if (ja[j] != INVALID) {
363 GetOStream(
Runtime1) <<
"TentativePFactory : generating block graph" << std::endl;
364 BlockGraph->setAllIndices(iaPtent, jaPtent);
369 if (pL.isSublist(
"matrixmatrix: kernel params"))
370 FCparams =
rcp(
new ParameterList(pL.sublist(
"matrixmatrix: kernel params")));
375 FCparams->
set(
"compute global constants", FCparams->
get(
"compute global constants",
true));
376 std::string levelIDs =
toString(levelID);
377 FCparams->
set(
"Timer Label", std::string(
"MueLu::TentativeP-") + levelIDs);
380 BlockGraph->expertStaticFillComplete(coarseBlockMap, rowMap, dummy_i, dummy_e, FCparams);
387 if (P_tpetra.
is_null())
throw std::runtime_error(
"BuildPUncoupled: Matrix factory did not return a Tpetra::BlockCrsMatrix");
400 GetOStream(
Runtime1) <<
"TentativePFactory : bypassing local QR phase" << std::endl;
401 for (
LO agg = 0; agg < numAggs; agg++) {
403 const LO aggSize = aggStart[agg + 1] - aggStart[agg];
408 for (
LO j = 0; j < aggSize; j++) {
409 const LO localBlockRow = aggToRowMapLO[aggStart[agg] + j];
411 for (
size_t r = 0; r < NSDim; r++) {
412 LO localPointRow = localBlockRow * NSDim + r;
413 for (
size_t c = 0; c < NSDim; c++)
414 block[r * NSDim + c] = fineNS[c][localPointRow];
417 P_tpetra->replaceLocalValues(localBlockRow, bcol(), block());
421 for (
size_t j = 0; j < NSDim; j++)
422 coarseNS[j][offset + j] = one;
429 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
434 typedef typename STS::magnitudeType Magnitude;
435 const SC zero = STS::zero();
436 const SC one = STS::one();
451 for (
GO i = 0; i < numAggs; ++i) {
452 LO sizeOfThisAgg = aggStart[i + 1] - aggStart[i];
453 if (sizeOfThisAgg > maxAggSize) maxAggSize = sizeOfThisAgg;
457 const size_t NSDim = fineNullspace->getNumVectors();
460 GO indexBase = A->getRowMap()->getIndexBase();
465 RCP<MultiVector> fineNullspaceWithOverlap = MultiVectorFactory::Build(nonUniqueMap, NSDim);
466 fineNullspaceWithOverlap->doImport(*fineNullspace, *importer,
Xpetra::INSERT);
470 for (
size_t i = 0; i < NSDim; ++i)
471 fineNS[i] = fineNullspaceWithOverlap->getData(i);
474 coarseNullspace = MultiVectorFactory::Build(coarseMap, NSDim);
477 for (
size_t i = 0; i < NSDim; ++i)
478 if (coarseMap->getLocalNumElements() > 0) coarseNS[i] = coarseNullspace->getDataNonConst(i);
484 const Map& rowMapForPtentRef = *rowMapForPtent;
499 for (
LO j = 0; j < numAggs; ++j) {
500 for (
LO k = aggStart[j]; k < aggStart[j + 1]; ++k) {
501 if (rowMapForPtentRef.isNodeGlobalElement(aggToRowMap[k]) ==
false) {
506 ghostQMap = MapFactory::Build(A->getRowMap()->lib(),
509 indexBase, A->getRowMap()->getComm());
511 ghostQvalues = MultiVectorFactory::Build(ghostQMap, NSDim);
515 ghostQcolumns.
resize(NSDim);
516 for (
size_t i = 0; i < NSDim; ++i)
519 if (ghostQvalues->getLocalLength() > 0) {
522 for (
size_t i = 0; i < NSDim; ++i) {
523 ghostQvals[i] = ghostQvalues->getDataNonConst(i);
524 ghostQcols[i] = ghostQcolumns[i]->getDataNonConst(0);
526 ghostQrows = ghostQrowNums->getDataNonConst(0);
530 importer = ImportFactory::Build(ghostQMap, A->getRowMap());
536 Array<GO> globalColPtr(maxAggSize * NSDim, 0);
537 Array<LO> localColPtr(maxAggSize * NSDim, 0);
538 Array<SC> valPtr(maxAggSize * NSDim, 0.);
541 const Map& coarseMapRef = *coarseMap;
561 PtentCrs = PtentCrsWrap->getCrsMatrix();
562 Ptentative = PtentCrsWrap;
568 const Map& nonUniqueMapRef = *nonUniqueMap;
570 size_t total_nnz_count = 0;
572 for (
GO agg = 0; agg < numAggs; ++agg) {
573 LO myAggSize = aggStart[agg + 1] - aggStart[agg];
577 for (
size_t j = 0; j < NSDim; ++j) {
578 bool bIsZeroNSColumn =
true;
579 for (
LO k = 0; k < myAggSize; ++k) {
583 SC nsVal = fineNS[j][nonUniqueMapRef.getLocalElement(aggToRowMap[aggStart[agg] + k])];
584 localQR(k, j) = nsVal;
585 if (nsVal != zero) bIsZeroNSColumn =
false;
587 GetOStream(
Runtime1, -1) <<
"length of fine level nsp: " << fineNullspace->getGlobalLength() << std::endl;
588 GetOStream(
Runtime1, -1) <<
"length of fine level nsp w overlap: " << fineNullspaceWithOverlap->getGlobalLength() << std::endl;
589 GetOStream(
Runtime1, -1) <<
"(local?) aggId=" << agg << std::endl;
590 GetOStream(
Runtime1, -1) <<
"aggSize=" << myAggSize << std::endl;
591 GetOStream(
Runtime1, -1) <<
"agg DOF=" << k << std::endl;
592 GetOStream(
Runtime1, -1) <<
"NS vector j=" << j << std::endl;
593 GetOStream(
Runtime1, -1) <<
"j*myAggSize + k = " << j * myAggSize + k << std::endl;
594 GetOStream(
Runtime1, -1) <<
"aggToRowMap[" << agg <<
"][" << k <<
"] = " << aggToRowMap[aggStart[agg] + k] << std::endl;
595 GetOStream(
Runtime1, -1) <<
"id aggToRowMap[agg][k]=" << aggToRowMap[aggStart[agg] + k] <<
" is global element in nonUniqueMap = " << nonUniqueMapRef.isNodeGlobalElement(aggToRowMap[aggStart[agg] + k]) << std::endl;
596 GetOStream(
Runtime1, -1) <<
"colMap local id aggToRowMap[agg][k]=" << nonUniqueMapRef.getLocalElement(aggToRowMap[aggStart[agg] + k]) << std::endl;
597 GetOStream(
Runtime1, -1) <<
"fineNS...=" << fineNS[j][nonUniqueMapRef.getLocalElement(aggToRowMap[aggStart[agg] + k])] << std::endl;
598 GetOStream(
Errors, -1) <<
"caught an error!" << std::endl;
606 if (myAggSize >= Teuchos::as<LocalOrdinal>(NSDim)) {
611 SC tau = localQR(0, 0);
616 for (
size_t k = 0; k < Teuchos::as<size_t>(myAggSize); ++k) {
617 Magnitude tmag = STS::magnitude(localQR(k, 0));
618 dtemp += tmag * tmag;
622 localQR(0, 0) = dtemp;
631 for (
size_t j = 0; j < NSDim; ++j) {
632 for (
size_t k = 0; k <= j; ++k) {
634 if (coarseMapRef.isNodeLocalElement(offset + k)) {
635 coarseNS[j][offset + k] = localQR(k, j);
638 GetOStream(
Errors, -1) <<
"caught error in coarseNS insert, j=" << j <<
", offset+k = " << offset + k << std::endl;
652 localQR(i, 0) *= dtemp;
657 for (
size_t j = 0; j < NSDim; j++) {
658 for (
size_t i = 0; i < Teuchos::as<size_t>(myAggSize); i++) {
659 localQR(i, j) = (*qFactor)(i, j);
669 for (
size_t j = 0; j < NSDim; j++)
670 for (
size_t k = 0; k < NSDim; k++) {
672 "Caught error in coarseNS insert, j=" << j <<
", offset+k = " << offset + k);
674 if (k < as<size_t>(myAggSize))
675 coarseNS[j][offset + k] = localQR(k, j);
677 coarseNS[j][offset + k] = (k == j ? one : zero);
681 for (
size_t i = 0; i < as<size_t>(myAggSize); i++)
682 for (
size_t j = 0; j < NSDim; j++)
683 localQR(i, j) = (j == i ? one : zero);
690 for (
GO j = 0; j < myAggSize; ++j) {
694 GO globalRow = aggToRowMap[aggStart[agg] + j];
697 if (rowMapForPtentRef.isNodeGlobalElement(globalRow) ==
false) {
698 ghostQrows[qctr] = globalRow;
699 for (
size_t k = 0; k < NSDim; ++k) {
700 ghostQcols[k][qctr] = coarseMapRef.getGlobalElement(agg * NSDim + k);
701 ghostQvals[k][qctr] = localQR(j, k);
706 for (
size_t k = 0; k < NSDim; ++k) {
709 localColPtr[nnz] = agg * NSDim + k;
710 globalColPtr[nnz] = coarseMapRef.getGlobalElement(localColPtr[nnz]);
711 valPtr[nnz] = localQR(j, k);
716 GetOStream(
Errors, -1) <<
"caught error in colPtr/valPtr insert, current index=" << nnz << std::endl;
721 Ptentative->insertGlobalValues(globalRow, globalColPtr.
view(0, nnz), valPtr.
view(0, nnz));
723 GetOStream(
Errors, -1) <<
"pid " << A->getRowMap()->getComm()->getRank()
724 <<
"caught error during Ptent row insertion, global row "
725 << globalRow << std::endl;
735 GetOStream(
Runtime1) <<
"TentativePFactory : aggregates may cross process boundaries" << std::endl;
739 targetQrowNums->putScalar(-1);
740 targetQrowNums->doImport(*ghostQrowNums, *importer,
Xpetra::INSERT);
741 ArrayRCP<GO> targetQrows = targetQrowNums->getDataNonConst(0);
751 RCP<const Map> reducedMap = MapFactory::Build(A->getRowMap()->lib(),
753 gidsToImport, indexBase, A->getRowMap()->getComm());
756 importer = ImportFactory::Build(ghostQMap, reducedMap);
759 for (
size_t i = 0; i < NSDim; ++i) {
761 targetQcolumns[i]->doImport(*(ghostQcolumns[i]), *importer,
Xpetra::INSERT);
763 RCP<MultiVector> targetQvalues = MultiVectorFactory::Build(reducedMap, NSDim);
764 targetQvalues->doImport(*ghostQvalues, *importer,
Xpetra::INSERT);
768 if (targetQvalues->getLocalLength() > 0) {
769 targetQvals.
resize(NSDim);
770 targetQcols.
resize(NSDim);
771 for (
size_t i = 0; i < NSDim; ++i) {
772 targetQvals[i] = targetQvalues->getDataNonConst(i);
773 targetQcols[i] = targetQcolumns[i]->getDataNonConst(0);
780 if (targetQvalues->getLocalLength() > 0) {
781 for (
size_t j = 0; j < NSDim; ++j) {
782 valPtr[j] = targetQvals[j][reducedMap->getLocalElement(*r)];
783 globalColPtr[j] = targetQcols[j][reducedMap->getLocalElement(*r)];
785 Ptentative->insertGlobalValues(*r, globalColPtr.
view(0, NSDim), valPtr.
view(0, NSDim));
789 Ptentative->fillComplete(coarseMap, A->getDomainMap());
792 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
798 const size_t numRows = rowMap->getLocalNumElements();
801 typedef typename STS::magnitudeType Magnitude;
802 const SC zero = STS::zero();
803 const SC one = STS::one();
807 const size_t NSDim = fineNullspace->getNumVectors();
812 const bool&
doQRStep = pL.
get<
bool>(
"tentative: calculate qr");
813 const bool& constantColSums = pL.
get<
bool>(
"tentative: constant column sums");
816 "MueLu::TentativePFactory::MakeTentative: cannot use 'constant column sums' and 'calculate qr' at the same time");
832 GetOStream(
Runtime1) <<
"Column map is consistent with the row map, good." << std::endl;
836 GetOStream(
Warnings0) <<
"Column map is not consistent with the row map\n"
837 <<
"using GO->LO conversion with performance penalty" << std::endl;
839 coarseNullspace = MultiVectorFactory::Build(coarseMap, NSDim);
844 for (
size_t i = 0; i < NSDim; i++) {
845 fineNS[i] = fineNullspace->getData(i);
846 if (coarseMap->getLocalNumElements() > 0)
847 coarseNS[i] = coarseNullspace->getDataNonConst(i);
850 size_t nnzEstimate = numRows * NSDim;
853 Ptentative =
rcp(
new CrsMatrixWrap(rowMap, coarseMap, 0));
854 RCP<CrsMatrix> PtentCrs = rcp_dynamic_cast<CrsMatrixWrap>(Ptentative)->getCrsMatrix();
860 PtentCrs->allocateAllValues(nnzEstimate, iaPtent, jaPtent, valPtent);
867 for (
size_t i = 1; i <= numRows; i++)
868 ia[i] = ia[i - 1] + NSDim;
870 for (
size_t j = 0; j < nnzEstimate; j++) {
879 for (
GO agg = 0; agg < numAggs; agg++) {
880 LO aggSize = aggStart[agg + 1] - aggStart[agg];
889 for (
size_t j = 0; j < NSDim; j++)
890 for (
LO k = 0; k < aggSize; k++)
891 localQR(k, j) = fineNS[j][aggToRowMapLO[aggStart[agg] + k]];
893 for (
size_t j = 0; j < NSDim; j++)
894 for (
LO k = 0; k < aggSize; k++)
895 localQR(k, j) = fineNS[j][rowMap->getLocalElement(aggToRowMapGO[aggStart[agg] + k])];
899 for (
size_t j = 0; j < NSDim; j++) {
900 bool bIsZeroNSColumn =
true;
902 for (
LO k = 0; k < aggSize; k++)
903 if (localQR(k, j) != zero)
904 bIsZeroNSColumn =
false;
907 "MueLu::TentativePFactory::MakeTentative: fine level NS part has a zero column in NS column " << j);
912 if (aggSize >= Teuchos::as<LO>(NSDim)) {
915 Magnitude norm = STS::magnitude(zero);
916 for (
size_t k = 0; k < Teuchos::as<size_t>(aggSize); k++)
917 norm += STS::magnitude(localQR(k, 0) * localQR(k, 0));
921 coarseNS[0][offset] = norm;
924 for (
LO i = 0; i < aggSize; i++)
925 localQR(i, 0) /= norm;
933 for (
size_t j = 0; j < NSDim; j++)
934 for (
size_t k = 0; k <= j; k++)
935 coarseNS[j][offset + k] = localQR(k, j);
941 for (
size_t j = 0; j < NSDim; j++)
942 for (
size_t i = 0; i < Teuchos::as<size_t>(aggSize); i++)
943 localQR(i, j) = (*qFactor)(i, j);
974 for (
size_t j = 0; j < NSDim; j++)
975 for (
size_t k = 0; k < NSDim; k++)
976 if (k < as<size_t>(aggSize))
977 coarseNS[j][offset + k] = localQR(k, j);
979 coarseNS[j][offset + k] = (k == j ? one : zero);
982 for (
size_t i = 0; i < as<size_t>(aggSize); i++)
983 for (
size_t j = 0; j < NSDim; j++)
984 localQR(i, j) = (j == i ? one : zero);
989 for (
LO j = 0; j < aggSize; j++) {
990 LO localRow = (goodMap ? aggToRowMapLO[aggStart[agg] + j] : rowMap->getLocalElement(aggToRowMapGO[aggStart[agg] + j]));
992 size_t rowStart = ia[localRow];
993 for (
size_t k = 0, lnnz = 0; k < NSDim; k++) {
995 if (localQR(j, k) != zero) {
996 ja[rowStart + lnnz] = offset + k;
997 val[rowStart + lnnz] = localQR(j, k);
1005 GetOStream(
Runtime1) <<
"TentativePFactory : bypassing local QR phase" << std::endl;
1007 GetOStream(
Warnings0) <<
"TentativePFactory : for nontrivial nullspace, this may degrade performance" << std::endl;
1017 for (
GO agg = 0; agg < numAggs; agg++) {
1018 const LO aggSize = aggStart[agg + 1] - aggStart[agg];
1023 for (
LO j = 0; j < aggSize; j++) {
1027 const LO localRow = aggToRowMapLO[aggStart[agg] + j];
1029 const size_t rowStart = ia[localRow];
1031 for (
size_t k = 0, lnnz = 0; k < NSDim; k++) {
1033 SC qr_jk = fineNS[k][aggToRowMapLO[aggStart[agg] + j]];
1034 if (constantColSums) qr_jk = qr_jk / (Magnitude)aggSizes[agg];
1035 if (qr_jk != zero) {
1036 ja[rowStart + lnnz] = offset + k;
1037 val[rowStart + lnnz] = qr_jk;
1042 for (
size_t j = 0; j < NSDim; j++)
1043 coarseNS[j][offset + j] = one;
1047 for (
GO agg = 0; agg < numAggs; agg++) {
1048 const LO aggSize = aggStart[agg + 1] - aggStart[agg];
1050 for (
LO j = 0; j < aggSize; j++) {
1051 const LO localRow = rowMap->getLocalElement(aggToRowMapGO[aggStart[agg] + j]);
1053 const size_t rowStart = ia[localRow];
1055 for (
size_t k = 0, lnnz = 0; k < NSDim; ++k) {
1057 SC qr_jk = fineNS[k][rowMap->getLocalElement(aggToRowMapGO[aggStart[agg] + j])];
1058 if (constantColSums) qr_jk = qr_jk / (Magnitude)aggSizes[agg];
1059 if (qr_jk != zero) {
1060 ja[rowStart + lnnz] = offset + k;
1061 val[rowStart + lnnz] = qr_jk;
1066 for (
size_t j = 0; j < NSDim; j++)
1067 coarseNS[j][offset + j] = one;
1076 size_t ia_tmp = 0, nnz = 0;
1077 for (
size_t i = 0; i < numRows; i++) {
1078 for (
size_t j = ia_tmp; j < ia[i + 1]; j++)
1079 if (ja[j] != INVALID) {
1095 GetOStream(
Runtime1) <<
"TentativePFactory : aggregates do not cross process boundaries" << std::endl;
1097 PtentCrs->setAllValues(iaPtent, jaPtent, valPtent);
1101 if (pL.
isSublist(
"matrixmatrix: kernel params"))
1106 FCparams->
set(
"compute global constants", FCparams->
get(
"compute global constants",
false));
1107 std::string levelIDs =
toString(levelID);
1108 FCparams->
set(
"Timer Label", std::string(
"MueLu::TentativeP-") + levelIDs);
1112 PtentCrs->expertStaticFillComplete(coarseMap, A->getDomainMap(), dummy_i, dummy_e, FCparams);
1119 #define MUELU_TENTATIVEPFACTORY_SHORT
1120 #endif // MUELU_TENTATIVEPFACTORY_DEF_HPP
void BuildPuncoupled(RCP< Matrix > A, RCP< Aggregates > aggregates, RCP< AmalgamationInfo > amalgInfo, RCP< MultiVector > fineNullspace, RCP< const Map > coarseMap, RCP< Matrix > &Ptentative, RCP< MultiVector > &coarseNullspace, const int levelID) const
void Build(Level &fineLevel, Level &coarseLevel) const
Build an object with this factory.
Important warning messages (one line)
void reserve(size_type n)
MueLu::DefaultLocalOrdinal LocalOrdinal
int setMatrix(const RCP< SerialDenseMatrix< OrdinalType, ScalarType > > &A)
static bool MapsAreNested(const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &rowMap, const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &colMap)
void BuildPcoupled(RCP< Matrix > A, RCP< Aggregates > aggregates, RCP< AmalgamationInfo > amalgInfo, RCP< MultiVector > fineNullspace, RCP< const Map > coarseMap, RCP< Matrix > &Ptentative, RCP< MultiVector > &coarseNullspace) const
std::string toString(const T &what)
Little helper function to convert non-string types to strings.
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
void DeclareInput(Level &fineLevel, Level &coarseLevel) const
Input.
KOKKOS_INLINE_FUNCTION LO GetNumAggregates() const
T & get(const std::string &name, T def_value)
void UnamalgamateAggregates(const Aggregates &aggregates, Teuchos::ArrayRCP< LocalOrdinal > &aggStart, Teuchos::ArrayRCP< GlobalOrdinal > &aggToRowMap) const
UnamalgamateAggregates.
ArrayView< T > view(size_type offset, size_type size)
Timer to be used in factories. Similar to Monitor but with additional timers.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void UnamalgamateAggregatesLO(const Aggregates &aggregates, Teuchos::ArrayRCP< LocalOrdinal > &aggStart, Teuchos::ArrayRCP< LO > &aggToRowMap) const
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
static const NoFactory * get()
Print even more statistics.
#define SET_VALID_ENTRY(name)
void resize(const size_type n, const T &val=T())
bool isParameter(const std::string &name) const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Class that holds all level-specific information.
Teuchos::RCP< Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > ComputeUnamalgamatedImportDofMap(const Aggregates &aggregates) const
ComputeUnamalgamatedImportDofMap build overlapping dof row map from aggregates needed for overlapping...
bool isSublist(const std::string &name) const
Teuchos::ArrayRCP< LocalOrdinal > ComputeAggregateSizesArrayRCP(bool forceRecompute=false) const
Compute sizes of aggregates.
void resize(size_type new_size, const value_type &x=value_type())
static std::string PrintMatrixInfo(const Matrix &A, const std::string &msgTag, RCP< const Teuchos::ParameterList > params=Teuchos::null)
static bool isnaninf(const T &x)
static RCP< Vector > Build(const Teuchos::RCP< const Map > &map, bool zeroOut=true)
static magnitudeType magnitude(T a)
void push_back(const value_type &x)
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
void BuildPuncoupledBlockCrs(RCP< Matrix > A, RCP< Aggregates > aggregates, RCP< AmalgamationInfo > amalgInfo, RCP< MultiVector > fineNullspace, RCP< const Map > coarseMap, RCP< Matrix > &Ptentative, RCP< MultiVector > &coarseNullspace, const int levelID) const
int GetLevelID() const
Return level number.
RCP< SerialDenseMatrix< OrdinalType, ScalarType > > getQ() const
Exception throws to report errors in the internal logical of the program.
void BuildP(Level &fineLevel, Level &coarseLevel) const
Abstract Build method.
Description of what is happening (more verbose)
bool IsAvailable(const std::string &ename, const FactoryBase *factory=NoFactory::get()) const
Test whether a need's value has been saved.