10 #ifndef MUELU_TEKOSMOOTHER_DECL_HPP_
11 #define MUELU_TEKOSMOOTHER_DECL_HPP_
13 #ifdef HAVE_MUELU_TEKO
15 #include "Teko_Utilities.hpp"
17 #include "Teko_InverseLibrary.hpp"
18 #include "Teko_InverseFactory.hpp"
27 #include "MueLu_SmootherPrototype.hpp"
42 template <class Scalar = SmootherPrototype<>::scalar_type,
43 class LocalOrdinal =
typename SmootherPrototype<Scalar>::local_ordinal_type,
44 class GlobalOrdinal =
typename SmootherPrototype<Scalar, LocalOrdinal>::global_ordinal_type,
45 class Node =
typename SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal>::node_type>
49 #undef MUELU_TEKOSMOOTHER_SHORT
59 :
type_(
"Teko smoother") {
71 return validParamList;
92 void Apply(MultiVector &X,
const MultiVector &B,
bool InitialGuessIsZero =
false)
const {}
102 std::ostringstream out;
104 out <<
"{type = " <<
type_ <<
"}";
114 out0 <<
"Prec. type: " <<
type_ << std::endl;
116 if (verbLevel &
Debug)
151 #undef MUELU_TEKOSMOOTHER_SHORT
161 :
type_(
"Teko smoother")
164 , bThyOp_(Teuchos::null)
165 , tekoParams_(Teuchos::null)
166 , inverseOp_(Teuchos::null){};
178 validParamList->set<std::string>(
"Inverse Type",
"",
"Name of parameter list within 'Teko parameters' containing the Teko smoother parameters.");
180 return validParamList;
184 this->
Input(currentLevel,
"A");
200 this->
GetOStream(
Warnings0) <<
"MueLu::TekoSmoother::Setup(): Setup() has already been called";
203 A_ = Factory::Get<RCP<Matrix> >(currentLevel,
"A");
204 bA_ = Teuchos::rcp_dynamic_cast<BlockedCrsMatrix>(A_);
206 "MueLu::TekoSmoother::Build: input matrix A is not of type BlockedCrsMatrix.");
208 bThyOp_ = bA_->getThyraOperator();
210 "MueLu::TekoSmoother::Build: Could not extract thyra operator from BlockedCrsMatrix.");
214 "MueLu::TekoSmoother::Build: Downcast of Thyra::BlockedLinearOpBase to Teko::LinearOp failed.");
218 std::string smootherType = pL.get<std::string>(
"Inverse Type");
220 "MueLu::TekoSmoother::Build: You must provide a 'Smoother Type' name that is defined in the 'Teko parameters' sublist.");
221 type_ = smootherType;
224 "MueLu::TekoSmoother::Build: No Teko parameters have been set.");
229 inverseOp_ = Teko::buildInverse(*inverse, thyOp);
231 "MueLu::TekoSmoother::Build: Failed to build Teko inverse operator. Probably a problem with the Teko parameters.");
242 void Apply(MultiVector &X,
const MultiVector &B,
bool =
false)
const {
244 "MueLu::TekoSmoother::Apply(): Setup() has not been called");
256 Teuchos::rcp_dynamic_cast<Thyra::ProductMultiVectorBase<Scalar> >(thyB);
258 "MueLu::TekoSmoother::Apply: Failed to cast range space to product range space.");
261 Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::updateThyra(Teuchos::rcpFromRef(B), rgMapExtractor, thyProdB);
266 Teuchos::rcp_dynamic_cast<Thyra::ProductMultiVectorBase<Scalar> >(thyX);
268 "MueLu::TekoSmoother::Apply: Failed to cast domain space to product domain space.");
271 Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::updateThyra(Teuchos::rcpFromRef(X), rgMapExtractor, thyProdX);
282 Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::toXpetra(thyX, comm);
295 std::ostringstream out;
297 out <<
"{type = " <<
type_ <<
"}";
307 out0 <<
"Prec. type: " <<
type_ << std::endl;
309 if (verbLevel &
Debug)
337 #define MUELU_TEKOSMOOTHER_SHORT
339 #endif // HAVE_MUELU_TEKO
Important warning messages (one line)
virtual const Teuchos::ParameterList & GetParameterList() const
std::string description() const
Return a simple one-line description of this object.
Exception indicating invalid cast attempted.
MueLu::DefaultLocalOrdinal LocalOrdinal
Teuchos::FancyOStream & GetOStream(MsgType type, int thisProcRankOnly=0) const
Get an output stream for outputting the input message type.
Xpetra::MapExtractor< Scalar, LocalOrdinal, GlobalOrdinal, Node > MapExtractorClass
RCP< const ParameterList > GetValidParameterList() const
Input.
bool is_null(const std::shared_ptr< T > &p)
RCP< SmootherPrototype > Copy() const
void DeclareInput(Level ¤tLevel) const
Input.
virtual ~TekoSmoother()
Destructor.
Timer to be used in factories. Similar to Monitor but with additional timers.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
RCP< Matrix > A_
block operator
virtual ~TekoSmoother()
Destructor.
Base class for smoother prototypes.
Print additional debugging information.
TekoSmoother()
Constructor.
std::string description() const
Return a simple one-line description of this object.
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the object with some verbosity level to an FancyOStream object.
void SetTekoParameters(RCP< ParameterList > tekoParams)
RCP< const ParameterList > GetValidParameterList() const
Input.
size_t getNodeSmootherComplexity() const
Get a rough estimate of cost per iteration.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
MueLu::DefaultGlobalOrdinal GlobalOrdinal
Class that holds all level-specific information.
void Setup(Level ¤tLevel)
Setup routine.
TekoSmoother()
Constructor.
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the object with some verbosity level to an FancyOStream object.
bool IsSetup() const
Get the state of a smoother prototype.
void SetTekoParameters(RCP< ParameterList > tekoParams)
std::string type_
smoother type
#define MUELU_DESCRIBE
Helper macro for implementing Describable::describe() for BaseClass objects.
RCP< SmootherPrototype > Copy() const
void DeclareInput(Level ¤tLevel) const
Input.
void Setup(Level ¤tLevel)
Setup routine.
void Apply(MultiVector &X, const MultiVector &B, bool=false) const
Apply the Teko smoother.
RCP< const Thyra::BlockedLinearOpBase< Scalar > > bThyOp_
RCP< BlockedCrsMatrix > bA_
Exception throws to report errors in the internal logical of the program.
Xpetra::MapExtractor< Scalar, LocalOrdinal, GlobalOrdinal, Node > MapExtractorClass
std::string type_
smoother type
Teko::LinearOp inverseOp_
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
Apply the Teko smoother.
void Input(Level &level, const std::string &varName) const
size_t getNodeSmootherComplexity() const
Get a rough estimate of cost per iteration.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
virtual std::string description() const
Return a simple one-line description of this object.
std::string toString(const T &t)
RCP< ParameterList > tekoParams_
Teko parameters.
int inverse(const Epetra_SerialDenseMatrix &, Epetra_SerialDenseMatrix &)
Interface to block smoothers in Teko package.