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_StepSize_Factory.H"
00047 #include "LOCA_StepSize_AbstractStrategy.H"
00048 #include "LOCA_StepSize_Constant.H"
00049 #include "LOCA_StepSize_Adaptive.H"
00050
00051 LOCA::StepSize::Factory::Factory(
00052 const Teuchos::RCP<LOCA::GlobalData>& global_data) :
00053 globalData(global_data)
00054 {
00055 }
00056
00057 LOCA::StepSize::Factory::~Factory()
00058 {
00059 }
00060
00061 Teuchos::RCP<LOCA::StepSize::AbstractStrategy>
00062 LOCA::StepSize::Factory::create(
00063 const Teuchos::RCP<LOCA::Parameter::SublistParser>& topParams,
00064 const Teuchos::RCP<Teuchos::ParameterList>& stepsizeParams)
00065 {
00066 string methodName = "LOCA::StepSize::Factory::create()";
00067 Teuchos::RCP<LOCA::StepSize::AbstractStrategy> strategy;
00068
00069
00070 const string& name = strategyName(*stepsizeParams);
00071
00072 if (name == "Constant")
00073 strategy =
00074 Teuchos::rcp(new LOCA::StepSize::Constant(globalData,
00075 topParams,
00076 stepsizeParams));
00077 else if (name == "Adaptive")
00078 strategy =
00079 Teuchos::rcp(new LOCA::StepSize::Adaptive(globalData,
00080 topParams,
00081 stepsizeParams));
00082 else if (name == "User-Defined") {
00083
00084
00085 string userDefinedName = stepsizeParams->get("User-Defined Name",
00086 "???");
00087 if ((*stepsizeParams).INVALID_TEMPLATE_QUALIFIER
00088 isType< Teuchos::RCP<LOCA::StepSize::AbstractStrategy> >(userDefinedName))
00089 strategy = (*stepsizeParams).INVALID_TEMPLATE_QUALIFIER
00090 get< Teuchos::RCP<LOCA::StepSize::AbstractStrategy> >(userDefinedName);
00091 else
00092 globalData->locaErrorCheck->throwError(
00093 methodName,
00094 "Cannot find user-defined strategy: " +
00095 userDefinedName);
00096 }
00097 else
00098 globalData->locaErrorCheck->throwError(
00099 methodName,
00100 "Invalid step size control strategy: " +
00101 name);
00102
00103 return strategy;
00104 }
00105
00106 const string&
00107 LOCA::StepSize::Factory::strategyName(
00108 Teuchos::ParameterList& stepsizeParams) const
00109 {
00110 return stepsizeParams.get("Method", "Adaptive");
00111 }