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
00044 #include "NOX_Common.H"
00045
00046 #include "LOCA_Epetra_TransposeLinearSystem_Factory.H"
00047 #include "LOCA_Epetra_TransposeLinearSystem_AbstractStrategy.H"
00048 #include "LOCA_Epetra_TransposeLinearSystem_TransposePreconditioner.H"
00049 #ifdef HAVE_NOX_EPETRAEXT
00050 #include "LOCA_Epetra_TransposeLinearSystem_ExplicitTranspose.H"
00051 #endif
00052 #include "LOCA_Epetra_TransposeLinearSystem_LeftPreconditioning.H"
00053 #include "LOCA_GlobalData.H"
00054 #include "LOCA_ErrorCheck.H"
00055
00056 LOCA::Epetra::TransposeLinearSystem::Factory::Factory(
00057 const Teuchos::RCP<LOCA::GlobalData>& global_data) :
00058 globalData(global_data)
00059 {
00060 }
00061
00062 LOCA::Epetra::TransposeLinearSystem::Factory::~Factory()
00063 {
00064 }
00065
00066 Teuchos::RCP<LOCA::Epetra::TransposeLinearSystem::AbstractStrategy>
00067 LOCA::Epetra::TransposeLinearSystem::Factory::create(
00068 const Teuchos::RCP<Teuchos::ParameterList>& solverParams,
00069 const Teuchos::RCP<NOX::Epetra::LinearSystem>& linsys)
00070 {
00071 string methodName = "LOCA::Epetra::TransposeLinearSystem::Factory::create()";
00072 Teuchos::RCP<LOCA::Epetra::TransposeLinearSystem::AbstractStrategy> strategy;
00073
00074
00075 const string& name = strategyName(*solverParams);
00076
00077 if (name == "Transpose Preconditioner")
00078 strategy =
00079 Teuchos::rcp(new LOCA::Epetra::TransposeLinearSystem::TransposePreconditioner(globalData, solverParams, linsys));
00080
00081 #ifdef HAVE_NOX_EPETRAEXT
00082 else if (name == "Explicit Transpose") {
00083 strategy =
00084 Teuchos::rcp(new LOCA::Epetra::TransposeLinearSystem::ExplicitTranspose(globalData, solverParams, linsys));
00085 }
00086 #endif
00087
00088 else if (name == "Left Preconditioning") {
00089 strategy =
00090 Teuchos::rcp(new LOCA::Epetra::TransposeLinearSystem::LeftPreconditioning(globalData, solverParams, linsys));
00091 }
00092
00093 else if (name == "User-Defined") {
00094
00095
00096 string userDefinedName = solverParams->get("User-Defined Name",
00097 "???");
00098 if ((*solverParams).INVALID_TEMPLATE_QUALIFIER
00099 isType< Teuchos::RCP<LOCA::Epetra::TransposeLinearSystem::AbstractStrategy> >(userDefinedName))
00100 strategy = (*solverParams).INVALID_TEMPLATE_QUALIFIER
00101 get< Teuchos::RCP<LOCA::Epetra::TransposeLinearSystem::AbstractStrategy> >(userDefinedName);
00102 else
00103 globalData->locaErrorCheck->throwError(
00104 methodName,
00105 "Cannot find user-defined strategy: " +
00106 userDefinedName);
00107 }
00108 else
00109 globalData->locaErrorCheck->throwError(
00110 methodName,
00111 "Invalid bordered solver strategy: " +
00112 name);
00113
00114 return strategy;
00115 }
00116
00117 const string&
00118 LOCA::Epetra::TransposeLinearSystem::Factory::strategyName(
00119 Teuchos::ParameterList& solverParams) const
00120 {
00121 return solverParams.get("Transpose Solver Method",
00122 "Transpose Preconditioner");
00123 }