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"
62 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
75 ParameterList paramList = paramListIn;
80 #if defined(HAVE_MUELU_TPETRA) && defined(HAVE_MUELU_AMESOS2)
91 #if defined(HAVE_MUELU_EPETRA) && defined(HAVE_MUELU_AMESOS)
106 "Plase enable (TPETRA and AMESOS2) or (EPETRA and AMESOS)");
109 "Could not enable any direct solver:\n"
110 << (
triedEpetra_ ?
"Epetra mode was disabled due to an error:\n" :
"")
112 << (
triedTpetra_ ?
"Tpetra mode was disabled due to an error:\n" :
"")
118 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
121 if (!sEpetra_.is_null()) sEpetra_->SetFactory(varName, factory);
122 if (!sTpetra_.is_null()) sTpetra_->SetFactory(varName, factory);
125 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
132 bool useTpetra = (currentLevel.
lib() == Xpetra::UseTpetra);
133 s_ = (useTpetra ? sTpetra_ : sEpetra_);
136 #if not defined(HAVE_MUELU_AMESOS2)
138 "Error: running in Tpetra mode, but MueLu with Amesos2 was disabled during the configure stage.\n"
139 "Please make sure that:\n"
140 " - Amesos2 is enabled (Trilinos_ENABLE_Amesos2=ON),\n"
141 " - Amesos2 is available for MueLu to use (MueLu_ENABLE_Amesos2=ON)\n");
144 this->GetOStream(
Errors) <<
"Tpetra mode was disabled due to an error:\n" << errorTpetra_ << std::endl;
148 #if not defined(HAVE_MUELU_AMESOS)
150 "Error: running in Epetra mode, but MueLu with Amesos was disabled during the configure stage.\n"
151 "Please make sure that:\n"
152 " - Amesos is enabled (you can do that with Trilinos_ENABLE_Amesos=ON),\n"
153 " - Amesos is available for MueLu to use (MueLu_ENABLE_Amesos=ON)\n");
156 this->GetOStream(
Errors) <<
"Epetra mode was disabled due to an error:\n" << errorEpetra_ << std::endl;
160 "Direct solver for " << (useTpetra ?
"Tpetra" :
"Epetra") <<
" was not constructed");
163 s_->DeclareInput(currentLevel);
166 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
169 this->GetOStream(
Warnings0) <<
"MueLu::DirectSolver::Setup(): Setup() has already been called" << std::endl;
171 int oldRank = s_->SetProcRankVerbose(this->GetProcRankVerbose());
173 s_->Setup(currentLevel);
175 s_->SetProcRankVerbose(oldRank);
179 this->SetParameterList(s_->GetParameterList());
182 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
186 s_->Apply(X, B, InitialGuessIsZero);
189 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
191 RCP<DirectSolver> newSmoo = rcp(
new DirectSolver(*
this));
195 if (!sEpetra_.is_null())
196 newSmoo->sEpetra_ = sEpetra_->Copy();
197 if (!sTpetra_.is_null())
198 newSmoo->sTpetra_ = sTpetra_->Copy();
201 newSmoo->s_ = (s_.get() == sTpetra_.get() ? newSmoo->sTpetra_ : newSmoo->sEpetra_);
202 newSmoo->SetParameterList(this->GetParameterList());
207 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
209 std::ostringstream out;
210 if (s_ != Teuchos::null) {
211 out << s_->description();
214 out <<
"{type = " << type_ <<
"}";
219 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
224 out0 <<
"Prec. type: " << type_ << std::endl;
227 out0 <<
"Parameter list: " << std::endl;
228 Teuchos::OSTab tab3(out);
229 out << this->GetParameterList();
232 if (verbLevel &
Debug)
238 #endif // MUELU_DIRECTSOLVER_DEF_HPP