46 #ifndef THYRA_MUELU_REFMAXWELL_PRECONDITIONER_FACTORY_DEF_HPP
47 #define THYRA_MUELU_REFMAXWELL_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 typedef Thyra::DiagonalLinearOpBase<Scalar> ThyDiagLinOpBase;
104 #ifdef HAVE_MUELU_TPETRA
105 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) {
199 #ifdef HAVE_MUELU_TPETRA
201 typedef Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> tV;
202 typedef Tpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> tMV;
203 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> TpCrsMat;
208 paramList.
remove(
"Nullspace");
209 RCP<XpMultVec> nullspace = MueLu::TpetraMultiVector_To_XpetraMultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>(tpetra_nullspace);
228 RCP<XpCrsMat> crsM1NonConst = Teuchos::rcp_const_cast<XpCrsMat>(crsM1);
254 RCP<XpCrsMat> crsD0NonConst = Teuchos::rcp_const_cast<XpCrsMat>(crsD0);
270 paramList.
remove(
"M0inv");
271 RCP<XpCrsMat> xM0inv = rcp_dynamic_cast<XpCrsMat>(tM0inv,
true);
276 paramList.
remove(
"M0inv");
278 RCP<const tV> tDiag = Thyra::TpetraOperatorVectorExtraction<Scalar,LocalOrdinal,GlobalOrdinal,Node>::getConstTpetraVector(diag);
284 paramList.
remove(
"M0inv");
288 RCP<XpCrsMat> crsM0invNonConst = Teuchos::rcp_const_cast<XpCrsMat>(crsM0inv);
306 paramList.
set<
bool>(
"refmaxwell: use as preconditioner",
true);
314 #if defined(HAVE_MUELU_TPETRA)
317 RCP<ThyTpLinOp> tpetr_precOp = rcp_dynamic_cast<ThyTpLinOp>(thyra_precOp);
331 RCP<XpOp> xpOp = Teuchos::rcp_dynamic_cast<XpOp>(preconditioner);
332 thyraPrecOp = Thyra::xpetraLinearOp<Scalar, LocalOrdinal, GlobalOrdinal, Node>(thyraRangeSpace, thyraDomainSpace,xpOp);
336 defaultPrec->initializeUnspecified(thyraPrecOp);
340 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
342 uninitializePrec(PreconditionerBase<Scalar>* prec,
RCP<
const LinearOpSourceBase<Scalar> >* fwdOp, ESupportSolveUse* supportSolveUse)
const {
351 *fwdOp = Teuchos::null;
354 if (supportSolveUse) {
356 *supportSolveUse = Thyra::SUPPORT_SOLVE_UNSPECIFIED;
359 defaultPrec->uninitialize();
364 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
367 paramList_ = paramList;
370 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
375 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
378 paramList_ = Teuchos::null;
379 return savedParamList;
382 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
387 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
398 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
400 return "Thyra::MueLuRefMaxwellPreconditionerFactory";
404 #endif // HAVE_MUELU_STRATIMIKOS
406 #endif // ifdef THYRA_MUELU_REFMAXWELL_PRECONDITIONER_FACTORY_DEF_HPP
Teuchos::RCP< Teuchos::ParameterList > unsetParameterList()
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)
bool isCompatible(const LinearOpSourceBase< Scalar > &fwdOp) const
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Teuchos::RCP< PreconditionerBase< Scalar > > createPrec() const
Teuchos::RCP< Teuchos::ParameterList > getNonconstParameterList()
void uninitializePrec(PreconditionerBase< Scalar > *prec, Teuchos::RCP< const LinearOpSourceBase< Scalar > > *fwdOp, ESupportSolveUse *supportSolveUse) const
Preconditioner (wrapped as a Xpetra::Operator) for Maxwell's equations in curl-curl form...
static RCP< Time > getNewTimer(const std::string &name)
bool isParameter(const std::string &name) const
bool remove(std::string const &name, bool throwIfNotExists=true)
MueLuRefMaxwellPreconditionerFactory()
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void initializePrec(const Teuchos::RCP< const LinearOpSourceBase< Scalar > > &fwdOp, PreconditionerBase< Scalar > *prec, const ESupportSolveUse supportSolveUse) const
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > ¶mList)
RCP< const CrsGraph< int, GlobalOrdinal, Node > > toXpetra(const Epetra_CrsGraph &g)
std::string description() const
bool isType(const std::string &name) const
static RCP< Matrix > Build(const RCP< const Map > &rowMap, size_t maxNumEntriesPerRow, Xpetra::ProfileType pftype=Xpetra::DynamicProfile)
Exception throws to report errors in the internal logical of the program.
#define TEUCHOS_ASSERT(assertion_test)
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
Teuchos::RCP< const Teuchos::ParameterList > getParameterList() const