46 #ifndef MUELU_TRILINOSSMOOTHER_DEF_HPP
47 #define MUELU_TRILINOSSMOOTHER_DEF_HPP
49 #include <Xpetra_Map.hpp>
56 #include "MueLu_Ifpack2Smoother.hpp"
57 #include "MueLu_BelosSmoother.hpp"
58 #include "MueLu_StratimikosSmoother.hpp"
63 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
87 #if defined(HAVE_MUELU_IFPACK2)
92 else if (!
sTpetra_->constructionSuccessful()) {
105 #if defined(HAVE_MUELU_EPETRA) && defined(HAVE_MUELU_IFPACK)
111 else if (!
sEpetra_->constructionSuccessful()) {
121 #if defined(HAVE_MUELU_BELOS)
125 errorBelos_ =
"Unable to construct Belos smoother";
126 else if (!
sBelos_->constructionSuccessful()) {
137 #if defined(HAVE_MUELU_STRATIMIKOS) && defined(HAVE_MUELU_THYRA)
155 "Unable to construct any smoother."
156 "Please enable (TPETRA and IFPACK2) or (EPETRA and IFPACK) or (BELOS) or (STRATIMIKOS)");
159 "Could not construct any smoother:\n"
160 << (
triedEpetra_ ?
"=> Failed to build an Epetra smoother due to the following exception:\n" :
"=> Epetra and/or Ifpack are not enabled.\n")
162 << (
triedTpetra_ ?
"=> Failed to build a Tpetra smoother due to the following exception:\n" :
"=> Tpetra and/or Ifpack2 are not enabled.\n")
164 << (
triedBelos_ ?
"=> Failed to build a Belos smoother due to the following exception:\n" :
"=> Belos not enabled.\n")
166 << (
triedStratimikos_ ?
"=> Failed to build a Stratimikos smoother due to the following exception:\n" :
"=> Stratimikos not enabled.\n")
172 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
175 if (!sEpetra_.is_null()) sEpetra_->SetFactory(varName, factory);
176 if (!sTpetra_.is_null()) sTpetra_->SetFactory(varName, factory);
177 if (!sBelos_.is_null()) sBelos_->SetFactory(varName, factory);
178 if (!sStratimikos_.is_null()) sStratimikos_->SetFactory(varName, factory);
181 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
183 if (!sBelos_.is_null())
185 else if (!sStratimikos_.is_null())
195 s_ = (useTpetra ? sTpetra_ : sEpetra_);
198 #if not defined(HAVE_MUELU_IFPACK2)
200 "Error: running in Tpetra mode, but MueLu with Ifpack2 was disabled during the configure stage.\n"
201 "Please make sure that:\n"
202 " - Ifpack2 is enabled (Trilinos_ENABLE_Ifpack2=ON),\n"
203 " - Ifpack2 is available for MueLu to use (MueLu_ENABLE_Ifpack2=ON)\n");
206 this->GetOStream(
Errors) <<
"Tpetra mode was disabled due to an error:\n"
207 << errorTpetra_ << std::endl;
211 #if not defined(HAVE_MUELU_IFPACK)
213 "Error: running in Epetra mode, but MueLu with Ifpack was disabled during the configure stage.\n"
214 "Please make sure that:\n"
215 " - Ifpack is enabled (you can do that with Trilinos_ENABLE_Ifpack=ON),\n"
216 " - Ifpack is available for MueLu to use (MueLu_ENABLE_Ifpack=ON)\n");
219 this->GetOStream(
Errors) <<
"Epetra mode was disabled due to an error:\n"
220 << errorEpetra_ << std::endl;
224 "Smoother for " << (useTpetra ?
"Tpetra" :
"Epetra") <<
" was not constructed");
228 s_->DeclareInput(currentLevel);
231 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
234 this->GetOStream(
Warnings0) <<
"MueLu::TrilinosSmoother::Setup(): Setup() has already been called" << std::endl;
236 int oldRank = s_->SetProcRankVerbose(this->GetProcRankVerbose());
238 s_->Setup(currentLevel);
240 s_->SetProcRankVerbose(oldRank);
244 this->SetParameterList(s_->GetParameterList());
247 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
251 s_->Apply(X, B, InitialGuessIsZero);
254 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
261 if (!sEpetra_.is_null())
262 newSmoo->
sEpetra_ = sEpetra_->Copy();
263 if (!sTpetra_.is_null())
264 newSmoo->
sTpetra_ = sTpetra_->Copy();
265 if (!sBelos_.is_null())
266 newSmoo->
sBelos_ = sBelos_->Copy();
267 if (!sStratimikos_.is_null())
271 if (s_.get() == sBelos_.get())
273 else if (s_.get() == sStratimikos_.get())
275 else if (s_.get() == sTpetra_.get())
284 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
286 if (type ==
"RELAXATION") {
287 return "point relaxation stand-alone";
289 if (type ==
"CHEBYSHEV") {
292 if (type ==
"ILUT") {
295 if (type ==
"RILUK") {
301 if (type ==
"Amesos") {
309 if (type ==
"LINESMOOTHING_BLOCKRELAXATION") {
310 return "LINESMOOTHING_BLOCKRELAXATION";
312 if (type ==
"LINESMOOTHING_BLOCK RELAXATION") {
313 return "LINESMOOTHING_BLOCKRELAXATION";
315 if (type ==
"LINESMOOTHING_BLOCK_RELAXATION") {
316 return "LINESMOOTHING_BLOCKRELAXATION";
318 if (type ==
"LINESMOOTHING_BANDEDRELAXATION") {
319 return "LINESMOOTHING_BLOCKRELAXATION";
321 if (type ==
"LINESMOOTHING_BANDED RELAXATION") {
322 return "LINESMOOTHING_BLOCKRELAXATION";
324 if (type ==
"LINESMOOTHING_BANDED_RELAXATION") {
325 return "LINESMOOTHING_BLOCKRELAXATION";
327 if (type ==
"LINESMOOTHING_TRIDIRELAXATION") {
328 return "LINESMOOTHING_BLOCKRELAXATION";
330 if (type ==
"LINESMOOTHING_TRIDI RELAXATION") {
331 return "LINESMOOTHING_BLOCKRELAXATION";
333 if (type ==
"LINESMOOTHING_TRIDI_RELAXATION") {
334 return "LINESMOOTHING_BLOCKRELAXATION";
336 if (type ==
"LINESMOOTHING_TRIDIAGONALRELAXATION") {
337 return "LINESMOOTHING_BLOCKRELAXATION";
339 if (type ==
"LINESMOOTHING_TRIDIAGONAL RELAXATION") {
340 return "LINESMOOTHING_BLOCKRELAXATION";
342 if (type ==
"LINESMOOTHING_TRIDIAGONAL_RELAXATION") {
343 return "LINESMOOTHING_BLOCKRELAXATION";
345 if (type ==
"AGGREGATE") {
348 if (type ==
"BLOCK_RELAXATION" ||
349 type ==
"BLOCK RELAXATION" ||
350 type ==
"BLOCKRELAXATION" ||
352 type ==
"BANDED_RELAXATION" ||
353 type ==
"BANDED RELAXATION" ||
354 type ==
"BANDEDRELAXATION" ||
356 type ==
"TRIDI_RELAXATION" ||
357 type ==
"TRIDI RELAXATION" ||
358 type ==
"TRIDIRELAXATION" ||
359 type ==
"TRIDIAGONAL_RELAXATION" ||
360 type ==
"TRIDIAGONAL RELAXATION" ||
361 type ==
"TRIDIAGONALRELAXATION") {
362 return "block relaxation stand-alone";
368 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
372 if (ifpack2List.
isParameter(
"relaxation: type") && ifpack2List.
get<std::string>(
"relaxation: type") ==
"Symmetric Gauss-Seidel")
373 ifpack1List.
set(
"relaxation: type",
"symmetric Gauss-Seidel");
375 if (ifpack2List.
isParameter(
"fact: iluk level-of-fill")) {
376 ifpack1List.
remove(
"fact: iluk level-of-fill");
377 ifpack1List.
set(
"fact: level-of-fill", ifpack2List.
get<
int>(
"fact: iluk level-of-fill"));
383 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
385 std::ostringstream out;
386 if (s_ != Teuchos::null) {
387 out << s_->description();
390 out <<
"{type = " << type_ <<
"}";
395 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
400 out0 <<
"Prec. type: " << type_ << std::endl;
403 out0 <<
"PrecType: " << type_ << std::endl;
404 out0 <<
"Parameter list: " << std::endl;
406 out << this->GetParameterList();
407 out0 <<
"Overlap: " << overlap_ << std::endl;
410 if (verbLevel &
Debug) {
413 <<
"Epetra PrecType: " << Ifpack2ToIfpack1Type(type_) << std::endl
414 <<
"Epetra Parameter list: " << std::endl;
416 out << Ifpack2ToIfpack1Param(this->GetParameterList());
423 #endif // MUELU_TRILINOSSMOOTHER_DEF_HPP
Important warning messages (one line)
Exception indicating invalid cast attempted.
std::string errorStratimikos_
std::string description() const
Return a simple one-line description of this object.
RCP< SmootherPrototype > sStratimikos_
RCP< SmootherPrototype > sTpetra_
T & get(const std::string &name, T def_value)
Class that encapsulates external library smoothers.
static std::string Ifpack2ToIfpack1Type(const std::string &type)
Convert an Ifpack2 preconditioner name to Ifpack.
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
static Teuchos::ParameterList Ifpack2ToIfpack1Param(const Teuchos::ParameterList &ifpack2List)
Convert an Ifpack2 parameter list to Ifpack.
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the object with some verbosity level to an FancyOStream object.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Class that encapsulates Belos smoothers.
Print additional debugging information.
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
TrilinosSmoother cannot be applied. Apply() always returns a RuntimeError exception.
void Setup(Level ¤tLevel)
TrilinosSmoother cannot be turned into a smoother using Setup(). Setup() always returns a RuntimeErro...
friend class TrilinosSmoother
Friend declaration required for clone() functionality.
bool isParameter(const std::string &name) const
bool remove(std::string const &name, bool throwIfNotExists=true)
RCP< SmootherPrototype > s_
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)
Class that holds all level-specific information.
std::string type_
ifpack1/2-specific key phrase that denote smoother type
bool IsSetup() const
Get the state of a smoother prototype.
Xpetra::UnderlyingLib lib()
RCP< SmootherPrototype > Copy() const
When this prototype is cloned using Copy(), the clone is an Ifpack or an Ifpack2 smoother.
#define MUELU_DESCRIBE
Helper macro for implementing Describable::describe() for BaseClass objects.
void DeclareInput(Level ¤tLevel) const
Input.
RCP< SmootherPrototype > sEpetra_
Smoother.
RCP< SmootherPrototype > sBelos_
Print class parameters (more parameters, more verbose)
Exception throws to report errors in the internal logical of the program.
LO overlap_
overlap when using the smoother in additive Schwarz mode
Class that encapsulates Ifpack2 smoothers.
virtual std::string description() const
Return a simple one-line description of this object.
std::string toString(const T &t)
void SetFactory(const std::string &varName, const RCP< const FactoryBase > &factory)
Custom SetFactory.