48 #ifndef MUELU_TEKOSMOOTHER_DECL_HPP_
49 #define MUELU_TEKOSMOOTHER_DECL_HPP_
51 #ifdef HAVE_MUELU_TEKO
53 #include "Teko_Utilities.hpp"
55 #include "Teko_InverseLibrary.hpp"
56 #include "Teko_InverseFactory.hpp"
62 #include <Xpetra_MapExtractor_fwd.hpp>
65 #include "MueLu_SmootherPrototype.hpp"
82 template <class Scalar = SmootherPrototype<>::scalar_type,
83 class LocalOrdinal =
typename SmootherPrototype<Scalar>::local_ordinal_type,
84 class GlobalOrdinal =
typename SmootherPrototype<Scalar, LocalOrdinal>::global_ordinal_type,
85 class Node =
typename SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal>::node_type>
90 #undef MUELU_TEKOSMOOTHER_SHORT
112 return validParamList;
133 void Apply(MultiVector& X,
const MultiVector& B,
bool InitialGuessIsZero =
false)
const { }
143 std::ostringstream out;
145 out <<
"{type = " <<
type_ <<
"}";
155 out0 <<
"Prec. type: " <<
type_ << std::endl;
157 if (verbLevel &
Debug)
195 #undef MUELU_TEKOSMOOTHER_SHORT
205 TekoSmoother() :
type_(
"Teko smoother"), A_(Teuchos::null), bA_(Teuchos::null), bThyOp_(Teuchos::null), tekoParams_(Teuchos::null), inverseOp_(Teuchos::null) { };
217 validParamList->set< std::string > (
"Inverse Type",
"",
"Name of parameter list within 'Teko parameters' containing the Teko smoother parameters.");
219 return validParamList;
223 this->Input(currentLevel,
"A");
239 this->
GetOStream(
Warnings0) <<
"MueLu::TekoSmoother::Setup(): Setup() has already been called";
242 A_ = Factory::Get< RCP<Matrix> >(currentLevel,
"A");
243 bA_ = Teuchos::rcp_dynamic_cast<BlockedCrsMatrix>(A_);
245 "MueLu::TekoSmoother::Build: input matrix A is not of type BlockedCrsMatrix.");
247 bThyOp_ = bA_->getThyraOperator();
249 "MueLu::TekoSmoother::Build: Could not extract thyra operator from BlockedCrsMatrix.");
253 "MueLu::TekoSmoother::Build: Downcast of Thyra::BlockedLinearOpBase to Teko::LinearOp failed.");
257 std::string smootherType = pL.get<std::string>(
"Inverse Type");
259 "MueLu::TekoSmoother::Build: You must provide a 'Smoother Type' name that is defined in the 'Teko parameters' sublist.");
260 type_ = smootherType;
263 "MueLu::TekoSmoother::Build: No Teko parameters have been set.");
268 inverseOp_ = Teko::buildInverse(*inverse, thyOp);
270 "MueLu::TekoSmoother::Build: Failed to build Teko inverse operator. Probably a problem with the Teko parameters.");
281 void Apply(MultiVector& X,
const MultiVector& B,
bool =
false)
const {
283 "MueLu::TekoSmoother::Apply(): Setup() has not been called");
295 Teuchos::rcp_dynamic_cast<Thyra::ProductMultiVectorBase<Scalar> >(thyB);
297 "MueLu::TekoSmoother::Apply: Failed to cast range space to product range space.");
300 Xpetra::ThyraUtils<Scalar,LocalOrdinal,GlobalOrdinal,Node>::updateThyra(Teuchos::rcpFromRef(B), rgMapExtractor, thyProdB);
305 Teuchos::rcp_dynamic_cast<Thyra::ProductMultiVectorBase<Scalar> >(thyX);
307 "MueLu::TekoSmoother::Apply: Failed to cast domain space to product domain space.");
310 Xpetra::ThyraUtils<Scalar,LocalOrdinal,GlobalOrdinal,Node>::updateThyra(Teuchos::rcpFromRef(X), rgMapExtractor, thyProdX);
321 Xpetra::ThyraUtils<Scalar,LocalOrdinal,GlobalOrdinal,Node>::toXpetra(thyX, comm);
334 std::ostringstream out;
336 out <<
"{type = " <<
type_ <<
"}";
346 out0 <<
"Prec. type: " <<
type_ << std::endl;
348 if (verbLevel &
Debug)
374 #define MUELU_TEKOSMOOTHER_SHORT
376 #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
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
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.
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.
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.