46 #ifndef MUELU_IFPACK2SMOOTHER_DEF_HPP 47 #define MUELU_IFPACK2SMOOTHER_DEF_HPP 51 #if defined(HAVE_MUELU_TPETRA) && defined(HAVE_MUELU_IFPACK2) 53 #include <Teuchos_ParameterList.hpp> 55 #include <Tpetra_RowMatrix.hpp> 57 #include <Ifpack2_Chebyshev.hpp> 58 #include <Ifpack2_Relaxation.hpp> 59 #include <Ifpack2_ILUT.hpp> 60 #include <Ifpack2_BlockRelaxation.hpp> 61 #include <Ifpack2_Factory.hpp> 62 #include <Ifpack2_Parameters.hpp> 64 #include <Xpetra_BlockedCrsMatrix.hpp> 65 #include <Xpetra_CrsMatrix.hpp> 66 #include <Xpetra_CrsMatrixWrap.hpp> 67 #include <Xpetra_Matrix.hpp> 68 #include <Xpetra_MultiVectorFactory.hpp> 69 #include <Xpetra_TpetraMultiVector.hpp> 74 #include "MueLu_Utilities.hpp" 77 #ifdef HAVE_MUELU_INTREPID2 80 #include "Intrepid2_Basis.hpp" 81 #include "Kokkos_DynRankView.hpp" 88 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
90 : type_(type), overlap_(overlap)
95 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
106 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
108 ParameterList& paramList =
const_cast<ParameterList&
>(this->GetParameterList());
109 paramList.setParameters(list);
111 RCP<ParameterList> precList = this->RemoveFactoriesFromList(this->GetParameterList());
113 prec_->setParameters(*precList);
115 paramList.setParameters(*precList);
118 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
120 this->Input(currentLevel,
"A");
122 if (type_ ==
"LINESMOOTHING_TRIDI_RELAXATION" ||
123 type_ ==
"LINESMOOTHING_TRIDI RELAXATION" ||
124 type_ ==
"LINESMOOTHING_TRIDIRELAXATION" ||
125 type_ ==
"LINESMOOTHING_TRIDIAGONAL_RELAXATION" ||
126 type_ ==
"LINESMOOTHING_TRIDIAGONAL RELAXATION" ||
127 type_ ==
"LINESMOOTHING_TRIDIAGONALRELAXATION" ||
128 type_ ==
"LINESMOOTHING_BANDED_RELAXATION" ||
129 type_ ==
"LINESMOOTHING_BANDED RELAXATION" ||
130 type_ ==
"LINESMOOTHING_BANDEDRELAXATION" ||
131 type_ ==
"LINESMOOTHING_BLOCK_RELAXATION" ||
132 type_ ==
"LINESMOOTHING_BLOCK RELAXATION" ||
133 type_ ==
"LINESMOOTHING_BLOCKRELAXATION") {
134 this->Input(currentLevel,
"CoarseNumZLayers");
135 this->Input(currentLevel,
"LineDetection_VertLineIds");
137 else if (type_ ==
"BLOCK RELAXATION" ||
138 type_ ==
"BLOCK_RELAXATION" ||
139 type_ ==
"BLOCKRELAXATION")
142 ParameterList precList = this->GetParameterList();
143 if(precList.isParameter(
"partitioner: type") &&
144 precList.get<std::string>(
"partitioner: type") ==
"line") {
145 this->Input(currentLevel,
"Coordinates");
148 else if (type_ ==
"TOPOLOGICAL")
151 this->Input(currentLevel,
"pcoarsen: element to node map");
155 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
159 A_ = Factory::Get< RCP<Matrix> >(currentLevel,
"A");
161 if (type_ ==
"SCHWARZ")
162 SetupSchwarz(currentLevel);
164 else if (type_ ==
"LINESMOOTHING_TRIDI_RELAXATION" ||
165 type_ ==
"LINESMOOTHING_TRIDI RELAXATION" ||
166 type_ ==
"LINESMOOTHING_TRIDIRELAXATION" ||
167 type_ ==
"LINESMOOTHING_TRIDIAGONAL_RELAXATION" ||
168 type_ ==
"LINESMOOTHING_TRIDIAGONAL RELAXATION" ||
169 type_ ==
"LINESMOOTHING_TRIDIAGONALRELAXATION" ||
170 type_ ==
"LINESMOOTHING_BANDED_RELAXATION" ||
171 type_ ==
"LINESMOOTHING_BANDED RELAXATION" ||
172 type_ ==
"LINESMOOTHING_BANDEDRELAXATION" ||
173 type_ ==
"LINESMOOTHING_BLOCK_RELAXATION" ||
174 type_ ==
"LINESMOOTHING_BLOCK RELAXATION" ||
175 type_ ==
"LINESMOOTHING_BLOCKRELAXATION")
176 SetupLineSmoothing(currentLevel);
178 else if (type_ ==
"BLOCK_RELAXATION" ||
179 type_ ==
"BLOCK RELAXATION" ||
180 type_ ==
"BLOCKRELAXATION")
181 SetupBlockRelaxation(currentLevel);
183 else if (type_ ==
"CHEBYSHEV")
184 SetupChebyshev(currentLevel);
186 else if (type_ ==
"TOPOLOGICAL")
188 #ifdef HAVE_MUELU_INTREPID2 189 SetupTopological(currentLevel);
191 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"'TOPOLOGICAL' smoother choice requires Intrepid2");
196 SetupGeneric(currentLevel);
201 this->GetOStream(
Statistics1) << description() << std::endl;
204 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
206 typedef Tpetra::RowMatrix<SC,LO,GO,NO> tRowMatrix;
208 bool reusePreconditioner =
false;
209 if (this->IsSetup() ==
true) {
211 this->GetOStream(
Runtime1) <<
"MueLu::Ifpack2Smoother::SetupSchwarz(): Setup() has already been called, assuming reuse" << std::endl;
213 bool isTRowMatrix =
true;
214 RCP<const tRowMatrix> tA;
218 isTRowMatrix =
false;
221 RCP<Ifpack2::Details::CanChangeMatrix<tRowMatrix> > prec = rcp_dynamic_cast<Ifpack2::Details::CanChangeMatrix<tRowMatrix> >(prec_);
222 if (!prec.is_null() && isTRowMatrix) {
223 #ifdef IFPACK2_HAS_PROPER_REUSE 224 prec->resetMatrix(tA);
225 reusePreconditioner =
true;
227 this->GetOStream(
Errors) <<
"Ifpack2 does not have proper reuse yet." << std::endl;
231 this->GetOStream(
Warnings0) <<
"MueLu::Ifpack2Smoother::SetupSchwarz(): reuse of this type is not available " 232 "(either failed cast to CanChangeMatrix, or to Tpetra Row Matrix), reverting to full construction" << std::endl;
236 if (!reusePreconditioner) {
237 ParameterList& paramList =
const_cast<ParameterList&
>(this->GetParameterList());
239 bool isBlockedMatrix =
false;
240 RCP<Matrix> merged2Mat;
242 std::string sublistName =
"subdomain solver parameters";
243 if (paramList.isSublist(sublistName)) {
252 ParameterList& subList = paramList.sublist(sublistName);
254 std::string partName =
"partitioner: type";
255 if (subList.isParameter(partName) && subList.get<std::string>(partName) ==
"user") {
256 isBlockedMatrix =
true;
258 RCP<BlockedCrsMatrix> bA = rcp_dynamic_cast<BlockedCrsMatrix>(A_);
260 "Matrix A must be of type BlockedCrsMatrix.");
262 size_t numVels = bA->getMatrix(0,0)->getNodeNumRows();
263 size_t numPres = bA->getMatrix(1,0)->getNodeNumRows();
264 size_t numRows = A_->getNodeNumRows();
266 ArrayRCP<LocalOrdinal> blockSeeds(numRows, Teuchos::OrdinalTraits<LocalOrdinal>::invalid());
268 size_t numBlocks = 0;
269 for (
size_t rowOfB = numVels; rowOfB < numVels+numPres; ++rowOfB)
270 blockSeeds[rowOfB] = numBlocks++;
272 RCP<BlockedCrsMatrix> bA2 = rcp_dynamic_cast<BlockedCrsMatrix>(A_);
274 "Matrix A must be of type BlockedCrsMatrix.");
276 merged2Mat = bA2->Merge();
280 bool haveBoundary =
false;
281 for (LO i = 0; i < boundaryNodes.size(); i++)
282 if (boundaryNodes[i]) {
286 blockSeeds[i] = numBlocks;
292 subList.set(
"partitioner: map", blockSeeds);
293 subList.set(
"partitioner: local parts", as<int>(numBlocks));
296 RCP<BlockedCrsMatrix> bA = rcp_dynamic_cast<BlockedCrsMatrix>(A_);
298 isBlockedMatrix =
true;
299 merged2Mat = bA->Merge();
304 RCP<const tRowMatrix> tA;
308 prec_ = Ifpack2::Factory::create(type_, tA, overlap_);
317 #ifdef HAVE_MUELU_INTREPID2 318 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
328 if (this->IsSetup() ==
true) {
329 this->GetOStream(
Warnings0) <<
"MueLu::Ifpack2Smoother::SetupTopological(): Setup() has already been called" << std::endl;
330 this->GetOStream(
Warnings0) <<
"MueLu::Ifpack2Smoother::SetupTopological(): reuse of this type is not available, reverting to full construction" << std::endl;
333 ParameterList& paramList =
const_cast<ParameterList&
>(this->GetParameterList());
335 typedef typename Node::device_type::execution_space ES;
337 typedef Kokkos::DynRankView<LocalOrdinal,typename Node::device_type> FCO;
339 LocalOrdinal lo_invalid = Teuchos::OrdinalTraits<LO>::invalid();
343 const Teuchos::RCP<FCO> elemToNode = Factory::Get<Teuchos::RCP<FCO> >(currentLevel,
"pcoarsen: element to node map");
345 string basisString = paramList.get<
string>(
"pcoarsen: hi basis");
351 auto basis = MueLuIntrepid::BasisFactory<double,ES>(basisString, degree);
353 string topologyTypeString = paramList.get<
string>(
"smoother: neighborhood type");
355 if (topologyTypeString ==
"node")
357 else if (topologyTypeString ==
"edge")
359 else if (topologyTypeString ==
"face")
361 else if (topologyTypeString ==
"cell")
362 dimension = basis->getBaseCellTopology().getDimension();
364 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
"Unrecognized smoother neighborhood type. Supported types are node, edge, face.");
365 vector<vector<LocalOrdinal>> seeds;
370 int myNodeCount = A_->getRowMap()->getNodeNumElements();
371 ArrayRCP<LocalOrdinal> nodeSeeds(myNodeCount,lo_invalid);
372 int localPartitionNumber = 0;
373 for (LocalOrdinal seed : seeds[dimension])
375 nodeSeeds[seed] = localPartitionNumber++;
378 paramList.remove(
"smoother: neighborhood type");
379 paramList.remove(
"pcoarsen: hi basis");
381 paramList.set(
"partitioner: map", nodeSeeds);
382 paramList.set(
"partitioner: type",
"user");
383 paramList.set(
"partitioner: overlap", 1);
384 paramList.set(
"partitioner: local parts",
int(seeds[dimension].size()));
388 type_ =
"BLOCKRELAXATION";
389 prec_ = Ifpack2::Factory::create(type_, tA, overlap_);
396 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
398 if (this->IsSetup() ==
true) {
399 this->GetOStream(
Warnings0) <<
"MueLu::Ifpack2Smoother::SetupLineSmoothing(): Setup() has already been called" << std::endl;
400 this->GetOStream(
Warnings0) <<
"MueLu::Ifpack2Smoother::SetupLineSmoothing(): reuse of this type is not available, reverting to full construction" << std::endl;
403 ParameterList& myparamList =
const_cast<ParameterList&
>(this->GetParameterList());
405 LO CoarseNumZLayers = Factory::Get<LO>(currentLevel,
"CoarseNumZLayers");
406 if (CoarseNumZLayers > 0) {
407 Teuchos::ArrayRCP<LO> TVertLineIdSmoo = Factory::Get< Teuchos::ArrayRCP<LO> >(currentLevel,
"LineDetection_VertLineIds");
411 for(
size_t k = 0; k < Teuchos::as<size_t>(TVertLineIdSmoo.size()); k++) {
412 if(maxPart < TVertLineIdSmoo[k]) maxPart = TVertLineIdSmoo[k];
415 size_t numLocalRows = A_->getNodeNumRows();
417 "MueLu::Ifpack2Smoother::Setup(): the number of local nodes is incompatible with the TVertLineIdsSmoo.");
419 if (numLocalRows == Teuchos::as<size_t>(TVertLineIdSmoo.size())) {
420 myparamList.set(
"partitioner: type",
"user");
421 myparamList.set(
"partitioner: map",TVertLineIdSmoo);
422 myparamList.set(
"partitioner: local parts",maxPart+1);
425 size_t numDofsPerNode = numLocalRows / TVertLineIdSmoo.size();
428 Teuchos::ArrayRCP<LO> partitionerMap(numLocalRows, Teuchos::OrdinalTraits<LocalOrdinal>::invalid());
429 for (
size_t blockRow = 0; blockRow < Teuchos::as<size_t>(TVertLineIdSmoo.size()); ++blockRow)
430 for (
size_t dof = 0; dof < numDofsPerNode; dof++)
431 partitionerMap[blockRow * numDofsPerNode + dof] = TVertLineIdSmoo[blockRow];
432 myparamList.set(
"partitioner: type",
"user");
433 myparamList.set(
"partitioner: map",partitionerMap);
434 myparamList.set(
"partitioner: local parts",maxPart + 1);
437 if (type_ ==
"LINESMOOTHING_BANDED_RELAXATION" ||
438 type_ ==
"LINESMOOTHING_BANDED RELAXATION" ||
439 type_ ==
"LINESMOOTHING_BANDEDRELAXATION")
440 type_ =
"BANDEDRELAXATION";
441 else if (type_ ==
"LINESMOOTHING_TRIDI_RELAXATION" ||
442 type_ ==
"LINESMOOTHING_TRIDI RELAXATION" ||
443 type_ ==
"LINESMOOTHING_TRIDIRELAXATION" ||
444 type_ ==
"LINESMOOTHING_TRIDIAGONAL_RELAXATION" ||
445 type_ ==
"LINESMOOTHING_TRIDIAGONAL RELAXATION" ||
446 type_ ==
"LINESMOOTHING_TRIDIAGONALRELAXATION")
447 type_ =
"TRIDIAGONALRELAXATION";
449 type_ =
"BLOCKRELAXATION";
452 this->GetOStream(
Runtime0) <<
"Line detection failed: fall back to point-wise relaxation" << std::endl;
453 myparamList.remove(
"partitioner: type",
false);
454 myparamList.remove(
"partitioner: map",
false);
455 myparamList.remove(
"partitioner: local parts",
false);
456 type_ =
"RELAXATION";
461 prec_ = Ifpack2::Factory::create(type_, tA, overlap_);
467 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
469 typedef Tpetra::RowMatrix<SC,LO,GO,NO> tRowMatrix;
471 RCP<BlockedCrsMatrix> bA = rcp_dynamic_cast<BlockedCrsMatrix>(A_);
477 bool reusePreconditioner =
false;
478 if (this->IsSetup() ==
true) {
480 this->GetOStream(
Runtime1) <<
"MueLu::Ifpack2Smoother::SetupGeneric(): Setup() has already been called, assuming reuse" << std::endl;
482 RCP<Ifpack2::Details::CanChangeMatrix<tRowMatrix> > prec = rcp_dynamic_cast<Ifpack2::Details::CanChangeMatrix<tRowMatrix> >(prec_);
483 if (!prec.is_null()) {
484 #ifdef IFPACK2_HAS_PROPER_REUSE 485 prec->resetMatrix(tA);
486 reusePreconditioner =
true;
488 this->GetOStream(
Errors) <<
"Ifpack2 does not have proper reuse yet." << std::endl;
492 this->GetOStream(
Warnings0) <<
"MueLu::Ifpack2Smoother::SetupSchwarz(): reuse of this type is not available (failed cast to CanChangeMatrix), " 493 "reverting to full construction" << std::endl;
497 if (!reusePreconditioner) {
498 ParameterList& myparamList =
const_cast<ParameterList&
>(this->GetParameterList());
500 if(myparamList.isParameter(
"partitioner: type") &&
501 myparamList.get<std::string>(
"partitioner: type") ==
"line") {
502 Teuchos::RCP<Xpetra::MultiVector<double,LO,GO,NO> > xCoordinates =
503 Factory::Get<Teuchos::RCP<Xpetra::MultiVector<double,LO,GO,NO> > >(currentLevel,
"Coordinates");
504 Teuchos::RCP<Tpetra::MultiVector<double,LO,GO,NO> > coordinates = Teuchos::rcpFromRef(Xpetra::toTpetra<double,LO,GO,NO>(*xCoordinates));
505 myparamList.set(
"partitioner: coordinates", coordinates);
508 prec_ = Ifpack2::Factory::create(type_, tA, overlap_);
516 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
518 if (this->IsSetup() ==
true) {
519 this->GetOStream(
Warnings0) <<
"MueLu::Ifpack2Smoother::SetupChebyshev(): SetupChebyshev() has already been called" << std::endl;
520 this->GetOStream(
Warnings0) <<
"MueLu::Ifpack2Smoother::SetupChebyshev(): reuse of this type is not available, reverting to full construction" << std::endl;
523 typedef Teuchos::ScalarTraits<SC> STS;
524 SC negone = -STS::one();
526 SC lambdaMax = negone;
528 std::string maxEigString =
"chebyshev: max eigenvalue";
529 std::string eigRatioString =
"chebyshev: ratio eigenvalue";
531 ParameterList& paramList =
const_cast<ParameterList&
>(this->GetParameterList());
534 if (paramList.isParameter(maxEigString)) {
535 if (paramList.isType<
double>(maxEigString))
536 lambdaMax = paramList.get<
double>(maxEigString);
538 lambdaMax = paramList.get<SC>(maxEigString);
539 this->GetOStream(
Statistics1) << maxEigString <<
" (cached with smoother parameter list) = " << lambdaMax << std::endl;
542 lambdaMax = A_->GetMaxEigenvalueEstimate();
543 if (lambdaMax != negone) {
544 this->GetOStream(
Statistics1) << maxEigString <<
" (cached with matrix) = " << lambdaMax << std::endl;
545 paramList.set(maxEigString, lambdaMax);
550 const SC defaultEigRatio = 20;
552 SC ratio = defaultEigRatio;
553 if (paramList.isParameter(eigRatioString)) {
554 if (paramList.isType<
double>(eigRatioString))
555 ratio = paramList.get<
double>(eigRatioString);
557 ratio = paramList.get<SC>(eigRatioString);
564 RCP<const Matrix> fineA = currentLevel.
GetPreviousLevel()->Get<RCP<Matrix> >(
"A");
565 size_t nRowsFine = fineA->getGlobalNumRows();
566 size_t nRowsCoarse = A_->getGlobalNumRows();
568 SC levelRatio = as<SC>(as<float>(nRowsFine)/nRowsCoarse);
569 if (STS::magnitude(levelRatio) > STS::magnitude(ratio))
573 this->GetOStream(
Statistics1) << eigRatioString <<
" (computed) = " << ratio << std::endl;
574 paramList.set(eigRatioString, ratio);
579 prec_ = Ifpack2::Factory::create(type_, tA, overlap_);
590 if (lambdaMax == negone) {
591 typedef Tpetra::RowMatrix<SC, LO, GO, NO> MatrixType;
593 Teuchos::RCP<Ifpack2::Chebyshev<MatrixType> > chebyPrec = rcp_dynamic_cast<Ifpack2::Chebyshev<MatrixType> >(prec_);
594 if (chebyPrec != Teuchos::null) {
595 lambdaMax = chebyPrec->getLambdaMaxForApply();
596 A_->SetMaxEigenvalueEstimate(lambdaMax);
597 this->GetOStream(
Statistics1) <<
"chebyshev: max eigenvalue (calculated by Ifpack2)" <<
" = " << lambdaMax << std::endl;
599 TEUCHOS_TEST_FOR_EXCEPTION(lambdaMax == negone,
Exceptions::RuntimeError,
"MueLu::Ifpack2Smoother::Setup(): no maximum eigenvalue estimate");
603 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
605 typedef Tpetra::RowMatrix<SC,LO,GO,NO> tRowMatrix;
607 RCP<BlockedCrsMatrix> bA = rcp_dynamic_cast<BlockedCrsMatrix>(A_);
613 bool reusePreconditioner =
false;
614 if (this->IsSetup() ==
true) {
616 this->GetOStream(
Runtime1) <<
"MueLu::Ifpack2Smoother::SetupGeneric(): Setup() has already been called, assuming reuse" << std::endl;
618 RCP<Ifpack2::Details::CanChangeMatrix<tRowMatrix> > prec = rcp_dynamic_cast<Ifpack2::Details::CanChangeMatrix<tRowMatrix> >(prec_);
619 if (!prec.is_null()) {
620 #ifdef IFPACK2_HAS_PROPER_REUSE 621 prec->resetMatrix(tA);
622 reusePreconditioner =
true;
624 this->GetOStream(
Errors) <<
"Ifpack2 does not have proper reuse yet." << std::endl;
628 this->GetOStream(
Warnings0) <<
"MueLu::Ifpack2Smoother::SetupSchwarz(): reuse of this type is not available (failed cast to CanChangeMatrix), " 629 "reverting to full construction" << std::endl;
633 if (!reusePreconditioner) {
634 prec_ = Ifpack2::Factory::create(type_, tA, overlap_);
642 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
655 Teuchos::ParameterList paramList;
656 bool supportInitialGuess =
false;
657 if (type_ ==
"CHEBYSHEV") {
658 paramList.set(
"chebyshev: zero starting solution", InitialGuessIsZero);
659 SetPrecParameters(paramList);
660 supportInitialGuess =
true;
662 }
else if (type_ ==
"RELAXATION") {
663 paramList.set(
"relaxation: zero starting solution", InitialGuessIsZero);
664 SetPrecParameters(paramList);
665 supportInitialGuess =
true;
667 }
else if (type_ ==
"KRYLOV") {
668 paramList.set(
"krylov: zero starting solution", InitialGuessIsZero);
669 SetPrecParameters(paramList);
670 supportInitialGuess =
true;
672 }
else if (type_ ==
"SCHWARZ") {
673 paramList.set(
"schwarz: zero starting solution", InitialGuessIsZero);
678 prec_->setParameters(paramList);
679 supportInitialGuess =
true;
689 if (InitialGuessIsZero || supportInitialGuess) {
692 prec_->apply(tpB, tpX);
694 typedef Teuchos::ScalarTraits<Scalar> TST;
696 RCP<MultiVector> Correction = MultiVectorFactory::Build(A_->getDomainMap(), X.getNumVectors());
701 prec_->apply(tpB, tpX);
703 X.update(TST::one(), *Correction, TST::one());
707 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
710 smoother->SetParameterList(this->GetParameterList());
714 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
716 std::ostringstream out;
718 out << prec_->description();
721 out <<
"{type = " << type_ <<
"}";
726 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
731 out0 <<
"Prec. type: " << type_ << std::endl;
734 out0 <<
"Parameter list: " << std::endl;
735 Teuchos::OSTab tab2(out);
736 out << this->GetParameterList();
737 out0 <<
"Overlap: " << overlap_ << std::endl;
741 if (prec_ != Teuchos::null) {
742 Teuchos::OSTab tab2(out);
743 out << *prec_ << std::endl;
746 if (verbLevel &
Debug) {
749 <<
"RCP<prec_>: " << prec_ << std::endl;
753 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
755 typedef Tpetra::RowMatrix<SC,LO,GO,NO> MatrixType;
757 RCP<Ifpack2::Relaxation<MatrixType> > pr = rcp_dynamic_cast<Ifpack2::Relaxation<MatrixType> >(prec_);
758 if(!pr.is_null())
return pr->getNodeSmootherComplexity();
760 RCP<Ifpack2::Chebyshev<MatrixType> > pc = rcp_dynamic_cast<Ifpack2::Chebyshev<MatrixType> >(prec_);
761 if(!pc.is_null())
return pc->getNodeSmootherComplexity();
763 RCP<Ifpack2::BlockRelaxation<MatrixType> > pb = rcp_dynamic_cast<Ifpack2::BlockRelaxation<MatrixType> >(prec_);
764 if(!pb.is_null())
return pb->getNodeSmootherComplexity();
766 RCP<Ifpack2::ILUT<MatrixType> > pi = rcp_dynamic_cast<Ifpack2::ILUT<MatrixType> >(prec_);
767 if(!pi.is_null())
return pi->getNodeSmootherComplexity();
769 RCP<Ifpack2::RILUK<MatrixType> > pk = rcp_dynamic_cast<Ifpack2::RILUK<MatrixType> >(prec_);
770 if(!pk.is_null())
return pk->getNodeSmootherComplexity();
773 return Teuchos::OrdinalTraits<size_t>::invalid();
779 #endif // HAVE_MUELU_TPETRA && HAVE_MUELU_IFPACK2 780 #endif // MUELU_IFPACK2SMOOTHER_DEF_HPP Important warning messages (one line)
void SetupGeneric(Level ¤tLevel)
RCP< SmootherPrototype > Copy() const
Exception indicating invalid cast attempted.
RCP< Level > & GetPreviousLevel()
Previous level.
void SetPrecParameters(const Teuchos::ParameterList &list=Teuchos::ParameterList()) const
void FindGeometricSeedOrdinals(Teuchos::RCP< Basis > basis, const LOFieldContainer &elementToNodeMap, std::vector< std::vector< LocalOrdinal > > &seeds, const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &rowMap, const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &columnMap)
static RCP< const Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > MV2TpetraMV(RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > const vec)
Helper utility to pull out the underlying Tpetra objects from an Xpetra object.
std::string toString(const T &what)
Little helper function to convert non-string types to strings.
std::string description() const
Return a simple one-line description of this object.
Print external lib objects.
bool IsSetup() const
Get the state of a smoother prototype.
friend class Ifpack2Smoother
Constructor.
static Teuchos::ArrayRCP< const bool > DetectDirichletRows(const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Magnitude &tol=Teuchos::ScalarTraits< Scalar >::magnitude(0.), const bool count_twos_as_dirichlet=false)
Timer to be used in factories. Similar to Monitor but with additional timers.
Print additional debugging information.
One-liner description of what is happening.
void SetParameterList(const Teuchos::ParameterList ¶mList)
Namespace for MueLu classes and methods.
static RCP< Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > MV2NonConstTpetraMV(RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > vec)
int GetLevelID() const
Return level number.
void SetupBlockRelaxation(Level ¤tLevel)
size_t getNodeSmootherComplexity() const
Get a rough estimate of cost per iteration.
void SetupSchwarz(Level ¤tLevel)
void SetupLineSmoothing(Level ¤tLevel)
static RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Residual(const Xpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Op, const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &RHS)
virtual void SetParameterList(const ParameterList ¶mList)
Set parameters from a parameter list and return with default values.
Class that holds all level-specific information.
void Setup(Level ¤tLevel)
Set up the smoother.
Timer to be used in factories. Similar to SubMonitor but adds a timer level by level.
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
Apply the preconditioner.
void SetupTopological(Level ¤tLevel)
void DeclareInput(Level ¤tLevel) const
Input.
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the object with some verbosity level to an FancyOStream object.
#define MUELU_DESCRIBE
Helper macro for implementing Describable::describe() for BaseClass objects.
Print class parameters (more parameters, more verbose)
Exception throws to report errors in the internal logical of the program.
void SetupChebyshev(Level ¤tLevel)
Description of what is happening (more verbose)
Class that encapsulates Ifpack2 smoothers.
static RCP< Tpetra::RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op2NonConstTpetraRow(RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op)
virtual std::string description() const
Return a simple one-line description of this object.