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

Site Contact