#include "MoochoPack_MoochoThyraSolver.hpp"
#include "Thyra_EpetraModelEvaluator.hpp"
#include "Thyra_DefaultSpmdMultiVectorFileIO.hpp"
#include "Stratimikos_DefaultLinearSolverBuilder.hpp"
#include "Teuchos_GlobalMPISession.hpp"
#include "Teuchos_CommandLineProcessor.hpp"
#include "Teuchos_StandardCatchMacros.hpp"
#include "Teuchos_VerboseObject.hpp"
#include "Teuchos_XMLParameterListHelpers.hpp"
#ifdef HAVE_MPI
# include "Epetra_MpiComm.h"
#else
# include "Epetra_SerialComm.h"
#endif
namespace {
typedef AbstractLinAlgPack::value_type Scalar;
}
int main( int argc, char* argv[] )
{
const int numProcs = mpiSession.getNProc();
bool dummySuccess = true;
try {
MoochoThyraSolver solver;
std::string matchingVecFile = "";
bool showMoochoThyraParams = false;
bool showMoochoThyraParamsWithDoc = true;
bool showMoochoThyraParamsXML = false;
CommandLineProcessor clp;
clp.throwExceptions(false);
clp.addOutputSetupOptions(true);
solver.setupCLP(&clp);
clp.setOption(
"q-vec-file", &matchingVecFile
,"Base file name to read the objective state matching "
"vector q (i.e. ||x-q||_M in the objective)."
);
clp.setOption(
"only-print-moocho-thyra-solver-params", "no-print-moocho-thyra-solver-params"
,&showMoochoThyraParams
,"Only print the parameters accepted by MoochoPack::MoochoThyraSolver and stop."
);
clp.setOption(
"show-doc", "hide-doc", &showMoochoThyraParamsWithDoc
,"Show MoochoPack::MocohoThyraSolver parameters with documentation or not."
);
clp.setOption(
"xml-format", "readable-format", &showMoochoThyraParamsXML
,"Show MoochoPack::MoochoThyraSolver parameters in XML or human-readable format."
);
CommandLineProcessor::EParseCommandLineReturn
parse_return = clp.parse(argc,argv,&std::cerr);
if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL )
return parse_return;
solver.readParameters( !showMoochoThyraParams ? out.
get() : NULL );
if(showMoochoThyraParams) {
if(showMoochoThyraParamsXML)
Teuchos::writeParameterListToXmlOStream(
*solver.getValidParameters()
,*out
);
else
solver.getValidParameters()->print(
*out,PLPrintOptions().indent(2).showTypes(true).showDoc(showMoochoThyraParamsWithDoc)
);
return 0;
}
solver.getSolver().generate_output_file("MoochoJournal")
," "
)
);
*out
<< "\n***"
<< "\n*** NLPThyraEpetraAdvDiffReactOptMain, Global numProcs = "<<numProcs
<< "\n***\n";
#ifdef HAVE_MPI
MPI_Comm mpiComm = MPI_COMM_WORLD;
#endif
#ifdef HAVE_MPI
#else
#endif
*out << "\nCreate the GLpApp::AdvDiffReactOptModel wrapper object ...\n";
epetraModel = advDiffReacModelCreator.
createModel(comm);
epetraModel->setOStream(journalOut);
*out << "\nCreate the Thyra::LinearOpWithSolveFactory object ...\n";
*out << "\nCreate the Thyra::EpetraModelEvaluator wrapper object ...\n";
epetraThyraModel->setOStream(journalOut);
epetraThyraModel->
initialize(epetraModel,lowsFactory);
*out
<<
"\nnp = " << epetraThyraModel->
get_p_space(0)->dim() <<
"\n";
if(matchingVecFile != "") {
*out << "\nReading the matching vector \'q\' from the file(s) with base name \""<<matchingVecFile<<"\" ...\n";
,readVectorFromFile(fileIO,matchingVecFile,*epetraThyraModel->
get_x_space())
)
);
}
solver.getSolver().set_journal_out(journalOut);
solver.setModel(epetraThyraModel);
solver.readInitialGuess(out.
get());
const MoochoSolver::ESolutionStatus solution_status = solver.solve();
solver.writeFinalSolution(out.
get());
solver.writeParamsFile();
if(solution_status == MoochoSolver::SOLVE_RETURN_SOLVED)
*out << "\nEnd Result: TEST PASSED\n";
else
*out << "\nEnd Result: TEST FAILED\n";
return solution_status;
}
return MoochoSolver::SOLVE_RETURN_EXCEPTION;
}