46 #ifndef MUELU_TRILINOSSMOOTHER_DEF_HPP 47 #define MUELU_TRILINOSSMOOTHER_DEF_HPP 49 #include <Xpetra_Map.hpp> 50 #include <Xpetra_Matrix.hpp> 56 #include "MueLu_Ifpack2Smoother.hpp" 61 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
63 : type_(type), overlap_(overlap)
84 #if defined(HAVE_MUELU_TPETRA) && defined(HAVE_MUELU_IFPACK2) 95 #if defined(HAVE_MUELU_EPETRA) && defined(HAVE_MUELU_IFPACK) 110 "Please enable (TPETRA and IFPACK2) or (EPETRA and IFPACK)");
113 "Could not construct any smoother:\n" 114 << (
triedEpetra_ ?
"=> Failed to build an Epetra smoother due to the following exception:\n" :
"=> Epetra and/or Ifpack are not enabled.\n")
116 << (
triedTpetra_ ?
"=> Failed to build a Tpetra smoother due to the following exception:\n" :
"=> Tpetra and/or Ifpack2 are not enabled.\n")
122 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
125 if (!sEpetra_.is_null()) sEpetra_->SetFactory(varName, factory);
126 if (!sTpetra_.is_null()) sTpetra_->SetFactory(varName, factory);
129 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
136 bool useTpetra = (currentLevel.
lib() == Xpetra::UseTpetra);
137 s_ = (useTpetra ? sTpetra_ : sEpetra_);
140 #if not defined(HAVE_MUELU_IFPACK22) 142 "Error: running in Tpetra mode, but MueLu with Ifpack2 was disabled during the configure stage.\n" 143 "Please make sure that:\n" 144 " - Ifpack2 is enabled (Trilinos_ENABLE_Ifpack2=ON),\n" 145 " - Ifpack2 is available for MueLu to use (MueLu_ENABLE_Ifpack2=ON)\n");
148 this->GetOStream(
Errors) <<
"Tpetra mode was disabled due to an error:\n" << errorTpetra_ << std::endl;
152 #if not defined(HAVE_MUELU_IFPACK) 154 "Error: running in Epetra mode, but MueLu with Ifpack was disabled during the configure stage.\n" 155 "Please make sure that:\n" 156 " - Ifpack is enabled (you can do that with Trilinos_ENABLE_Ifpack=ON),\n" 157 " - Ifpack is available for MueLu to use (MueLu_ENABLE_Ifpack=ON)\n");
160 this->GetOStream(
Errors) <<
"Epetra mode was disabled due to an error:\n" << errorEpetra_ << std::endl;
164 "Smoother for " << (useTpetra ?
"Tpetra" :
"Epetra") <<
" was not constructed");
167 s_->DeclareInput(currentLevel);
170 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
173 this->GetOStream(
Warnings0) <<
"MueLu::TrilinosSmoother::Setup(): Setup() has already been called" << std::endl;
175 int oldRank = s_->SetProcRankVerbose(this->GetProcRankVerbose());
177 s_->Setup(currentLevel);
179 s_->SetProcRankVerbose(oldRank);
183 this->SetParameterList(s_->GetParameterList());
186 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
190 s_->Apply(X, B, InitialGuessIsZero);
193 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
200 if (!sEpetra_.is_null())
201 newSmoo->
sEpetra_ = sEpetra_->Copy();
202 if (!sTpetra_.is_null())
203 newSmoo->
sTpetra_ = sTpetra_->Copy();
212 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
214 if (type ==
"RELAXATION") {
return "point relaxation stand-alone"; }
215 if (type ==
"CHEBYSHEV") {
return "Chebyshev"; }
216 if (type ==
"ILUT") {
return "ILUT"; }
217 if (type ==
"RILUK") {
return "ILU"; }
218 if (type ==
"ILU") {
return "ILU"; }
219 if (type ==
"Amesos") {
return "Amesos"; }
224 if (type ==
"LINESMOOTHING_BLOCKRELAXATION") {
return "LINESMOOTHING_BLOCKRELAXATION"; }
225 if (type ==
"LINESMOOTHING_BLOCK RELAXATION") {
return "LINESMOOTHING_BLOCKRELAXATION"; }
226 if (type ==
"LINESMOOTHING_BLOCK_RELAXATION") {
return "LINESMOOTHING_BLOCKRELAXATION"; }
227 if (type ==
"LINESMOOTHING_BANDEDRELAXATION") {
return "LINESMOOTHING_BLOCKRELAXATION"; }
228 if (type ==
"LINESMOOTHING_BANDED RELAXATION") {
return "LINESMOOTHING_BLOCKRELAXATION"; }
229 if (type ==
"LINESMOOTHING_BANDED_RELAXATION") {
return "LINESMOOTHING_BLOCKRELAXATION"; }
234 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
238 if (ifpack2List.
isParameter(
"relaxation: type") && ifpack2List.
get<std::string>(
"relaxation: type") ==
"Symmetric Gauss-Seidel")
239 ifpack1List.
set(
"relaxation: type",
"symmetric Gauss-Seidel");
241 if (ifpack2List.
isParameter(
"fact: iluk level-of-fill")) {
242 ifpack1List.
remove(
"fact: iluk level-of-fill");
243 ifpack1List.
set(
"fact: level-of-fill", ifpack2List.
get<
int>(
"fact: iluk level-of-fill"));
249 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
251 std::ostringstream out;
252 if (s_ != Teuchos::null) {
253 out << s_->description();
256 out <<
"{type = " << type_ <<
"}";
261 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
266 out0 <<
"Prec. type: " << type_ << std::endl;
269 out0 <<
"PrecType: " << type_ << std::endl;
270 out0 <<
"Parameter list: " << std::endl;
272 out << this->GetParameterList();
273 out0 <<
"Overlap: " << overlap_ << std::endl;
276 if (verbLevel &
Debug) {
279 <<
"Epetra PrecType: " << Ifpack2ToIfpack1Type(type_) << std::endl
280 <<
"Epetra Parameter list: " << std::endl;
282 out << Ifpack2ToIfpack1Param(this->GetParameterList());;
288 #endif // MUELU_TRILINOSSMOOTHER_DEF_HPP Important warning messages (one line)
Exception indicating invalid cast attempted.
RCP< SmootherPrototype > Copy() const
When this prototype is cloned using Copy(), the clone is an Ifpack or an Ifpack2 smoother.
RCP< SmootherPrototype > sTpetra_
bool IsSetup() const
Get the state of a smoother prototype.
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.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Print additional debugging information.
void DeclareInput(Level ¤tLevel) const
Input.
Namespace for MueLu classes and methods.
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.
std::string description() const
Return a simple one-line description of this object.
bool remove(std::string const &name, bool throwIfNotExists=true)
RCP< SmootherPrototype > s_
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
virtual void SetParameterList(const ParameterList ¶mList)
Set parameters from a parameter list and return with default values.
Class that holds all level-specific information.
std::string type_
ifpack1/2-specific key phrase that denote smoother type
Xpetra::UnderlyingLib lib()
#define MUELU_DESCRIBE
Helper macro for implementing Describable::describe() for BaseClass objects.
RCP< SmootherPrototype > sEpetra_
Smoother.
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the object with some verbosity level to an FancyOStream object.
bool isParameter(const std::string &name) const
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
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
TrilinosSmoother cannot be applied. Apply() always returns a RuntimeError exception.
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.