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)
78 ParameterList paramList = paramListIn;
84 #if defined(HAVE_MUELU_TPETRA) && defined(HAVE_MUELU_IFPACK2) 93 #if defined(HAVE_MUELU_EPETRA) && defined(HAVE_MUELU_IFPACK) 108 "Plase enable (TPETRA and IFPACK2) or (EPETRA and IFPACK)");
111 "Could not enable any smoother:\n" 112 << (
triedEpetra_ ?
"Epetra mode was disabled due to an error:\n" :
"")
114 << (
triedTpetra_ ?
"Tpetra mode was disabled due to an error:\n" :
"")
120 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
127 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
134 bool useTpetra = (currentLevel.
lib() == Xpetra::UseTpetra);
138 #if not defined(HAVE_MUELU_IFPACK22) 140 "Error: running in Tpetra mode, but MueLu with Ifpack2 was disabled during the configure stage.\n" 141 "Please make sure that:\n" 142 " - Ifpack2 is enabled (Trilinos_ENABLE_Ifpack2=ON),\n" 143 " - Ifpack2 is available for MueLu to use (MueLu_ENABLE_Ifpack2=ON)\n");
150 #if not defined(HAVE_MUELU_IFPACK) 152 "Error: running in Epetra mode, but MueLu with Ifpack was disabled during the configure stage.\n" 153 "Please make sure that:\n" 154 " - Ifpack is enabled (you can do that with Trilinos_ENABLE_Ifpack=ON),\n" 155 " - Ifpack is available for MueLu to use (MueLu_ENABLE_Ifpack=ON)\n");
162 "Smoother for " << (useTpetra ?
"Tpetra" :
"Epetra") <<
" was not constructed");
165 s_->DeclareInput(currentLevel);
168 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
171 this->
GetOStream(
Warnings0) <<
"MueLu::TrilinosSmoother::Setup(): Setup() has already been called";
175 s_->Setup(currentLevel);
177 s_->SetProcRankVerbose(oldRank);
184 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
188 s_->Apply(X, B, InitialGuessIsZero);
191 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
192 RCP<MueLu::SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
199 newSmoo->sEpetra_ =
sEpetra_->Copy();
201 newSmoo->sTpetra_ =
sTpetra_->Copy();
204 newSmoo->s_ = (
s_.get() ==
sTpetra_.get() ? newSmoo->sTpetra_ : newSmoo->sEpetra_);
210 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
212 if (type ==
"RELAXATION") {
return "point relaxation stand-alone"; }
213 if (type ==
"CHEBYSHEV") {
return "Chebyshev"; }
214 if (type ==
"ILUT") {
return "ILUT"; }
215 if (type ==
"RILUK") {
return "ILU"; }
216 if (type ==
"ILU") {
return "ILU"; }
217 if (type ==
"Amesos") {
return "Amesos"; }
222 if (type ==
"LINESMOOTHING_BLOCKRELAXATION") {
return "LINESMOOTHING_BLOCKRELAXATION"; }
223 if (type ==
"LINESMOOTHING_BLOCK RELAXATION") {
return "LINESMOOTHING_BLOCKRELAXATION"; }
224 if (type ==
"LINESMOOTHING_BLOCK_RELAXATION") {
return "LINESMOOTHING_BLOCKRELAXATION"; }
225 if (type ==
"LINESMOOTHING_BANDEDRELAXATION") {
return "LINESMOOTHING_BLOCKRELAXATION"; }
226 if (type ==
"LINESMOOTHING_BANDED RELAXATION") {
return "LINESMOOTHING_BLOCKRELAXATION"; }
227 if (type ==
"LINESMOOTHING_BANDED_RELAXATION") {
return "LINESMOOTHING_BLOCKRELAXATION"; }
229 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"Cannot convert Ifpack2 preconditioner name to Ifpack: unknown type: " + type);
232 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
234 Teuchos::ParameterList ifpack1List = ifpack2List;
236 if (ifpack2List.isParameter(
"relaxation: type") && ifpack2List.get<std::string>(
"relaxation: type") ==
"Symmetric Gauss-Seidel")
237 ifpack1List.set(
"relaxation: type",
"symmetric Gauss-Seidel");
239 if (ifpack2List.isParameter(
"fact: iluk level-of-fill")) {
240 ifpack1List.remove(
"fact: iluk level-of-fill");
241 ifpack1List.set(
"fact: level-of-fill", ifpack2List.get<
int>(
"fact: iluk level-of-fill"));
247 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
249 std::ostringstream out;
250 if (
s_ != Teuchos::null) {
251 out <<
s_->description();
254 out <<
"{type = " <<
type_ <<
"}";
259 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
264 out0 <<
"Prec. type: " <<
type_ << std::endl;
267 out0 <<
"PrecType: " <<
type_ << std::endl;
268 out0 <<
"Parameter list: " << std::endl;
269 Teuchos::OSTab tab2(out);
271 out0 <<
"Overlap: " <<
overlap_ << std::endl;
274 if (verbLevel &
Debug) {
278 <<
"Epetra Parameter list: " << std::endl;
279 Teuchos::OSTab tab2(out);
286 #endif // MUELU_TRILINOSSMOOTHER_DEF_HPP Important warning messages (one line)
std::string toString(const T &what)
Little helper function to convert non-string types to strings.
std::string description() const
Return a simple one-line description of this object.
RCP< SmootherPrototype > sTpetra_
static std::string Ifpack2ToIfpack1Type(const std::string &type)
Convert an Ifpack2 preconditioner name to Ifpack.
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.
Print additional debugging information.
Namespace for MueLu classes and methods.
virtual const Teuchos::ParameterList & GetParameterList() const
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.
RCP< SmootherPrototype > s_
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
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.
Teuchos::FancyOStream & GetOStream(MsgType type, int thisProcRankOnly=0) const
Get an output stream for outputting the input message type.
void DeclareInput(Level ¤tLevel) const
Input.
RCP< SmootherPrototype > sEpetra_
Smoother.
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.
int GetProcRankVerbose() const
Get proc rank used for printing. Do not use this information for any other purpose.
void SetFactory(const std::string &varName, const RCP< const FactoryBase > &factory)
Custom SetFactory.