46#ifndef MUELU_SHIFTEDLAPLACIAN_DEF_HPP
47#define MUELU_SHIFTEDLAPLACIAN_DEF_HPP
51#if defined(HAVE_MUELU_IFPACK2) and defined(HAVE_MUELU_TPETRA)
53#include <MueLu_AmalgamationFactory.hpp>
54#include <MueLu_CoalesceDropFactory.hpp>
55#include <MueLu_CoarseMapFactory.hpp>
56#include <MueLu_CoupledRBMFactory.hpp>
57#include <MueLu_DirectSolver.hpp>
58#include <MueLu_GenericRFactory.hpp>
59#include <MueLu_Hierarchy.hpp>
60#include <MueLu_Ifpack2Smoother.hpp>
61#include <MueLu_PFactory.hpp>
62#include <MueLu_PgPFactory.hpp>
63#include <MueLu_RAPFactory.hpp>
64#include <MueLu_RAPShiftFactory.hpp>
65#include <MueLu_SaPFactory.hpp>
66#include <MueLu_ShiftedLaplacian.hpp>
67#include <MueLu_ShiftedLaplacianOperator.hpp>
68#include <MueLu_SmootherFactory.hpp>
69#include <MueLu_SmootherPrototype.hpp>
70#include <MueLu_TentativePFactory.hpp>
71#include <MueLu_TransPFactory.hpp>
72#include <MueLu_UncoupledAggregationFactory.hpp>
73#include <MueLu_Utilities.hpp>
78template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
82template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
87 numLevels_ = paramList->get(
"MueLu: levels", 3);
88 int stype = paramList->get(
"MueLu: smoother", 8);
90 else if(stype==2) {
Smoother_=
"gauss-seidel"; }
91 else if(stype==3) {
Smoother_=
"symmetric gauss-seidel"; }
92 else if(stype==4) {
Smoother_=
"chebyshev"; }
96 else if(stype==8) {
Smoother_=
"schwarz"; }
97 else if(stype==9) {
Smoother_=
"superilu"; }
98 else if(stype==10) {
Smoother_=
"superlu"; }
102 ncycles_ = paramList->get(
"MueLu: cycles", 1);
103 iters_ = paramList->get(
"MueLu: iterations", 500);
104 solverType_ = paramList->get(
"MueLu: solver type", 1);
107 isSymmetric_ = paramList->get(
"MueLu: symmetric",
true);
116 int combinemode = paramList->get(
"MueLu: combine mode", 1);
119 tol_ = paramList->get(
"MueLu: tolerance", 0.001);
123template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
127 if(
A_!=Teuchos::null)
129#ifdef HAVE_MUELU_TPETRA_INST_INT_INT
130 if(LinearProblem_!=Teuchos::null)
131 LinearProblem_ -> setOperator (
TpetraA_ );
133 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"ShiftedLaplacian only available with Tpetra and GO=int enabled.");
138template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
142#ifdef HAVE_MUELU_TPETRA_INST_INT_INT
143 if(LinearProblem_!=Teuchos::null)
144 LinearProblem_ -> setOperator (
TpetraA_ );
149template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
157template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
160 RCP< Xpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > Atmp
161 = rcp(
new Xpetra::TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(TpetraP) );
162 P_= rcp(
new Xpetra::CrsMatrixWrap<Scalar, LocalOrdinal, GlobalOrdinal, Node>(Atmp) );
167template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
174template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
177 RCP< Xpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > Atmp
178 = rcp(
new Xpetra::TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(TpetraK) );
179 K_= rcp(
new Xpetra::CrsMatrixWrap<Scalar, LocalOrdinal, GlobalOrdinal, Node>(Atmp) );
183template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
190template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
193 RCP< Xpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > Atmp
194 = rcp(
new Xpetra::TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(TpetraM) );
195 M_= rcp(
new Xpetra::CrsMatrixWrap<Scalar, LocalOrdinal, GlobalOrdinal, Node>(Atmp) );
199template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
206template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
213template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
222template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
238 Teuchos::ParameterList params;
239 params.set(
"lightweight wrap",
true);
240 params.set(
"aggregation: drop scheme",
"classical");
259 precList_.set(
"relaxation: type",
"Jacobi");
265 precList_.set(
"relaxation: type",
"Gauss-Seidel");
269 else if(
Smoother_==
"symmetric gauss-seidel") {
271 precList_.set(
"relaxation: type",
"Symmetric Gauss-Seidel");
282 precList_.set(
"krylov: residual tolerance",1.0e-8);
336#ifdef HAVE_MUELU_TPETRA_INST_INT_INT
340#if defined(HAVE_MUELU_AMESOS2) and defined(HAVE_AMESOS2_SUPERLU)
342#elif defined(HAVE_MUELU_AMESOS2) and defined(HAVE_AMESOS2_KLU2)
344#elif defined(HAVE_MUELU_AMESOS2) and defined(HAVE_AMESOS2_SUPERLUDIST)
357 if(
K_!=Teuchos::null) {
358 Manager_ -> SetFactory(
"Smoother", Teuchos::null);
359 Manager_ -> SetFactory(
"CoarseSolver", Teuchos::null);
392 BelosList_ = rcp(
new Teuchos::ParameterList(
"GMRES") );
393 BelosList_ -> set(
"Maximum Iterations",
iters_ );
394 BelosList_ -> set(
"Convergence Tolerance",
tol_ );
395 BelosList_ -> set(
"Verbosity", Belos::Errors + Belos::Warnings + Belos::StatusTestDetails);
396 BelosList_ -> set(
"Output Frequency",1);
397 BelosList_ -> set(
"Output Style",Belos::Brief);
401 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"ShiftedLaplacian only available with Tpetra and GO=int enabled.");
406template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
419template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
438template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
456template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
459#ifdef HAVE_MUELU_TPETRA_INST_INT_INT
464 if(LinearProblem_==Teuchos::null)
465 LinearProblem_ = rcp(
new LinearProblem );
466 LinearProblem_ -> setOperator (
TpetraA_ );
467 LinearProblem_ -> setRightPrec(
MueLuOp_ );
468 if(SolverManager_==Teuchos::null) {
469 std::string solverName;
470 SolverFactory_= rcp(
new SolverFactory() );
472 else if(
solverType_==2) { solverName=
"Recycling GMRES"; }
473 else { solverName=
"Flexible GMRES"; }
474 SolverManager_ = SolverFactory_->create( solverName, BelosList_ );
475 SolverManager_ -> setProblem( LinearProblem_ );
478 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"ShiftedLaplacian only available with Tpetra and GO=int enabled.");
482template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
485#ifdef HAVE_MUELU_TPETRA_INST_INT_INT
486 LinearProblem_ -> setOperator (
TpetraA_ );
488 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"ShiftedLaplacian only available with Tpetra and GO=int enabled.");
493template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
496#ifdef HAVE_MUELU_TPETRA_INST_INT_INT
498 LinearProblem_ -> setProblem(X, B);
500 SolverManager_ ->
solve();
502 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"ShiftedLaplacian only available with Tpetra and GO=int enabled.");
508template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
517template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
519 RCP<Tpetra::MultiVector<SC,LO,GO,NO> >& X)
521 Teuchos::RCP< Xpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > XpetraX
522 = Teuchos::rcp(
new Xpetra::TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(X) );
523 Teuchos::RCP< Xpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > XpetraB
524 = Teuchos::rcp(
new Xpetra::TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(B) );
526 Hierarchy_ -> Iterate(*XpetraB, *XpetraX, 1,
true, 0);
530template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
533#ifdef HAVE_MUELU_TPETRA_INST_INT_INT
534 int numiters = SolverManager_ -> getNumIters();
537 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"ShiftedLaplacian only available with Tpetra and GO=int enabled.");
543template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
544typename Teuchos::ScalarTraits<Scalar>::magnitudeType
547 typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType MT;
548#ifdef HAVE_MUELU_TPETRA_INST_INT_INT
549 MT residual = SolverManager_ -> achievedTol();
552 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"ShiftedLaplacian only available with Tpetra and GO=int enabled.");
559#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)
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_
RCP< Tpetra::CrsMatrix< SC, LO, GO, NO > > TpetraA_
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.
static RCP< Tpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op2NonConstTpetraCrs(RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op)
Namespace for MueLu classes and methods.
@ Keep
Always keep data, even accross run. This flag is set by Level::Keep(). This flag is propagated to coa...