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 "NOX_Direction_Factory.H"
00043
00044 #include "Teuchos_ParameterList.hpp"
00045 #include "NOX_GlobalData.H"
00046 #include "NOX_Common.H"
00047
00048
00049 #include "NOX_Direction_Newton.H"
00050 #include "NOX_Direction_SteepestDescent.H"
00051 #include "NOX_Direction_NonlinearCG.H"
00052 #include "NOX_Direction_Broyden.H"
00053 #include "NOX_Direction_UserDefinedFactory.H"
00054 #ifdef WITH_PRERELEASE
00055 #include "NOX_Direction_Tensor.H"
00056 #include "NOX_Direction_ModifiedNewton.H"
00057 #include "NOX_Direction_QuasiNewton.H"
00058 #endif
00059
00060
00061
00062
00063 NOX::Direction::Factory::Factory()
00064 { }
00065
00066
00067
00068 NOX::Direction::Factory::~Factory()
00069 { }
00070
00071
00072
00073 Teuchos::RCP<NOX::Direction::Generic> NOX::Direction::Factory::
00074 buildDirection(const Teuchos::RCP<NOX::GlobalData>& gd,
00075 Teuchos::ParameterList& params)
00076 {
00077
00078 Teuchos::RCP<NOX::Direction::Generic> direction;
00079
00080 std::string method = params.get("Method", "Newton");
00081
00082 if (method == "Newton")
00083 direction = Teuchos::rcp(new Newton(gd, params));
00084 else if (method == "Steepest Descent")
00085 direction = Teuchos::rcp(new SteepestDescent(gd, params));
00086 else if (method == "NonlinearCG")
00087 direction = Teuchos::rcp(new NonlinearCG(gd, params));
00088 else if (method == "Broyden")
00089 direction = Teuchos::rcp(new Broyden(gd, params));
00090 #ifdef WITH_PRERELEASE
00091 else if (method == "Tensor")
00092 direction = Teuchos::rcp(new Tensor(gd, params));
00093 else if (method == "Modified-Newton")
00094 direction = Teuchos::rcp(new ModifiedNewton(gd, params));
00095 else if (method == "Quasi-Newton")
00096 direction = Teuchos::rcp(new QuasiNewton(gd, params));
00097 #endif
00098 else if (method == "User Defined") {
00099 using namespace Teuchos;
00100 if (isParameterType< RCP<NOX::Direction::UserDefinedFactory> >
00101 (params, "User Defined Direction Factory")) {
00102
00103 RCP<NOX::Direction::UserDefinedFactory> user_factory =
00104 getParameter< Teuchos::RCP<NOX::Direction::UserDefinedFactory> >
00105 (params, "User Defined Direction Factory");
00106
00107 direction = user_factory->buildDirection(gd, params);
00108 }
00109 else {
00110 std::string msg = "Error - NOX::Direction::Factory::buildDirection() - a \"User Defined\" direction was chosen for the \"Method\" in the \"Direction\" sublist, but a Teuchos::RCP<NOX::Direction::UserDefinedFactory> object was not found in the parameter list!";
00111 TEST_FOR_EXCEPTION(true, std::logic_error, msg);
00112 }
00113 }
00114 else {
00115 std::string msg = "Error - NOX::Direction::Facotry::buildDirection() - Invalid choice for \"Method\" in \"Direction\" sublist!";
00116 TEST_FOR_EXCEPTION(true, std::logic_error, msg);
00117 }
00118
00119 return direction;
00120 }
00121
00122
00123
00124
00125 Teuchos::RCP<NOX::Direction::Generic> NOX::Direction::
00126 buildDirection(const Teuchos::RCP<NOX::GlobalData>& gd,
00127 Teuchos::ParameterList& params)
00128 {
00129 NOX::Direction::Factory factory;
00130 return factory.buildDirection(gd, params);
00131 }
00132
00133
00134