45 #include "Thyra_DefaultPreconditioner.hpp"
46 #include "Ifpack_ValidParameters.h"
47 #include "Ifpack_Preconditioner.h"
49 #include "Epetra_RowMatrix.h"
63 const std::string Ifpack_name =
"Ifpack";
65 const std::string IfpackSettings_name =
"Ifpack Settings";
67 const std::string PrecType_name =
"Prec Type";
70 const Ifpack::EPrecType PrecType_default = Ifpack::ILU;
71 const std::string PrecTypeName_default = Ifpack::precTypeNames[PrecType_default];
73 const std::string Overlap_name =
"Overlap";
74 const int Overlap_default = 0;
91 ,precType_(PrecType_default)
92 ,overlap_(Overlap_default)
101 const LinearOpSourceBase<double> &fwdOpSrc
104 using Teuchos::outArg;
106 EOpTransp epetraFwdOpTransp;
109 double epetraFwdOpScalar;
110 epetraFwdOpViewExtractor_->getEpetraOpView(
112 outArg(epetraFwdOp), outArg(epetraFwdOpTransp),
113 outArg(epetraFwdOpApplyAs), outArg(epetraFwdOpAdjointSupport),
114 outArg(epetraFwdOpScalar)
116 if( !dynamic_cast<const Epetra_RowMatrix*>(&*epetraFwdOp) )
134 return Teuchos::rcp(
new DefaultPreconditioner<double>());
138 const Teuchos::RCP<
const LinearOpSourceBase<double> > &fwdOpSrc
139 ,PreconditionerBase<double> *prec
140 ,
const ESupportSolveUse
143 using Teuchos::outArg;
149 using Teuchos::rcp_dynamic_cast;
150 using Teuchos::rcp_const_cast;
151 using Teuchos::set_extra_data;
152 using Teuchos::get_optional_extra_data;
155 totalTimer.start(
true);
156 #ifdef STRATIMIKOS_TEUCHOS_TIME_MONITOR
163 *out <<
"\nEntering Thyra::IfpackPreconditionerFactory::initializePrec(...) ...\n";
169 fwdOp = fwdOpSrc->getOp();
171 TEUCHOS_TEST_FOR_EXCEPT(fwdOp.
get()==NULL);
177 EOpTransp epetraFwdOpTransp;
180 double epetraFwdOpScalar;
181 epetraFwdOpViewExtractor_->getEpetraOpView(
183 outArg(epetraFwdOp), outArg(epetraFwdOpTransp),
184 outArg(epetraFwdOpApplyAs), outArg(epetraFwdOpAdjointSupport),
185 outArg(epetraFwdOpScalar)
189 epetraFwdRowMat = rcp_dynamic_cast<
const Epetra_RowMatrix>(epetraFwdOp,
true);
192 ,
"Error, incorrect apply mode for an Epetra_RowMatrix"
197 DefaultPreconditioner<double>
203 epetra_precOp = rcp_dynamic_cast<
EpetraLinearOp>(defaultPrec->getNonconstUnspecifiedPrecOp(),
true);
209 if(epetra_precOp.
get())
210 ifpack_precOp = rcp_dynamic_cast<Ifpack_Preconditioner>(epetra_precOp->epetra_op(),
true);
214 if(ifpack_precOp.get()) {
222 const bool startingOver =
true;
232 #ifdef STRATIMIKOS_TEUCHOS_TIME_MONITOR
239 ,const_cast<Epetra_RowMatrix*>(&*epetraFwdRowMat)
251 TEUCHOS_TEST_FOR_EXCEPT(0!=ifpack_precOp->SetParameters(ifpackSettingsPL));
256 TEUCHOS_TEST_FOR_EXCEPT(0!=ifpack_precOp->Initialize());
261 set_extra_data(epetraFwdOp,
"IFPF::epetraFwdOp", Teuchos::inOutArg(ifpack_precOp),
268 *out <<
"\nComputing the preconditioner ...\n";
269 #ifdef STRATIMIKOS_TEUCHOS_TIME_MONITOR
273 TEUCHOS_TEST_FOR_EXCEPT(0!=ifpack_precOp->Compute());
287 set_extra_data(fwdOpSrc,
"IFPF::fwdOpSrc", Teuchos::inOutArg(ifpack_precOp),
295 epetra_precOp->initialize(
302 *out <<
"\nDescription of created preconditioner:\n";
304 ifpack_precOp->Print(*out);
310 defaultPrec->initializeUnspecified(
311 Teuchos::rcp_implicit_cast<LinearOpBase<double> >(epetra_precOp)
315 *out <<
"\nTotal time in IfpackPreconditionerFactory = "<<totalTimer.totalElapsedTime()<<
" sec\n";
317 *out <<
"\nLeaving Thyra::IfpackPreconditionerFactory::initializePrec(...) ...\n";
321 PreconditionerBase<double> *
339 std::ostringstream oss;
340 oss <<
"(sub)list \""<<paramList->
name()<<
"\"parameter \"Prec Type\"";
346 Teuchos::readVerboseObjectSublist(&*
paramList_,
this);
377 using Teuchos::rcp_implicit_cast;
380 if(validParamList.
get()==NULL) {
387 precTypeNames.
begin(),
388 &Ifpack::precTypeNames[0],
389 &Ifpack::precTypeNames[0] + Ifpack::numPrecTypes
394 precTypeValues.
begin(),
395 &Ifpack::precTypeValues[0],
396 &Ifpack::precTypeValues[0] + Ifpack::numPrecTypes
398 precTypeValidator =
rcp(
400 precTypeNames,precTypeValues,PrecType_name
405 PrecType_name, PrecTypeName_default,
406 "Type of Ifpack preconditioner to use.",
407 rcp_implicit_cast<const PEV>(precTypeValidator)
410 Overlap_name, Overlap_default,
411 "Number of rows/columns overlapped between subdomains in different"
412 "\nprocesses in the additive Schwarz-type domain-decomposition preconditioners."
415 IfpackSettings_name,
false,
416 "Preconditioner settings that are passed onto the Ifpack preconditioners themselves."
417 ).setParameters(Ifpack_GetValidParameters());
423 Teuchos::setupVerboseObjectSublist(&*validParamList);
425 return validParamList;
432 std::ostringstream oss;
433 oss <<
"Thyra::IfpackPreconditionerFactory{";
444 if(!overallTimer.get()) {
445 #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)
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
#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="")
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()