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_Eigensolver_Factory.H"
00047 #include "LOCA_Eigensolver_AbstractStrategy.H"
00048 #include "LOCA_Eigensolver_DefaultStrategy.H"
00049 #ifdef HAVE_LOCA_ANASAZI
00050 #include "LOCA_Eigensolver_AnasaziStrategy.H"
00051 #endif
00052
00053 LOCA::Eigensolver::Factory::Factory(
00054 const Teuchos::RCP<LOCA::GlobalData>& global_data) :
00055 globalData(global_data)
00056 {
00057 }
00058
00059 LOCA::Eigensolver::Factory::~Factory()
00060 {
00061 }
00062
00063 Teuchos::RCP<LOCA::Eigensolver::AbstractStrategy>
00064 LOCA::Eigensolver::Factory::create(
00065 const Teuchos::RCP<LOCA::Parameter::SublistParser>& topParams,
00066 const Teuchos::RCP<Teuchos::ParameterList>& eigenParams)
00067 {
00068 string methodName = "LOCA::Eigensolver::Factory::create()";
00069 Teuchos::RCP<LOCA::Eigensolver::AbstractStrategy> strategy;
00070
00071
00072 const string& name = strategyName(*eigenParams);
00073
00074 if (name == "Default")
00075 strategy =
00076 Teuchos::rcp(new LOCA::Eigensolver::DefaultStrategy(globalData,
00077 topParams,
00078 eigenParams));
00079 else if (name == "Anasazi") {
00080 #ifdef HAVE_LOCA_ANASAZI
00081 strategy =
00082 Teuchos::rcp(new LOCA::Eigensolver::AnasaziStrategy(globalData,
00083 topParams,
00084 eigenParams));
00085 #else
00086 globalData->locaErrorCheck->throwError(methodName,
00087 "Anasazi strategy requested, but LOCA was not configured with Anasazi support enabled.");
00088 #endif
00089 }
00090 else if (name == "User-Defined") {
00091
00092
00093 string userDefinedName = eigenParams->get("User-Defined Name",
00094 "???");
00095 if ((*eigenParams).INVALID_TEMPLATE_QUALIFIER
00096 isType< Teuchos::RCP<LOCA::Eigensolver::AbstractStrategy> >(userDefinedName))
00097 strategy = (*eigenParams).INVALID_TEMPLATE_QUALIFIER
00098 get< Teuchos::RCP<LOCA::Eigensolver::AbstractStrategy> >(userDefinedName);
00099 else
00100 globalData->locaErrorCheck->throwError(
00101 methodName,
00102 "Cannot find user-defined strategy: " +
00103 userDefinedName);
00104 }
00105 else
00106 globalData->locaErrorCheck->throwError(
00107 methodName,
00108 "Invalid eigensolver strategy: " +
00109 name);
00110
00111 return strategy;
00112 }
00113
00114 const string&
00115 LOCA::Eigensolver::Factory::strategyName(
00116 Teuchos::ParameterList& eigenParams) const
00117 {
00118 return eigenParams.get("Method", "Default");
00119 }