46 #ifndef THYRA_MUELU_PRECONDITIONER_FACTORY_DEF_HPP
47 #define THYRA_MUELU_PRECONDITIONER_FACTORY_DEF_HPP
51 #ifdef HAVE_MUELU_STRATIMIKOS
62 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
69 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
73 #ifdef HAVE_MUELU_TPETRA
74 if (Xpetra::ThyraUtils<Scalar,LocalOrdinal,GlobalOrdinal,Node>::isTpetra(fwdOp))
return true;
77 if (Xpetra::ThyraUtils<Scalar,LocalOrdinal,GlobalOrdinal,Node>::isBlockedOperator(fwdOp))
return true;
83 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
88 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
90 initializePrec(
const RCP<
const LinearOpSourceBase<Scalar> >& fwdOpSrc, PreconditionerBase<Scalar>* prec,
const ESupportSolveUse supportSolveUse)
const {
91 using Teuchos::rcp_dynamic_cast;
96 typedef Xpetra::ThyraUtils<Scalar,LocalOrdinal,GlobalOrdinal,Node> XpThyUtils;
102 typedef Thyra::LinearOpBase<Scalar> ThyLinOpBase;
103 #ifdef HAVE_MUELU_TPETRA
105 typedef Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> TpOp;
106 typedef Thyra::TpetraLinearOp<Scalar,LocalOrdinal,GlobalOrdinal,Node> ThyTpLinOp;
122 bool bIsEpetra = XpThyUtils::isEpetra(fwdOp);
123 bool bIsTpetra = XpThyUtils::isTpetra(fwdOp);
124 bool bIsBlocked = XpThyUtils::isBlockedOperator(fwdOp);
132 Teuchos::rcp_dynamic_cast<
const Thyra::BlockedLinearOpBase<Scalar> >(fwdOp);
135 TEUCHOS_TEST_FOR_EXCEPT(ThyBlockedOp->blockExists(0,0)==
false);
144 RCP<XpCrsMat> xpetraFwdCrsMatNonConst00 = Teuchos::rcp_const_cast<XpCrsMat>(xpetraFwdCrsMat00);
165 RCP<XpCrsMat> xpetraFwdCrsMatNonConst = Teuchos::rcp_const_cast<XpCrsMat>(xpetraFwdCrsMat);
179 thyra_precOp = rcp_dynamic_cast<Thyra::LinearOpBase<Scalar> >(defaultPrec->getNonconstUnspecifiedPrecOp(),
true);
187 const bool startingOver = (thyra_precOp.
is_null() || !paramList.
isParameter(
"reuse: type") || paramList.
get<std::string>(
"reuse: type") ==
"none");
189 if (startingOver ==
true) {
196 #ifdef HAVE_MUELU_TPETRA
198 typedef Tpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> tMV;
199 RCP<tMV> tpetra_nullspace = Teuchos::null;
201 tpetra_nullspace = paramList.
get<
RCP<tMV> >(
"Nullspace");
202 paramList.
remove(
"Nullspace");
203 nullspace = MueLu::TpetraMultiVector_To_XpetraMultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>(tpetra_nullspace);
222 #if defined(HAVE_MUELU_TPETRA)
225 RCP<ThyTpLinOp> tpetr_precOp = rcp_dynamic_cast<ThyTpLinOp>(thyra_precOp);
226 RCP<MueTpOp> muelu_precOp = rcp_dynamic_cast<MueTpOp>(tpetr_precOp->getTpetraOperator(),
true);
228 H = muelu_precOp->GetHierarchy();
234 "Thyra::MueLuPreconditionerFactory: Hierarchy has no levels in it");
236 "Thyra::MueLuPreconditionerFactory: Hierarchy has no fine level operator");
245 A->SetFixedBlockSize(A0->GetFixedBlockSize());
256 #if defined(HAVE_MUELU_TPETRA)
260 RCP<TpOp> tpOp = Teuchos::rcp_dynamic_cast<TpOp>(muelu_tpetraOp);
261 thyraPrecOp = Thyra::createLinearOp<Scalar, LocalOrdinal, GlobalOrdinal, Node>(tpOp);
276 thyraPrecOp = Thyra::xpetraLinearOp<Scalar, LocalOrdinal, GlobalOrdinal, Node>(thyraRangeSpace, thyraDomainSpace,xpOp);
281 defaultPrec->initializeUnspecified(thyraPrecOp);
285 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
287 uninitializePrec(PreconditionerBase<Scalar>* prec,
RCP<
const LinearOpSourceBase<Scalar> >* fwdOp, ESupportSolveUse* supportSolveUse)
const {
296 *fwdOp = Teuchos::null;
299 if (supportSolveUse) {
301 *supportSolveUse = Thyra::SUPPORT_SOLVE_UNSPECIFIED;
304 defaultPrec->uninitialize();
309 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
312 paramList_ = paramList;
315 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
320 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
323 paramList_ = Teuchos::null;
324 return savedParamList;
327 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
332 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
343 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
345 return "Thyra::MueLuPreconditionerFactory";
349 #endif // HAVE_MUELU_STRATIMIKOS
351 #endif // ifdef THYRA_MUELU_PRECONDITIONER_FACTORY_DEF_HPP
T & get(const std::string &name, T def_value)
static RCP< Xpetra::MultiVector< typename Teuchos::ScalarTraits< Scalar >::magnitudeType, LocalOrdinal, GlobalOrdinal, Node > > ExtractCoordinatesFromParameterList(ParameterList ¶mList)
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
bool nonnull(const std::shared_ptr< T > &p)
bool is_null(const std::shared_ptr< T > &p)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void initializePrec(const Teuchos::RCP< const LinearOpSourceBase< Scalar > > &fwdOp, PreconditionerBase< Scalar > *prec, const ESupportSolveUse supportSolveUse) const
void uninitializePrec(PreconditionerBase< Scalar > *prec, Teuchos::RCP< const LinearOpSourceBase< Scalar > > *fwdOp, ESupportSolveUse *supportSolveUse) const
bool isParameter(const std::string &name) const
bool remove(std::string const &name, bool throwIfNotExists=true)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::RCP< MueLu::Hierarchy< Scalar, LocalOrdinal, GlobalOrdinal, Node > > CreateXpetraPreconditioner(Teuchos::RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > op, const Teuchos::ParameterList &inParamList)
Helper function to create a MueLu preconditioner that can be used by Xpetra.Given an Xpetra::Matrix...
bool isCompatible(const LinearOpSourceBase< Scalar > &fwdOp) const
Teuchos::RCP< const Teuchos::ParameterList > getParameterList() const
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > ¶mList)
MueLuPreconditionerFactory()
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
std::string description() const
Teuchos::RCP< PreconditionerBase< Scalar > > createPrec() const
bool isType(const std::string &name) const
Wraps an existing MueLu::Hierarchy as a Tpetra::Operator.
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
Exception throws to report errors in the internal logical of the program.
#define TEUCHOS_ASSERT(assertion_test)
Teuchos::RCP< Teuchos::ParameterList > getNonconstParameterList()
Teuchos::RCP< Teuchos::ParameterList > unsetParameterList()
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
Wraps an existing MueLu::Hierarchy as a Xpetra::Operator.