46 #ifndef MUELU_AMESOS2SMOOTHER_DEF_HPP 47 #define MUELU_AMESOS2SMOOTHER_DEF_HPP 52 #if defined (HAVE_MUELU_TPETRA) && defined(HAVE_MUELU_AMESOS2) 53 #include <Xpetra_Matrix.hpp> 55 #include <Amesos2_config.h> 56 #include <Amesos2.hpp> 60 #include "MueLu_Utilities.hpp" 65 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
73 std::transform(
type_.begin(), ++
type_.begin(),
type_.begin(), ::toupper);
75 if (
type_ ==
"Superlu_dist")
76 type_ =
"Superludist";
81 if (
type_ ==
"" || Amesos2::query(
type_) ==
false) {
82 std::string oldtype =
type_;
83 #if defined(HAVE_AMESOS2_SUPERLU) 85 #elif defined(HAVE_AMESOS2_KLU2) 87 #elif defined(HAVE_AMESOS2_SUPERLUDIST) 88 type_ =
"Superludist";
89 #elif defined(HAVE_AMESOS2_BASKER) 92 throw Exceptions::RuntimeError(
"Amesos2 has been compiled without SuperLU_DIST, SuperLU, Klu, or Basker. By default, MueLu tries" 93 "to use one of these libraries. Amesos2 must be compiled with one of these solvers, " 94 "or a valid Amesos2 solver has to be specified explicitly.");
97 this->
GetOStream(
Warnings0) <<
"MueLu::Amesos2Smoother: \"" << oldtype <<
"\" is not available. Using \"" <<
type_ <<
"\" instead" << std::endl;
103 TEUCHOS_TEST_FOR_EXCEPTION(Amesos2::query(
type_) ==
false,
Exceptions::RuntimeError,
"The Amesos2 library reported that the solver '" <<
type_ <<
"' is not available. " 104 "Amesos2 has been compiled without the support of this solver, or the solver name is misspelled.");
107 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
110 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
112 this->
Input(currentLevel,
"A");
115 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
120 this->
GetOStream(
Warnings0) <<
"MueLu::Amesos2Smoother::Setup(): Setup() has already been called" << std::endl;
122 RCP<Matrix> A_ = Factory::Get< RCP<Matrix> >(currentLevel,
"A");
126 prec_ = Amesos2::create<Tpetra_CrsMatrix,Tpetra_MultiVector>(
type_, tA);
132 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
137 MultiVector & BNonC =
const_cast<MultiVector&
>(B);
144 prec_->setX(Teuchos::null);
145 prec_->setB(Teuchos::null);
148 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
149 RCP<MueLu::SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
156 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
158 std::ostringstream out;
161 out <<
prec_->description();
165 out <<
"{type = " <<
type_ <<
"}";
170 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
175 out0 <<
"Prec. type: " <<
type_ << std::endl;
178 out0 <<
"Parameter list: " << std::endl;
179 Teuchos::OSTab tab2(out);
184 Teuchos::OSTab tab2(out);
185 out << *
prec_ << std::endl;
188 if (verbLevel &
Debug)
191 <<
"RCP<prec_>: " <<
prec_ << std::endl;
196 #endif // HAVE_MUELU_TPETRA && HAVE_MUELU_AMESOS2 197 #endif // MUELU_AMESOS2SMOOTHER_DEF_HPP Important warning messages (one line)
std::string toString(const T &what)
Little helper function to convert non-string types to strings.
Print external lib objects.
std::string type_
amesos2-specific key phrase that denote smoother type
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
Apply the direct solver. Solves the linear system AX=B using the constructed solver.
Timer to be used in factories. Similar to Monitor but with additional timers.
Print additional debugging information.
Namespace for MueLu classes and methods.
Amesos2Smoother(const std::string &type="", const Teuchos::ParameterList ¶mList=Teuchos::ParameterList())
Constructor Creates a MueLu interface to the direct solvers in the Amesos2 package. If you are using type=="", then either SuperLU or KLU2 are used by default.
virtual const Teuchos::ParameterList & GetParameterList() const
std::string description() const
Return a simple one-line description of this object.
RCP< SmootherPrototype > Copy() const
virtual void SetParameterList(const ParameterList ¶mList)
Set parameters from a parameter list and return with default values.
Class that holds all level-specific information.
Class that encapsulates Amesos2 direct solvers.
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 > > MV2NonConstTpetraMV2(Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &vec)
bool IsSetup() const
Get the state of a smoother prototype.
void DeclareInput(Level ¤tLevel) const
Input.
#define MUELU_DESCRIBE
Helper macro for implementing Describable::describe() for BaseClass objects.
Teuchos::FancyOStream & GetOStream(MsgType type, int thisProcRankOnly=0) const
Get an output stream for outputting the input message type.
virtual ~Amesos2Smoother()
Destructor.
void Setup(Level ¤tLevel)
Set up the direct solver. This creates the underlying Amesos2 solver object according to the paramete...
RCP< Amesos2::Solver< Tpetra_CrsMatrix, Tpetra_MultiVector > > prec_
pointer to Amesos2 solver object
Print class parameters (more parameters, more verbose)
Exception throws to report errors in the internal logical of the program.
Description of what is happening (more verbose)
void Input(Level &level, const std::string &varName) const
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the object with some verbosity level to an FancyOStream object.
virtual std::string description() const
Return a simple one-line description of this object.