00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include "Teuchos_ParameterList.hpp"
00043 #include "LOCA_GlobalData.H"
00044 #include "LOCA_ErrorCheck.H"
00045
00046 #include "LOCA_BorderedSolver_Factory.H"
00047 #include "LOCA_BorderedSolver_AbstractStrategy.H"
00048 #include "LOCA_BorderedSolver_Bordering.H"
00049 #include "LOCA_BorderedSolver_Nested.H"
00050
00051 LOCA::BorderedSolver::Factory::Factory(
00052 const Teuchos::RCP<LOCA::GlobalData>& global_data) :
00053 globalData(global_data)
00054 {
00055 }
00056
00057 LOCA::BorderedSolver::Factory::~Factory()
00058 {
00059 }
00060
00061 Teuchos::RCP<LOCA::BorderedSolver::AbstractStrategy>
00062 LOCA::BorderedSolver::Factory::create(
00063 const Teuchos::RCP<LOCA::Parameter::SublistParser>& topParams,
00064 const Teuchos::RCP<Teuchos::ParameterList>& solverParams)
00065 {
00066 string methodName = "LOCA::BorderedSolver::Factory::create()";
00067 Teuchos::RCP<LOCA::BorderedSolver::AbstractStrategy> strategy;
00068
00069
00070 const string& name = strategyName(*solverParams);
00071
00072 if (name == "Bordering")
00073 strategy =
00074 Teuchos::rcp(new LOCA::BorderedSolver::Bordering(globalData,
00075 topParams,
00076 solverParams));
00077
00078 else if (name == "Nested")
00079 strategy =
00080 Teuchos::rcp(new LOCA::BorderedSolver::Nested(globalData,
00081 topParams,
00082 solverParams));
00083 else if (name == "User-Defined") {
00084
00085
00086 string userDefinedName = solverParams->get("User-Defined Name",
00087 "???");
00088 if ((*solverParams).INVALID_TEMPLATE_QUALIFIER
00089 isType< Teuchos::RCP<LOCA::BorderedSolver::AbstractStrategy> >(userDefinedName))
00090 strategy = (*solverParams).INVALID_TEMPLATE_QUALIFIER
00091 get< Teuchos::RCP<LOCA::BorderedSolver::AbstractStrategy> >(userDefinedName);
00092 else
00093 globalData->locaErrorCheck->throwError(
00094 methodName,
00095 "Cannot find user-defined strategy: " +
00096 userDefinedName);
00097 }
00098 else
00099 globalData->locaErrorCheck->throwError(
00100 methodName,
00101 "Invalid bordered solver strategy: " +
00102 name);
00103
00104 return strategy;
00105 }
00106
00107 const string&
00108 LOCA::BorderedSolver::Factory::strategyName(
00109 Teuchos::ParameterList& solverParams) const
00110 {
00111 return solverParams.get("Bordered Solver Method", "Bordering");
00112 }