50#if defined(HAVE_MUELU_EPETRA) && defined(HAVE_MUELU_AMESOS)
52#include <Epetra_LinearProblem.h>
54#include <Amesos_config.h>
61#include "MueLu_Utilities.hpp"
74 std::transform(
type_.begin(), ++
type_.begin(),
type_.begin(), ::toupper);
78 if (
type_ ==
"Amesos_umfpack")
type_ =
"Umfpack";
79 if (
type_ ==
"Superlu_dist")
type_ =
"Superludist";
85 std::string oldtype =
type_;
87#if defined(HAVE_AMESOS_SUPERLU)
89#elif defined(HAVE_AMESOS_KLU)
91#elif defined(HAVE_AMESOS_SUPERLUDIST)
92 type_ =
"Superludist";
93#elif defined(HAVE_AMESOS_UMFPACK)
96 this->
declareConstructionOutcome(
true,
"Amesos has been compiled without SuperLU_DIST, SuperLU, Umfpack or Klu. By default, MueLu tries" +
97 "to use one of these libraries. Amesos must be compiled with one of these solvers, " +
98 "or a valid Amesos solver has to be specified explicitly.");
102 this->
GetOStream(
Warnings0) <<
"MueLu::AmesosSmoother: \"" << oldtype <<
"\" is not available. Using \"" <<
type_ <<
"\" instead" << std::endl;
109 template <
class Node>
111 this->Input(currentLevel,
"A");
114 template <
class Node>
119 this->GetOStream(
Warnings0) <<
"MueLu::AmesosSmoother::Setup(): Setup() has already been called" << std::endl;
121 A_ = Factory::Get< RCP<Matrix> >(currentLevel,
"A");
125 linearProblem_->SetOperator(epA.get());
128 prec_ = rcp(factory.
Create(type_, *linearProblem_));
129 TEUCHOS_TEST_FOR_EXCEPTION(prec_ == Teuchos::null,
Exceptions::RuntimeError,
"MueLu::AmesosSmoother::Setup(): Solver '" + type_ +
"' not supported by Amesos");
133 if (A_->getRowMap()->isDistributed() ==
true && A_->getRowMap()->isContiguous() ==
false)
134 const_cast<ParameterList&
>(this->GetParameterList()).set(
"Reindex",
true);
136 const ParameterList& paramList = this->GetParameterList();
137 RCP<ParameterList> precList = this->RemoveFactoriesFromList(paramList);
139 prec_->SetParameters(*precList);
141 const_cast<ParameterList&
>(paramList).setParameters(*precList);
143 int r = prec_->NumericFactorization();
144 TEUCHOS_TEST_FOR_EXCEPTION(r != 0,
Exceptions::RuntimeError,
"MueLu::AmesosSmoother::Setup(): Amesos solver returns value of " +
145 Teuchos::toString(r) +
" during NumericFactorization()");
150 template <
class Node>
160 linearProblem_->SetLHS(&epX);
161 linearProblem_->SetRHS(&nonconstB);
166 linearProblem_->SetLHS(0);
167 linearProblem_->SetRHS(0);
170 template <
class Node>
175 template <
class Node>
177 std::ostringstream out;
179 out <<
"{type = " << type_ <<
"}";
184 template <
class Node>
189 out0 <<
"Prec. type: " << type_ << std::endl;
192 out0 <<
"Parameter list: " << std::endl;
193 Teuchos::OSTab tab2(out);
194 out << this->GetParameterList();
198 if (prec_ != Teuchos::null) {
199 prec_->PrintStatus();
200 prec_->PrintTiming();
203 if (verbLevel &
Debug) {
206 <<
"RCP<A_>: " << A_ << std::endl
207 <<
"RCP<linearProblem__>: " << linearProblem_ << std::endl
208 <<
"RCP<prec_>: " << prec_ << std::endl;
212 template <
class Node>
215 return Teuchos::OrdinalTraits<size_t>::invalid();
225#if defined(HAVE_MUELU_EPETRA)
#define MUELU_DESCRIBE
Helper macro for implementing Describable::describe() for BaseClass objects.
Amesos_BaseSolver * Create(const char *ClassType, const Epetra_LinearProblem &LinearProblem)
Class that encapsulates Amesos direct solvers.
AmesosSmoother(const std::string &type="", const Teuchos::ParameterList ¶mList=Teuchos::ParameterList())
Constructor.
std::string description() const
Return a simple one-line description of this object.
std::string type_
amesos-specific key phrase that denote smoother type
size_t getNodeSmootherComplexity() const
Get a rough estimate of cost per iteration.
void Setup(Level ¤tLevel)
Set up the direct solver. This creates the underlying Amesos solver object according to the parameter...
RCP< SmootherPrototype > Copy() const
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the object with some verbosity level to an FancyOStream object.
void DeclareInput(Level ¤tLevel) const
Input.
void Apply(MultiVector &X, const MultiVector &B, bool=false) const
Apply the direct solver.
virtual std::string description() const
Return a simple one-line description of this object.
Exception throws to report errors in the internal logical of the program.
Timer to be used in factories. Similar to Monitor but with additional timers.
Class that holds all level-specific information.
virtual void SetParameterList(const Teuchos::ParameterList ¶mList)
Set parameters from a parameter list and return with default values.
void declareConstructionOutcome(bool fail, std::string msg)
bool IsSetup() const
Get the state of a smoother prototype.
static RCP< Epetra_MultiVector > MV2NonConstEpetraMV(RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > vec)
static RCP< Epetra_CrsMatrix > Op2NonConstEpetraCrs(RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op)
static RCP< const Epetra_MultiVector > MV2EpetraMV(RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > const vec)
Helper utility to pull out the underlying Epetra objects from an Xpetra object.
Teuchos::FancyOStream & GetOStream(MsgType type, int thisProcRankOnly=0) const
Get an output stream for outputting the input message type.
Namespace for MueLu classes and methods.
@ Warnings0
Important warning messages (one line)
@ Debug
Print additional debugging information.
@ External
Print external lib objects.
@ Runtime1
Description of what is happening (more verbose)
@ Parameters0
Print class parameters.
@ Parameters1
Print class parameters (more parameters, more verbose)