00001
00002
00003
00004
00005
00006 #include "PlayaParameterListPreconditionerFactory.hpp"
00007 #include "PlayaGenericRightPreconditioner.hpp"
00008
00009 #ifndef HAVE_TEUCHOS_EXPLICIT_INSTANTIATION
00010 #include "PlayaVectorImpl.hpp"
00011 #include "PlayaLinearOperatorImpl.hpp"
00012 #endif
00013
00014 using namespace Playa;
00015 using namespace Teuchos;
00016
00017 Preconditioner<double> ParameterListPreconditionerFactory::
00018 createPreconditioner(const LinearOperator<double>& A) const
00019 {
00020 const std::string& pType = params_.get<string>("Type");
00021
00022 Preconditioner<double> rtn;
00023
00024 if (pType=="ML")
00025 {
00026 std::string precType = params_.get<string>("Problem Type");
00027 ParameterList mlParams;
00028 ML_Epetra::SetDefaults(precType, mlParams);
00029 ParameterList::ConstIterator iter;
00030 ParameterList mlSettings = params_.sublist("ML Settings");
00031 for (iter=mlSettings.begin(); iter!=mlSettings.end(); ++iter)
00032 {
00033 const std::string& name = mlSettings.name(iter);
00034 const ParameterEntry& entry = mlSettings.entry(iter);
00035 mlParams.setEntry(name, entry);
00036 }
00037 RCP<LinearOperatorBase<double> > mlp
00038 = rcp(new MLOperator(A, mlParams));
00039 LinearOperator<double> P = mlp;
00040 rtn = new GenericRightPreconditioner<double>(P);
00041 }
00042 else if (pType=="Ifpack")
00043 {
00044 ParameterList iluSettings = params_.sublist("Ifpack Settings");
00045 RCP<PreconditionerFactoryBase<double> > pf
00046 = rcp(new ILUKPreconditionerFactory<double>(iluSettings));
00047 rtn = pf->createPreconditioner(A);
00048 }
00049 else
00050 {
00051 TEUCHOS_TEST_FOR_EXCEPTION(true, std::runtime_error,
00052 "preconditioner type=[" << pType << "] not recognized");
00053 }
00054
00055 return rtn;
00056 }