46 #ifndef MUELU_BELOSSMOOTHER_DEF_HPP
47 #define MUELU_BELOSSMOOTHER_DEF_HPP
51 #if defined(HAVE_MUELU_BELOS)
57 #include <Xpetra_MultiVectorFactory.hpp>
58 #ifdef HAVE_XPETRA_TPETRA
59 #include <Xpetra_TpetraMultiVector.hpp>
64 #include "MueLu_Utilities.hpp"
67 #include <BelosLinearProblem.hpp>
68 #include <BelosSolverFactory.hpp>
72 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
75 bool solverSupported =
false;
76 Belos::SolverFactory<Scalar, tMV, tOP> tFactory;
77 solverSupported = solverSupported || tFactory.isSupported(type);
98 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
103 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
105 this->Input(currentLevel,
"A");
108 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
112 A_ = Factory::Get<RCP<Matrix> >(currentLevel,
"A");
113 SetupBelos(currentLevel);
115 this->GetOStream(
Statistics1) << description() << std::endl;
118 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
123 tBelosProblem_ =
rcp(
new Belos::LinearProblem<Scalar, tMV, tOP>());
125 tBelosProblem_->setOperator(tA);
127 Belos::SolverFactory<SC, tMV, tOP> solverFactory;
128 tSolver_ = solverFactory.create(type_, rcpFromRef(const_cast<ParameterList&>(this->GetParameterList())));
129 tSolver_->setProblem(tBelosProblem_);
135 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
140 if (InitialGuessIsZero) {
146 tBelosProblem_->setInitResVec(tpB);
147 tBelosProblem_->setProblem(tpX, tpB);
153 RCP<MultiVector> Correction = MultiVectorFactory::Build(A_->getDomainMap(), X.getNumVectors());
158 tBelosProblem_->setInitResVec(tpB);
159 tBelosProblem_->setProblem(tpX, tpB);
162 X.update(TST::one(), *Correction, TST::one());
169 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
176 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
178 std::ostringstream out;
181 out << tSolver_->description();
184 out <<
"BELOS {type = " << type_ <<
"}";
189 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
194 out0 <<
"Parameter list: " << std::endl;
196 out << this->GetParameterList();
200 if (tSolver_ != Teuchos::null) {
202 out << *tSolver_ << std::endl;
206 if (verbLevel &
Debug) {
210 <<
"RCP<solver_>: " << tSolver_ << std::endl;
215 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
222 #endif // HAVE_MUELU_BELOS
223 #endif // MUELU_BELOSSMOOTHER_DEF_HPP
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.
Print external lib objects.
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the object with some verbosity level to an FancyOStream object.
Timer to be used in factories. Similar to Monitor but with additional timers.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Class that encapsulates Belos smoothers.
Print additional debugging information.
void Setup(Level ¤tLevel)
Set up the smoother.
size_t getNodeSmootherComplexity() const
For diagnostic purposes.
RCP< SmootherPrototype > Copy() const
static RCP< MultiVector > Residual(const Xpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Op, const MultiVector &X, const MultiVector &RHS)
virtual void SetParameterList(const Teuchos::ParameterList ¶mList)
Set parameters from a parameter list and return with default values.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void declareConstructionOutcome(bool fail, std::string msg)
Class that holds all level-specific information.
void SetupBelos(Level ¤tLevel)
friend class BelosSmoother
Constructor.
bool IsSetup() const
Get the state of a smoother prototype.
#define MUELU_DESCRIBE
Helper macro for implementing Describable::describe() for BaseClass objects.
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
Apply the preconditioner.
Print class parameters (more parameters, more verbose)
Exception throws to report errors in the internal logical of the program.
#define TEUCHOS_ASSERT(assertion_test)
void SetParameterList(const Teuchos::ParameterList ¶mList)
Set parameters from a parameter list and return with default values.
static RCP< Tpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op2NonConstTpetraCrs(RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >> Op)
static RCP< Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > MV2NonConstTpetraMV(RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >> vec)
void DeclareInput(Level ¤tLevel) const
Input.
std::string toString(const T &t)
std::string description() const
Return a simple one-line description of this object.