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_CoupledAggregationFactory.hpp>
57#include <MueLu_CoupledRBMFactory.hpp>
58#include <MueLu_DirectSolver.hpp>
59#include <MueLu_GenericRFactory.hpp>
60#include <MueLu_Hierarchy.hpp>
61#include <MueLu_Ifpack2Smoother.hpp>
62#include <MueLu_PFactory.hpp>
63#include <MueLu_PgPFactory.hpp>
64#include <MueLu_RAPFactory.hpp>
65#include <MueLu_RAPShiftFactory.hpp>
66#include <MueLu_SaPFactory.hpp>
67#include <MueLu_ShiftedLaplacian.hpp>
68#include <MueLu_ShiftedLaplacianOperator.hpp>
69#include <MueLu_SmootherFactory.hpp>
70#include <MueLu_SmootherPrototype.hpp>
71#include <MueLu_TentativePFactory.hpp>
72#include <MueLu_TransPFactory.hpp>
73#include <MueLu_UncoupledAggregationFactory.hpp>
74#include <MueLu_Utilities.hpp>
79template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
83template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
88 numLevels_ = paramList->get(
"MueLu: levels", 3);
89 int stype = paramList->get(
"MueLu: smoother", 8);
91 else if(stype==2) {
Smoother_=
"gauss-seidel"; }
92 else if(stype==3) {
Smoother_=
"symmetric gauss-seidel"; }
93 else if(stype==4) {
Smoother_=
"chebyshev"; }
97 else if(stype==8) {
Smoother_=
"schwarz"; }
98 else if(stype==9) {
Smoother_=
"superilu"; }
99 else if(stype==10) {
Smoother_=
"superlu"; }
103 ncycles_ = paramList->get(
"MueLu: cycles", 1);
104 iters_ = paramList->get(
"MueLu: iterations", 500);
105 solverType_ = paramList->get(
"MueLu: solver type", 1);
108 isSymmetric_ = paramList->get(
"MueLu: symmetric",
true);
117 int combinemode = paramList->get(
"MueLu: combine mode", 1);
120 tol_ = paramList->get(
"MueLu: tolerance", 0.001);
124template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
128 if(
A_!=Teuchos::null)
130#ifdef HAVE_MUELU_TPETRA_INST_INT_INT
131 if(LinearProblem_!=Teuchos::null)
132 LinearProblem_ -> setOperator (
TpetraA_ );
134 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"ShiftedLaplacian only available with Tpetra and GO=int enabled.");
139template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
143#ifdef HAVE_MUELU_TPETRA_INST_INT_INT
144 if(LinearProblem_!=Teuchos::null)
145 LinearProblem_ -> setOperator (
TpetraA_ );
150template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
158template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
161 RCP< Xpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > Atmp
162 = rcp(
new Xpetra::TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(TpetraP) );
163 P_= rcp(
new Xpetra::CrsMatrixWrap<Scalar, LocalOrdinal, GlobalOrdinal, Node>(Atmp) );
168template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
175template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
178 RCP< Xpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > Atmp
179 = rcp(
new Xpetra::TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(TpetraK) );
180 K_= rcp(
new Xpetra::CrsMatrixWrap<Scalar, LocalOrdinal, GlobalOrdinal, Node>(Atmp) );
184template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
191template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
194 RCP< Xpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > Atmp
195 = rcp(
new Xpetra::TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(TpetraM) );
196 M_= rcp(
new Xpetra::CrsMatrixWrap<Scalar, LocalOrdinal, GlobalOrdinal, Node>(Atmp) );
200template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
207template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
214template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
223template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
240 Teuchos::ParameterList params;
241 params.set(
"lightweight wrap",
true);
242 params.set(
"aggregation: drop scheme",
"classical");
266 precList_.set(
"relaxation: type",
"Jacobi");
272 precList_.set(
"relaxation: type",
"Gauss-Seidel");
276 else if(
Smoother_==
"symmetric gauss-seidel") {
278 precList_.set(
"relaxation: type",
"Symmetric Gauss-Seidel");
289 precList_.set(
"krylov: residual tolerance",1.0e-8);
343#ifdef HAVE_MUELU_TPETRA_INST_INT_INT
347#if defined(HAVE_MUELU_AMESOS2) and defined(HAVE_AMESOS2_SUPERLU)
349#elif defined(HAVE_MUELU_AMESOS2) and defined(HAVE_AMESOS2_KLU2)
351#elif defined(HAVE_MUELU_AMESOS2) and defined(HAVE_AMESOS2_SUPERLUDIST)
364 if(
K_!=Teuchos::null) {
365 Manager_ -> SetFactory(
"Smoother", Teuchos::null);
366 Manager_ -> SetFactory(
"CoarseSolver", Teuchos::null);
399 BelosList_ = rcp(
new Teuchos::ParameterList(
"GMRES") );
400 BelosList_ -> set(
"Maximum Iterations",
iters_ );
401 BelosList_ -> set(
"Convergence Tolerance",
tol_ );
402 BelosList_ -> set(
"Verbosity", Belos::Errors + Belos::Warnings + Belos::StatusTestDetails);
403 BelosList_ -> set(
"Output Frequency",1);
404 BelosList_ -> set(
"Output Style",Belos::Brief);
408 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"ShiftedLaplacian only available with Tpetra and GO=int enabled.");
413template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
426template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
445template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
463template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
466#ifdef HAVE_MUELU_TPETRA_INST_INT_INT
471 if(LinearProblem_==Teuchos::null)
472 LinearProblem_ = rcp(
new LinearProblem );
473 LinearProblem_ -> setOperator (
TpetraA_ );
474 LinearProblem_ -> setRightPrec(
MueLuOp_ );
475 if(SolverManager_==Teuchos::null) {
476 std::string solverName;
477 SolverFactory_= rcp(
new SolverFactory() );
479 else if(
solverType_==2) { solverName=
"Recycling GMRES"; }
480 else { solverName=
"Flexible GMRES"; }
481 SolverManager_ = SolverFactory_->create( solverName, BelosList_ );
482 SolverManager_ -> setProblem( LinearProblem_ );
485 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"ShiftedLaplacian only available with Tpetra and GO=int enabled.");
489template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
492#ifdef HAVE_MUELU_TPETRA_INST_INT_INT
493 LinearProblem_ -> setOperator (
TpetraA_ );
495 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"ShiftedLaplacian only available with Tpetra and GO=int enabled.");
500template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
503#ifdef HAVE_MUELU_TPETRA_INST_INT_INT
505 LinearProblem_ -> setProblem(X, B);
507 SolverManager_ ->
solve();
509 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"ShiftedLaplacian only available with Tpetra and GO=int enabled.");
515template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
524template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
526 RCP<Tpetra::MultiVector<SC,LO,GO,NO> >& X)
528 Teuchos::RCP< Xpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > XpetraX
529 = Teuchos::rcp(
new Xpetra::TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(X) );
530 Teuchos::RCP< Xpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > XpetraB
531 = Teuchos::rcp(
new Xpetra::TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(B) );
533 Hierarchy_ -> Iterate(*XpetraB, *XpetraX, 1,
true, 0);
537template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
540#ifdef HAVE_MUELU_TPETRA_INST_INT_INT
541 int numiters = SolverManager_ -> getNumIters();
544 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"ShiftedLaplacian only available with Tpetra and GO=int enabled.");
550template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
551typename Teuchos::ScalarTraits<Scalar>::magnitudeType
554 typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType MT;
555#ifdef HAVE_MUELU_TPETRA_INST_INT_INT
556 MT residual = SolverManager_ -> achievedTol();
559 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"ShiftedLaplacian only available with Tpetra and GO=int enabled.");
566#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.
Factory for coarsening a graph with uncoupled aggregation.
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_
RCP< CoupledAggregationFactory > Aggfact_
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...