00001 #include "EpetraExt_DiagonalQuadraticResponseOnlyModelEvaluator.hpp"
00002 #include "MoochoPack_MoochoThyraSolver.hpp"
00003 #include "Thyra_EpetraModelEvaluator.hpp"
00004 #include "Teuchos_GlobalMPISession.hpp"
00005 #include "Teuchos_CommandLineProcessor.hpp"
00006 #include "Teuchos_StandardCatchMacros.hpp"
00007 #include "Teuchos_VerboseObject.hpp"
00008 #include "Teuchos_XMLParameterListHelpers.hpp"
00009 #ifdef HAVE_MPI
00010 # include "Epetra_MpiComm.h"
00011 #else
00012 # include "Epetra_SerialComm.h"
00013 #endif
00014
00015
00016 int main( int argc, char* argv[] )
00017 {
00018 using Teuchos::rcp;
00019 using Teuchos::RCP;
00020 using Teuchos::OSTab;
00021 using MoochoPack::MoochoSolver;
00022 using MoochoPack::MoochoThyraSolver;
00023 using Teuchos::CommandLineProcessor;
00024
00025 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
00026
00027 Teuchos::Time timer("");
00028
00029 bool dummySuccess = true;
00030
00031 Teuchos::RCP<Teuchos::FancyOStream>
00032 out = Teuchos::VerboseObjectBase::getDefaultOStream();
00033
00034 try {
00035
00036
00037
00038
00039
00040
00041 MoochoThyraSolver solver;
00042
00043
00044
00045
00046
00047 int localDim = 4;
00048 double pt = 0.0;
00049 double p0 = 0.1;
00050 double scale = 0.1;
00051
00052 CommandLineProcessor clp;
00053 clp.throwExceptions(false);
00054 clp.addOutputSetupOptions(true);
00055
00056 clp.setOption("local-dim", &localDim);
00057 clp.setOption("pt", &pt);
00058 clp.setOption("p0", &p0);
00059 clp.setOption("scale", &scale);
00060
00061 solver.setupCLP(&clp);
00062
00063 CommandLineProcessor::EParseCommandLineReturn
00064 parse_return = clp.parse(argc,argv,&std::cerr);
00065
00066 if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL )
00067 return parse_return;
00068
00069 solver.readParameters( out.get() );
00070
00071 Teuchos::RCP<Epetra_Comm> comm = Teuchos::null;
00072
00073 #ifdef HAVE_MPI
00074 MPI_Comm mpiComm = MPI_COMM_WORLD;
00075 comm = Teuchos::rcp(new Epetra_MpiComm(mpiComm));
00076 #else
00077 comm = Teuchos::rcp(new Epetra_SerialComm());
00078 #endif
00079
00080
00081
00082
00083
00084 *out << "\nCreate EpetraExt::DiagonalQuadraticResponseOnlyModelEvaluator object ...\n";
00085
00086 Teuchos::RCP<EpetraExt::DiagonalQuadraticResponseOnlyModelEvaluator>
00087 epetraModel = EpetraExt::diagonalQuadraticResponseOnlyModelEvaluator(
00088 comm, localDim, pt, p0, scale);
00089
00090 *out << "\nCreate the Thyra::EpetraModelEvaluator wrapper object ...\n";
00091
00092 Teuchos::RCP<Thyra::EpetraModelEvaluator>
00093 epetraThyraModel(new Thyra::EpetraModelEvaluator());
00094 epetraThyraModel->initialize(epetraModel, Teuchos::null);
00095
00096
00097
00098
00099
00100
00101 solver.setModel(epetraThyraModel);
00102
00103
00104 solver.readInitialGuess(out.get());
00105
00106
00107 const MoochoSolver::ESolutionStatus solution_status = solver.solve();
00108
00109
00110 solver.writeFinalSolution(out.get());
00111
00112
00113 solver.writeParamsFile();
00114
00115
00116
00117
00118
00119 if(solution_status == MoochoSolver::SOLVE_RETURN_SOLVED)
00120 *out << "\nEnd Result: TEST PASSED\n";
00121 else
00122 *out << "\nEnd Result: TEST FAILED\n";
00123
00124 return solution_status;
00125
00126 }
00127 TEUCHOS_STANDARD_CATCH_STATEMENTS(true, *out, dummySuccess)
00128
00129 return MoochoSolver::SOLVE_RETURN_EXCEPTION;
00130
00131 }