46#ifndef MUELU_DIRECTSOLVER_DEF_HPP
47#define MUELU_DIRECTSOLVER_DEF_HPP
49#include <Xpetra_Utils.hpp>
50#include <Xpetra_Matrix.hpp>
57#include "MueLu_Amesos2Smoother.hpp"
59#include "MueLu_BelosSmoother.hpp"
60#include "MueLu_StratimikosSmoother.hpp"
61#include "MueLu_RefMaxwellSmoother.hpp"
65 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
79 ParameterList paramList = paramListIn;
84#if defined(HAVE_MUELU_TPETRA) && defined(HAVE_MUELU_AMESOS2)
88 errorTpetra_ =
"Unable to construct Amesos2 direct solver";
89 else if (!
sTpetra_->constructionSuccessful()) {
97 }
catch (Teuchos::Exceptions::InvalidParameterName& e) {
102#if defined(HAVE_MUELU_EPETRA) && defined(HAVE_MUELU_AMESOS)
107 errorEpetra_ =
"Unable to construct Amesos direct solver";
108 else if (!
sEpetra_->constructionSuccessful()) {
118#if defined(HAVE_MUELU_BELOS)
123 else if (!
sBelos_->constructionSuccessful()) {
134#if defined(HAVE_MUELU_STRATIMIKOS) && defined(HAVE_MUELU_TPETRA) && defined(HAVE_MUELU_THYRA)
164 "Plase enable (TPETRA and AMESOS2) or (EPETRA and AMESOS) or (BELOS) or (STRATIMIKOS)");
167 "Could not enable any direct solver:\n"
168 << (
triedEpetra_ ?
"Epetra mode was disabled due to an error:\n" :
"")
170 << (
triedTpetra_ ?
"Tpetra mode was disabled due to an error:\n" :
"")
172 << (
triedBelos_ ?
"Belos was disabled due to an error:\n" :
"")
182 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
192 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
206 bool useTpetra = (currentLevel.
lib() == Xpetra::UseTpetra);
210#if not defined(HAVE_MUELU_AMESOS2)
212 "Error: running in Tpetra mode, but MueLu with Amesos2 was disabled during the configure stage.\n"
213 "Please make sure that:\n"
214 " - Amesos2 is enabled (Trilinos_ENABLE_Amesos2=ON),\n"
215 " - Amesos2 is available for MueLu to use (MueLu_ENABLE_Amesos2=ON)\n");
222#if not defined(HAVE_MUELU_AMESOS)
224 "Error: running in Epetra mode, but MueLu with Amesos was disabled during the configure stage.\n"
225 "Please make sure that:\n"
226 " - Amesos is enabled (you can do that with Trilinos_ENABLE_Amesos=ON),\n"
227 " - Amesos is available for MueLu to use (MueLu_ENABLE_Amesos=ON)\n");
234 "Direct solver for " << (useTpetra ?
"Tpetra" :
"Epetra") <<
" was not constructed");
238 s_->DeclareInput(currentLevel);
241 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
244 this->
GetOStream(
Warnings0) <<
"MueLu::DirectSolver::Setup(): Setup() has already been called" << std::endl;
248 s_->Setup(currentLevel);
250 s_->SetProcRankVerbose(oldRank);
257 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
261 s_->Apply(X, B, InitialGuessIsZero);
264 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
266 RCP<DirectSolver> newSmoo = rcp(
new DirectSolver(*
this));
271 newSmoo->sEpetra_ =
sEpetra_->Copy();
273 newSmoo->sTpetra_ =
sTpetra_->Copy();
275 newSmoo->sBelos_ =
sBelos_->Copy();
283 newSmoo->s_ = newSmoo->sBelos_;
285 newSmoo->s_ = newSmoo->sStratimikos_;
287 newSmoo->s_ = newSmoo->sRefMaxwell_;
289 newSmoo->s_ = newSmoo->sTpetra_;
291 newSmoo->s_ = newSmoo->sEpetra_;
297 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
299 std::ostringstream out;
300 if (
s_ != Teuchos::null) {
301 out <<
s_->description();
304 out <<
"{type = " <<
type_ <<
"}";
309 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
314 out0 <<
"Prec. type: " <<
type_ << std::endl;
317 out0 <<
"Parameter list: " << std::endl;
318 Teuchos::OSTab tab3(out);
322 if (verbLevel &
Debug)
#define MUELU_DESCRIBE
Helper macro for implementing Describable::describe() for BaseClass objects.
Class that encapsulates Amesos2 direct solvers.
Class that encapsulates Belos smoothers.
virtual std::string description() const
Return a simple one-line description of this object.
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
DirectSolver cannot be applied. Apply() always returns a RuntimeError exception.
std::string errorRefMaxwell_
std::string description() const
Return a simple one-line description of this object.
void Setup(Level ¤tLevel)
DirectSolver cannot be turned into a smoother using Setup(). Setup() always returns a RuntimeError ex...
void SetFactory(const std::string &varName, const RCP< const FactoryBase > &factory)
Custom SetFactory.
RCP< SmootherPrototype > sBelos_
RCP< SmootherPrototype > sStratimikos_
RCP< SmootherPrototype > s_
RCP< SmootherPrototype > sEpetra_
Smoother.
std::string errorStratimikos_
RCP< SmootherPrototype > sRefMaxwell_
void DeclareInput(Level ¤tLevel) const
Input.
RCP< SmootherPrototype > Copy() const
When this prototype is cloned using Copy(), the clone is an Amesos or an Amesos2 smoother.
std::string type_
amesos1/2-specific key phrase that denote smoother type
DirectSolver(const std::string &type="", const Teuchos::ParameterList ¶mList=Teuchos::ParameterList())
Constructor Note: only parameters shared by Amesos and Amesos2 should be used for type and paramList ...
RCP< SmootherPrototype > sTpetra_
Exception indicating invalid cast attempted.
Exception throws to report errors in the internal logical of the program.
Class that holds all level-specific information.
Xpetra::UnderlyingLib lib()
virtual void SetParameterList(const Teuchos::ParameterList ¶mList)
Set parameters from a parameter list and return with default values.
virtual const Teuchos::ParameterList & GetParameterList() const
Class that encapsulates Operator smoothers.
bool IsSetup() const
Get the state of a smoother prototype.
Teuchos::FancyOStream & GetOStream(MsgType type, int thisProcRankOnly=0) const
Get an output stream for outputting the input message type.
int GetProcRankVerbose() const
Get proc rank used for printing. Do not use this information for any other purpose.
Namespace for MueLu classes and methods.
@ Warnings0
Important warning messages (one line)
@ Debug
Print additional debugging information.
@ Parameters0
Print class parameters.
@ Parameters1
Print class parameters (more parameters, more verbose)
RCP< MueLu::SmootherPrototype< Scalar, LocalOrdinal, GlobalOrdinal, Node > > GetAmesosSmoother(const std::string &="", const Teuchos::ParameterList &=Teuchos::ParameterList())
Non-member templated function GetAmesosSmoother() returns a new AmesosSmoother object.