46 #ifndef MUELU_DIRECTSOLVER_DEF_HPP
47 #define MUELU_DIRECTSOLVER_DEF_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>
84 #if defined(HAVE_MUELU_AMESOS2)
88 errorTpetra_ =
"Unable to construct Amesos2 direct solver";
89 else if (!
sTpetra_->constructionSuccessful()) {
102 #if defined(HAVE_MUELU_EPETRA) && defined(HAVE_MUELU_AMESOS)
105 sEpetra_ = GetAmesosSmoother<SC, LO, GO, NO>(
type_, paramList);
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_THYRA)
164 "Unable to construct any direct solver."
165 "Plase enable (TPETRA and AMESOS2) or (EPETRA and AMESOS) or (BELOS) or (STRATIMIKOS)");
168 "Could not enable any direct solver:\n"
169 << (
triedEpetra_ ?
"Epetra mode was disabled due to an error:\n" :
"")
171 << (
triedTpetra_ ?
"Tpetra mode was disabled due to an error:\n" :
"")
173 << (
triedBelos_ ?
"Belos was disabled due to an error:\n" :
"")
184 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
187 if (!sEpetra_.is_null()) sEpetra_->SetFactory(varName, factory);
188 if (!sTpetra_.is_null()) sTpetra_->SetFactory(varName, factory);
189 if (!sBelos_.is_null()) sBelos_->SetFactory(varName, factory);
190 if (!sStratimikos_.is_null()) sStratimikos_->SetFactory(varName, factory);
191 if (!sRefMaxwell_.is_null()) sRefMaxwell_->SetFactory(varName, factory);
194 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
196 if (!sBelos_.is_null())
198 else if (!sStratimikos_.is_null())
200 else if (!sRefMaxwell_.is_null())
209 s_ = (useTpetra ? sTpetra_ : sEpetra_);
212 #if not defined(HAVE_MUELU_AMESOS2)
214 "Error: running in Tpetra mode, but MueLu with Amesos2 was disabled during the configure stage.\n"
215 "Please make sure that:\n"
216 " - Amesos2 is enabled (Trilinos_ENABLE_Amesos2=ON),\n"
217 " - Amesos2 is available for MueLu to use (MueLu_ENABLE_Amesos2=ON)\n");
220 this->GetOStream(
Errors) <<
"Tpetra mode was disabled due to an error:\n"
221 << errorTpetra_ << std::endl;
225 #if not defined(HAVE_MUELU_AMESOS)
227 "Error: running in Epetra mode, but MueLu with Amesos was disabled during the configure stage.\n"
228 "Please make sure that:\n"
229 " - Amesos is enabled (you can do that with Trilinos_ENABLE_Amesos=ON),\n"
230 " - Amesos is available for MueLu to use (MueLu_ENABLE_Amesos=ON)\n");
233 this->GetOStream(
Errors) <<
"Epetra mode was disabled due to an error:\n"
234 << errorEpetra_ << std::endl;
238 "Direct solver for " << (useTpetra ?
"Tpetra" :
"Epetra") <<
" was not constructed");
242 s_->DeclareInput(currentLevel);
245 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
248 this->GetOStream(
Warnings0) <<
"MueLu::DirectSolver::Setup(): Setup() has already been called" << std::endl;
250 int oldRank = s_->SetProcRankVerbose(this->GetProcRankVerbose());
252 s_->Setup(currentLevel);
254 s_->SetProcRankVerbose(oldRank);
258 this->SetParameterList(s_->GetParameterList());
261 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
265 s_->Apply(X, B, InitialGuessIsZero);
268 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
274 if (!sEpetra_.is_null())
275 newSmoo->
sEpetra_ = sEpetra_->Copy();
276 if (!sTpetra_.is_null())
277 newSmoo->
sTpetra_ = sTpetra_->Copy();
278 if (!sBelos_.is_null())
279 newSmoo->
sBelos_ = sBelos_->Copy();
280 if (!sStratimikos_.is_null())
282 if (!sRefMaxwell_.is_null())
286 if (s_.get() == sBelos_.get())
288 else if (s_.get() == sStratimikos_.get())
290 else if (s_.get() == sRefMaxwell_.get())
292 else if (s_.get() == sTpetra_.get())
301 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
303 std::ostringstream out;
304 if (s_ != Teuchos::null) {
305 out << s_->description();
308 out <<
"{type = " << type_ <<
"}";
313 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
318 out0 <<
"Prec. type: " << type_ << std::endl;
321 out0 <<
"Parameter list: " << std::endl;
323 out << this->GetParameterList();
326 if (verbLevel &
Debug)
332 #endif // MUELU_DIRECTSOLVER_DEF_HPP
Important warning messages (one line)
Exception indicating invalid cast attempted.
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
DirectSolver cannot be applied. Apply() always returns a RuntimeError exception.
void Setup(Level ¤tLevel)
DirectSolver cannot be turned into a smoother using Setup(). Setup() always returns a RuntimeError ex...
std::string errorStratimikos_
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void DeclareInput(Level ¤tLevel) const
Input.
Class that encapsulates Belos smoothers.
Print additional debugging information.
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 ...
Class that encapsulates direct solvers. Autoselection of AmesosSmoother or Amesos2Smoother according ...
RCP< SmootherPrototype > Copy() const
When this prototype is cloned using Copy(), the clone is an Amesos or an Amesos2 smoother.
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
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)
std::string description() const
Return a simple one-line description of this object.
Class that holds all level-specific information.
Class that encapsulates Amesos2 direct solvers.
RCP< SmootherPrototype > sBelos_
bool IsSetup() const
Get the state of a smoother prototype.
Xpetra::UnderlyingLib lib()
Class that encapsulates Operator smoothers.
#define MUELU_DESCRIBE
Helper macro for implementing Describable::describe() for BaseClass objects.
RCP< SmootherPrototype > sTpetra_
void SetFactory(const std::string &varName, const RCP< const FactoryBase > &factory)
Custom SetFactory.
std::string errorRefMaxwell_
RCP< SmootherPrototype > sEpetra_
Smoother.
RCP< SmootherPrototype > sRefMaxwell_
RCP< SmootherPrototype > s_
Print class parameters (more parameters, more verbose)
Exception throws to report errors in the internal logical of the program.
RCP< SmootherPrototype > sStratimikos_
virtual std::string description() const
Return a simple one-line description of this object.
std::string toString(const T &t)