43 #include "Teuchos_GlobalMPISession.hpp"
44 #include "Teuchos_CommandLineProcessor.hpp"
45 #include "Teuchos_ParameterList.hpp"
46 #include "Teuchos_ParameterXMLFileReader.hpp"
47 #include "Teuchos_RefCountPtr.hpp"
48 #include "Teuchos_Time.hpp"
49 #include "Teuchos_Comm.hpp"
52 #include "Epetra_MpiComm.h"
54 #include "Epetra_SerialComm.h"
57 #include "Epetra_LinearProblem.h"
58 #include "Epetra_CrsMatrix.h"
69 int main(
int argc,
char*argv[])
85 std::string xml_file(
"xml_params.xml");
94 std::cout <<
"Every proc reading parameters from xml_file: "
95 << xml_file << std::endl;
109 int max_iters = solver->GetAllAztecOptions()[AZ_max_iter];
110 double tol = solver->GetAllAztecParams()[AZ_tol];
116 if (solver->GetAllAztecOptions()[AZ_precond] != AZ_user_precond) {
117 err_code = solver->ConstructPreconditioner(cond_est);
120 if (Comm.
MyPID() == 0 && err_code == 0) {
121 std::cout <<
"Time to compute preconditioner: " << prec_time.
totalElapsedTime() <<
"s"<<std::endl;
124 int ret = solver->Iterate(max_iters, tol);
127 solver->DestroyPreconditioner();
130 int actual_iters = (int)solver->GetAztecStatus()[AZ_its];
132 if (Comm.
MyPID() == 0) {
133 std::cout <<
"Converged in " << actual_iters <<
" iterations." << std::endl;
136 if (problem->
GetLHS()->NumVectors() > 1) {
137 throw std::runtime_error(
"ERROR: MultiVector->NumVectors()>1.");
145 r->Update(1.0, *b, -1.0);
149 if (Comm.
MyPID() == 0) {
150 std::cout <<
"2-Norm of residual vec: " << norm << std::endl;
165 int expected_iters = 0;
168 if (ret == 0 && actual_iters <= expected_iters && norm < eps) {
169 if (Comm.
MyPID() == 0) {
170 std::cout <<
"End Result: TEST PASSED" << std::endl;
174 if (Comm.
MyPID() == 0) {
175 std::cout <<
"Actual iters("<<actual_iters
176 <<
") > expected number of iterations ("
177 <<expected_iters<<
"), or resid-norm(" << norm <<
") >= "<<eps <<std::endl;
183 if (Comm.
MyPID() == 0) {
184 std::cout <<
"proc 0 total program time: " << timer.
totalElapsedTime() << std::endl;
193 cmdp.
setOption(
"xml_file", &xml_file,
"XML Parameters file");
195 throw std::runtime_error(
"Error parsing command-line.");
Epetra_MultiVector * GetLHS() const
Epetra_MultiVector * GetRHS() const
ParameterList getParameters() const
bool isParameter(const std::string &name) const
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const =0
void start(bool reset=false)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void setOption(const char option_true[], const char option_false[], bool *option_val, const char documentation[]=NULL)
EParseCommandLineReturn parse(int argc, char *argv[], std::ostream *errout=&std::cerr) const
int main(int argc, char *argv[])
void GetParameter(const Teuchos::ParameterList ¶ms, const std::string &name, T &value)
Set a value from a ParameterList if a parameter with the specified name exists.
double totalElapsedTime(bool readCurrentTime=false) const
void process_command_line(int argc, char *argv[], std::string &xml_file)
Epetra_Operator * GetOperator() const
Teuchos::RCP< Epetra_LinearProblem > build_problem(Teuchos::ParameterList &test_params, const Epetra_Comm &comm)
Teuchos::RCP< AztecOO > build_solver(Teuchos::ParameterList &test_params, Teuchos::RCP< Epetra_LinearProblem > problem)