Go to the documentation of this file.00001 #include "Thyra_LOWSFactoryBuilder.hpp"
00002
00003 #ifndef TRILINOS_6
00004
00005 #include "Thyra_DefaultModelEvaluatorWithSolveFactory.hpp"
00006 #include "Thyra_AmesosLinearOpWithSolveFactory.hpp"
00007 #include "Thyra_BelosLinearOpWithSolveFactory.hpp"
00008 #include "Thyra_AztecOOLinearOpWithSolveFactory.hpp"
00009 #include "Thyra_IfpackPreconditionerFactory.hpp"
00010 #include "Thyra_MLPreconditionerFactory.hpp"
00011
00012
00013 #ifndef HAVE_TEUCHOS_EXPLICIT_INSTANTIATION
00014 #include "TSFLinearOperatorImpl.hpp"
00015 #include "TSFLinearSolverImpl.hpp"
00016 #include "TSFLinearCombinationImpl.hpp"
00017 #endif
00018
00019
00020 using namespace Thyra;
00021 using namespace Teuchos;
00022
00023 RCP<LinearOpWithSolveFactoryBase<double> >
00024 LOWSFactoryBuilder::createLOWSFactory(const ParameterList& params)
00025 {
00026
00027
00028
00029
00030
00031
00032
00033 RCP<LinearOpWithSolveFactoryBase<double> > rtn;
00034 RCP<PreconditionerFactoryBase<double> > prec;
00035
00036 if (params.isSublist("Amesos"))
00037 {
00038 RCP<ParameterList> p = rcp(new ParameterList(params.sublist("Amesos")));
00039 rtn = rcp(new AmesosLinearOpWithSolveFactory());
00040 rtn->setParameterList(p);
00041 }
00042 else if (params.isSublist("Aztec"))
00043 {
00044 RCP<ParameterList> p = rcp(new ParameterList(params.sublist("Aztec")));
00045 rtn = rcp(new AztecOOLinearOpWithSolveFactory());
00046 rtn->setParameterList(p);
00047 }
00048 else if (params.isSublist("Belos"))
00049 {
00050 RCP<ParameterList> p = rcp(new ParameterList(params.sublist("Belos")));
00051 rtn = rcp(new BelosLinearOpWithSolveFactory<double>());
00052 rtn->setParameterList(p);
00053 }
00054 else
00055 {
00056 TEST_FOR_EXCEPTION(true, std::runtime_error,
00057 "solver parameter list did not contain one of [Aztec, Amesos, "
00058 "Belos]");
00059 }
00060
00061 if (params.isSublist("Preconditioner"))
00062 {
00063 ParameterList precParams = params.sublist("Preconditioner");
00064 std::string precType = precParams.get<string>("Type");
00065 if (precType=="ML")
00066 {
00067 std::string probType = getParameter<string>(precParams, "Problem Type");
00068 ParameterList mlParams = precParams.sublist("ML Settings");
00069 prec = rcp(new MLPreconditionerFactory(probType, mlParams));
00070 }
00071 else if (precType=="Ifpack")
00072 {
00073 std::string probType = getParameter<string>(precParams, "Prec Type");
00074 RCP<ParameterList> ifpackParams
00075 = rcp(new ParameterList(precParams.sublist("Ifpack")));
00076 prec = rcp(new IfpackPreconditionerFactory());
00077 prec->setParameterList(ifpackParams);
00078 }
00079 else
00080 {
00081 TEST_FOR_EXCEPTION(true, std::runtime_error,
00082 "Preconditioner type [" << precType << "] not recognized");
00083 }
00084 }
00085
00086 TEST_FOR_EXCEPTION(prec.get() != 0 && !rtn->acceptsPreconditionerFactory(),
00087 std::runtime_error,
00088 "Huh? You have provided a preconditioner for a solver that cannot "
00089 "accept a preconditioner!");
00090
00091 if (prec.get() != 0 && rtn->acceptsPreconditionerFactory())
00092 {
00093 rtn->setPreconditionerFactory(prec, "precond");
00094 }
00095
00096
00097 return rtn;
00098
00099 }
00100
00101
00102 #endif