13 #include "Thyra_DefaultPreconditioner.hpp"
14 #include "Ifpack_ValidParameters.h"
15 #include "Ifpack_Preconditioner.h"
17 #include "Epetra_RowMatrix.h"
31 const std::string Ifpack_name =
"Ifpack";
33 const std::string IfpackSettings_name =
"Ifpack Settings";
35 const std::string PrecType_name =
"Prec Type";
38 const Ifpack::EPrecType PrecType_default = Ifpack::ILU;
39 const std::string PrecTypeName_default = Ifpack::precTypeNames[PrecType_default];
41 const std::string Overlap_name =
"Overlap";
42 const int Overlap_default = 0;
59 ,precType_(PrecType_default)
60 ,overlap_(Overlap_default)
69 const LinearOpSourceBase<double> &fwdOpSrc
72 using Teuchos::outArg;
74 EOpTransp epetraFwdOpTransp;
77 double epetraFwdOpScalar;
78 epetraFwdOpViewExtractor_->getEpetraOpView(
80 outArg(epetraFwdOp), outArg(epetraFwdOpTransp),
81 outArg(epetraFwdOpApplyAs), outArg(epetraFwdOpAdjointSupport),
82 outArg(epetraFwdOpScalar)
84 if( !dynamic_cast<const Epetra_RowMatrix*>(&*epetraFwdOp) )
102 return Teuchos::rcp(
new DefaultPreconditioner<double>());
106 const Teuchos::RCP<
const LinearOpSourceBase<double> > &fwdOpSrc
107 ,PreconditionerBase<double> *prec
108 ,
const ESupportSolveUse
111 using Teuchos::outArg;
117 using Teuchos::rcp_dynamic_cast;
118 using Teuchos::rcp_const_cast;
119 using Teuchos::set_extra_data;
120 using Teuchos::get_optional_extra_data;
123 totalTimer.start(
true);
124 #ifdef STRATIMIKOS_TEUCHOS_TIME_MONITOR
131 *out <<
"\nEntering Thyra::IfpackPreconditionerFactory::initializePrec(...) ...\n";
137 fwdOp = fwdOpSrc->getOp();
139 TEUCHOS_TEST_FOR_EXCEPT(fwdOp.
get()==NULL);
145 EOpTransp epetraFwdOpTransp;
148 double epetraFwdOpScalar;
149 epetraFwdOpViewExtractor_->getEpetraOpView(
151 outArg(epetraFwdOp), outArg(epetraFwdOpTransp),
152 outArg(epetraFwdOpApplyAs), outArg(epetraFwdOpAdjointSupport),
153 outArg(epetraFwdOpScalar)
157 epetraFwdRowMat = rcp_dynamic_cast<
const Epetra_RowMatrix>(epetraFwdOp,
true);
160 ,
"Error, incorrect apply mode for an Epetra_RowMatrix"
165 DefaultPreconditioner<double>
171 epetra_precOp = rcp_dynamic_cast<
EpetraLinearOp>(defaultPrec->getNonconstUnspecifiedPrecOp(),
true);
177 if(epetra_precOp.
get())
178 ifpack_precOp = rcp_dynamic_cast<Ifpack_Preconditioner>(epetra_precOp->epetra_op(),
true);
182 if(ifpack_precOp.get()) {
190 const bool startingOver =
true;
200 #ifdef STRATIMIKOS_TEUCHOS_TIME_MONITOR
207 ,const_cast<Epetra_RowMatrix*>(&*epetraFwdRowMat)
219 TEUCHOS_TEST_FOR_EXCEPT(0!=ifpack_precOp->SetParameters(ifpackSettingsPL));
224 TEUCHOS_TEST_FOR_EXCEPT(0!=ifpack_precOp->Initialize());
229 set_extra_data(epetraFwdOp,
"IFPF::epetraFwdOp", Teuchos::inOutArg(ifpack_precOp),
236 *out <<
"\nComputing the preconditioner ...\n";
237 #ifdef STRATIMIKOS_TEUCHOS_TIME_MONITOR
241 TEUCHOS_TEST_FOR_EXCEPT(0!=ifpack_precOp->Compute());
255 set_extra_data(fwdOpSrc,
"IFPF::fwdOpSrc", Teuchos::inOutArg(ifpack_precOp),
263 epetra_precOp->initialize(
270 *out <<
"\nDescription of created preconditioner:\n";
272 ifpack_precOp->Print(*out);
278 defaultPrec->initializeUnspecified(
279 Teuchos::rcp_implicit_cast<LinearOpBase<double> >(epetra_precOp)
283 *out <<
"\nTotal time in IfpackPreconditionerFactory = "<<totalTimer.totalElapsedTime()<<
" sec\n";
285 *out <<
"\nLeaving Thyra::IfpackPreconditionerFactory::initializePrec(...) ...\n";
289 PreconditionerBase<double> *
307 std::ostringstream oss;
308 oss <<
"(sub)list \""<<paramList->
name()<<
"\"parameter \"Prec Type\"";
314 Teuchos::readVerboseObjectSublist(&*
paramList_,
this);
345 using Teuchos::rcp_implicit_cast;
348 if(validParamList.
get()==NULL) {
355 precTypeNames.
begin(),
356 &Ifpack::precTypeNames[0],
357 &Ifpack::precTypeNames[0] + Ifpack::numPrecTypes
362 precTypeValues.
begin(),
363 &Ifpack::precTypeValues[0],
364 &Ifpack::precTypeValues[0] + Ifpack::numPrecTypes
366 precTypeValidator =
rcp(
368 precTypeNames,precTypeValues,PrecType_name
373 PrecType_name, PrecTypeName_default,
374 "Type of Ifpack preconditioner to use.",
375 rcp_implicit_cast<const PEV>(precTypeValidator)
378 Overlap_name, Overlap_default,
379 "Number of rows/columns overlapped between subdomains in different"
380 "\nprocesses in the additive Schwarz-type domain-decomposition preconditioners."
383 IfpackSettings_name, Ifpack_GetValidParameters(),
384 "Preconditioner settings that are passed onto the Ifpack preconditioners themselves."
391 Teuchos::setupVerboseObjectSublist(&*validParamList);
393 return validParamList;
400 std::ostringstream oss;
401 oss <<
"Thyra::IfpackPreconditionerFactory{";
412 if(!overallTimer.get()) {
413 #ifdef STRATIMIKOS_TEUCHOS_TIME_MONITOR
static void initializeTimers()
const std::string & name() const
const std::string toString(const EAdjointEpetraOp adjointEpetraOp)
std::string description() const
::Ifpack::EPrecType precType_
Teuchos::RCP< Teuchos::ParameterList > paramList_
Teuchos::RCP< PreconditionerBase< double > > createPrec() const
T & get(ParameterList &l, const std::string &name)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
bool isCompatible(const LinearOpSourceBase< double > &fwdOpSrc) const
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
RCP< ParameterList > sublist(const RCP< ParameterList > ¶mList, const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
void uninitializePrec(PreconditionerBase< double > *prec, Teuchos::RCP< const LinearOpSourceBase< double > > *fwdOpSrc, ESupportSolveUse *supportSolveUse) const
bool applyTransposeSupportsConj(EConj conj) const
basic_OSTab< char > OSTab
IfpackPreconditionerFactory()
Teuchos::RCP< const Teuchos::ParameterList > getParameterList() const
static RCP< Time > getNewTimer(const std::string &name)
IntegralType getIntegralValue(ParameterList const ¶mList, std::string const ¶mName)
void start(bool reset=false)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
T_To & dyn_cast(T_From &from)
bool applySupportsConj(EConj conj) const
TypeTo implicit_cast(const TypeFrom &t)
void validateParameters(ParameterList const &validParamList, int const depth=1000, EValidateUsed const validateUsed=VALIDATE_USED_ENABLED, EValidateDefaults const validateDefaults=VALIDATE_DEFAULTS_ENABLED) const
void setParameterList(Teuchos::RCP< Teuchos::ParameterList > const ¶mList)
#define TEUCHOS_ADD_STRINGTOINTEGRALVALIDATOR_CONVERTER(INTEGRALTYPE)
Teuchos::RCP< Teuchos::ParameterList > unsetParameterList()
void initializePrec(const Teuchos::RCP< const LinearOpSourceBase< double > > &fwdOpSrc, PreconditionerBase< double > *prec, const ESupportSolveUse supportSolveUse) const
double totalElapsedTime(bool readCurrentTime=false) const
iterator insert(iterator position, const value_type &x)
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
Teuchos::RCP< Teuchos::ParameterList > getNonconstParameterList()