10#ifndef MUELU_SHIFTEDLAPLACIAN_DEF_HPP
11#define MUELU_SHIFTEDLAPLACIAN_DEF_HPP
15#if defined(HAVE_MUELU_IFPACK2) and defined(HAVE_MUELU_TPETRA)
17#include <MueLu_AmalgamationFactory.hpp>
18#include <MueLu_CoalesceDropFactory.hpp>
19#include <MueLu_CoarseMapFactory.hpp>
20#include <MueLu_CoupledRBMFactory.hpp>
21#include <MueLu_DirectSolver.hpp>
22#include <MueLu_GenericRFactory.hpp>
23#include <MueLu_Hierarchy.hpp>
24#include <MueLu_Ifpack2Smoother.hpp>
25#include <MueLu_PFactory.hpp>
26#include <MueLu_PgPFactory.hpp>
27#include <MueLu_RAPFactory.hpp>
28#include <MueLu_RAPShiftFactory.hpp>
29#include <MueLu_SaPFactory.hpp>
30#include <MueLu_ShiftedLaplacian.hpp>
31#include <MueLu_ShiftedLaplacianOperator.hpp>
32#include <MueLu_SmootherFactory.hpp>
33#include <MueLu_SmootherPrototype.hpp>
34#include <MueLu_TentativePFactory.hpp>
35#include <MueLu_TransPFactory.hpp>
36#include <MueLu_UncoupledAggregationFactory.hpp>
37#include <MueLu_Utilities.hpp>
42template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
46template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
50 numLevels_ = paramList->get(
"MueLu: levels", 3);
51 int stype = paramList->get(
"MueLu: smoother", 8);
54 }
else if (stype == 2) {
56 }
else if (stype == 3) {
58 }
else if (stype == 4) {
60 }
else if (stype == 5) {
62 }
else if (stype == 6) {
64 }
else if (stype == 7) {
66 }
else if (stype == 8) {
68 }
else if (stype == 9) {
70 }
else if (stype == 10) {
77 ncycles_ = paramList->get(
"MueLu: cycles", 1);
78 iters_ = paramList->get(
"MueLu: iterations", 500);
79 solverType_ = paramList->get(
"MueLu: solver type", 1);
91 int combinemode = paramList->get(
"MueLu: combine mode", 1);
92 if (combinemode == 0) {
97 tol_ = paramList->get(
"MueLu: tolerance", 0.001);
100template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
103 if (
A_ != Teuchos::null)
105#ifdef HAVE_MUELU_TPETRA_INST_INT_INT
106 if (LinearProblem_ != Teuchos::null)
107 LinearProblem_->setOperator(
TpetraA_);
109 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"ShiftedLaplacian only available with Tpetra and GO=int enabled.");
113template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
116#ifdef HAVE_MUELU_TPETRA_INST_INT_INT
117 if (LinearProblem_ != Teuchos::null)
118 LinearProblem_->setOperator(
TpetraA_);
122template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
128template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
130 RCP<Xpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > Atmp = rcp(
new Xpetra::TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(TpetraP));
131 P_ = rcp(
new Xpetra::CrsMatrixWrap<Scalar, LocalOrdinal, GlobalOrdinal, Node>(Atmp));
135template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
140template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
142 RCP<Xpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > Atmp = rcp(
new Xpetra::TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(TpetraK));
143 K_ = rcp(
new Xpetra::CrsMatrixWrap<Scalar, LocalOrdinal, GlobalOrdinal, Node>(Atmp));
146template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
151template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
153 RCP<Xpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > Atmp = rcp(
new Xpetra::TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(TpetraM));
154 M_ = rcp(
new Xpetra::CrsMatrixWrap<Scalar, LocalOrdinal, GlobalOrdinal, Node>(Atmp));
157template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
162template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
167template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
174template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
189 Teuchos::ParameterList params;
190 params.set(
"lightweight wrap",
true);
191 params.set(
"aggregation: drop scheme",
"classical");
209 precList_.set(
"relaxation: type",
"Jacobi");
212 }
else if (
Smoother_ ==
"gauss-seidel") {
214 precList_.set(
"relaxation: type",
"Gauss-Seidel");
217 }
else if (
Smoother_ ==
"symmetric gauss-seidel") {
219 precList_.set(
"relaxation: type",
"Symmetric Gauss-Seidel");
228 precList_.set(
"krylov: residual tolerance", 1.0e-8);
277#ifdef HAVE_MUELU_TPETRA_INST_INT_INT
281#if defined(HAVE_MUELU_AMESOS2) and defined(HAVE_AMESOS2_SUPERLU)
283#elif defined(HAVE_MUELU_AMESOS2) and defined(HAVE_AMESOS2_KLU2)
285#elif defined(HAVE_MUELU_AMESOS2) and defined(HAVE_AMESOS2_SUPERLUDIST)
298 if (
K_ != Teuchos::null) {
299 Manager_->SetFactory(
"Smoother", Teuchos::null);
300 Manager_->SetFactory(
"CoarseSolver", Teuchos::null);
332 BelosList_ = rcp(
new Teuchos::ParameterList(
"GMRES"));
333 BelosList_->set(
"Maximum Iterations",
iters_);
334 BelosList_->set(
"Convergence Tolerance",
tol_);
335 BelosList_->set(
"Verbosity", Belos::Errors + Belos::Warnings + Belos::StatusTestDetails);
336 BelosList_->set(
"Output Frequency", 1);
337 BelosList_->set(
"Output Style", Belos::Brief);
341 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"ShiftedLaplacian only available with Tpetra and GO=int enabled.");
346template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
357template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
374template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
390template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
392#ifdef HAVE_MUELU_TPETRA_INST_INT_INT
396 if (LinearProblem_ == Teuchos::null)
397 LinearProblem_ = rcp(
new LinearProblem);
398 LinearProblem_->setOperator(
TpetraA_);
399 LinearProblem_->setRightPrec(
MueLuOp_);
400 if (SolverManager_ == Teuchos::null) {
401 std::string solverName;
402 SolverFactory_ = rcp(
new SolverFactory());
404 solverName =
"Block GMRES";
406 solverName =
"Recycling GMRES";
408 solverName =
"Flexible GMRES";
410 SolverManager_ = SolverFactory_->create(solverName, BelosList_);
411 SolverManager_->setProblem(LinearProblem_);
414 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"ShiftedLaplacian only available with Tpetra and GO=int enabled.");
418template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
420#ifdef HAVE_MUELU_TPETRA_INST_INT_INT
421 LinearProblem_->setOperator(
TpetraA_);
423 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"ShiftedLaplacian only available with Tpetra and GO=int enabled.");
428template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
430#ifdef HAVE_MUELU_TPETRA_INST_INT_INT
432 LinearProblem_->setProblem(X, B);
434 SolverManager_->solve();
436 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"ShiftedLaplacian only available with Tpetra and GO=int enabled.");
442template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
444 RCP<MultiVector>& X) {
450template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
452 RCP<Tpetra::MultiVector<SC, LO, GO, NO> >& X) {
453 Teuchos::RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> > XpetraX = Teuchos::rcp(
new Xpetra::TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(X));
454 Teuchos::RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> > XpetraB = Teuchos::rcp(
new Xpetra::TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(B));
456 Hierarchy_->Iterate(*XpetraB, *XpetraX, 1,
true, 0);
460template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
462#ifdef HAVE_MUELU_TPETRA_INST_INT_INT
463 int numiters = SolverManager_->getNumIters();
466 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"ShiftedLaplacian only available with Tpetra and GO=int enabled.");
472template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
473typename Teuchos::ScalarTraits<Scalar>::magnitudeType
475 typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType MT;
476#ifdef HAVE_MUELU_TPETRA_INST_INT_INT
477 MT residual = SolverManager_->achievedTol();
480 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"ShiftedLaplacian only available with Tpetra and GO=int enabled.");
487#define MUELU_SHIFTEDLAPLACIAN_SHORT
AmalgamationFactory for subblocks of strided map based amalgamation data.
Factory for creating a graph based on a given matrix.
Factory for generating coarse level map. Used by TentativePFactory.
Class that encapsulates direct solvers. Autoselection of AmesosSmoother or Amesos2Smoother according ...
Exception throws to report errors in the internal logical of the program.
This class specifies the default factory that should generate some data on a Level if the data does n...
Factory for building restriction operators using a prolongator factory.
Provides methods to build a multigrid hierarchy and apply multigrid cycles.
Class that encapsulates Ifpack2 smoothers.
Factory for building Petrov-Galerkin Smoothed Aggregation prolongators.
Factory for building coarse matrices.
Factory for building coarse grid matrices, when the matrix is of the form K+a*M. Useful when you want...
Factory for building Smoothed Aggregation prolongators.
Wraps an existing MueLu::Hierarchy as a Tpetra::Operator, with an optional two-level correction....
void setPreconditioningMatrix(RCP< Matrix > &P)
RCP< TransPFactory > TransPfact_
RCP< MultiVector > NullSpace_
void setmass(RCP< Matrix > &M)
RCP< Tpetra::CrsMatrix< SC, LO, GO, NO > > TpetraA_
double ilu_diagpivotthresh_
std::string ilu_normtype_
int krylov_preconditioner_
RCP< CoarseMapFactory > CoarseMapfact_
std::string ilu_milutype_
RCP< GenericRFactory > Rfact_
void resetLinearProblem()
RCP< MultiVector > Coords_
void setNullSpace(RCP< MultiVector > NullSpace)
RCP< RAPFactory > Acfact_
RCP< MueLu::ShiftedLaplacianOperator< SC, LO, GO, NO > > MueLuOp_
RCP< SmootherPrototype > coarsestSmooProto_
std::vector< SC > levelshifts_
RCP< RAPShiftFactory > Acshift_
void setcoords(RCP< MultiVector > &Coords)
Teuchos::ScalarTraits< Scalar >::magnitudeType GetResidual()
RCP< TentativePFactory > TentPfact_
Teuchos::ParameterList precList_
RCP< UncoupledAggregationFactory > UCaggfact_
RCP< SmootherPrototype > smooProto_
RCP< SmootherFactory > smooFact_
int solve(const RCP< TMV > B, RCP< TMV > &X)
void setLevelShifts(std::vector< Scalar > levelshifts)
void setParameters(Teuchos::RCP< Teuchos::ParameterList > paramList)
std::string schwarz_ordermethod_
RCP< FactoryManager > Manager_
virtual ~ShiftedLaplacian()
void setstiff(RCP< Matrix > &K)
void setProblemMatrix(RCP< Matrix > &A)
void multigrid_apply(const RCP< MultiVector > B, RCP< MultiVector > &X)
Teuchos::ParameterList coarsestSmooList_
RCP< Hierarchy > Hierarchy_
RCP< AmalgamationFactory > Amalgfact_
std::string ilu_drop_rule_
RCP< CoalesceDropFactory > Dropfact_
RCP< SmootherFactory > coarsestSmooFact_
RCP< PgPFactory > PgPfact_
Tpetra::CombineMode schwarz_combinemode_
Generic Smoother Factory for generating the smoothers of the MG hierarchy.
Factory for building tentative prolongator.
Factory for building restriction operators.
Factory for building uncoupled aggregates.
Namespace for MueLu classes and methods.