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"
68 int main(
int argc,
char*argv[])
84 std::string xml_file(
"xml_params.xml");
93 std::cout <<
"Every proc reading parameters from xml_file: "
94 << xml_file << std::endl;
108 int max_iters = solver->GetAllAztecOptions()[AZ_max_iter];
109 double tol = solver->GetAllAztecParams()[AZ_tol];
115 if (solver->GetAllAztecOptions()[AZ_precond] != AZ_user_precond) {
116 err_code = solver->ConstructPreconditioner(cond_est);
119 if (Comm.
MyPID() == 0 && err_code == 0) {
120 std::cout <<
"Time to compute preconditioner: " << prec_time.
totalElapsedTime() <<
"s"<<std::endl;
123 int ret = solver->Iterate(max_iters, tol);
126 solver->DestroyPreconditioner();
129 int actual_iters = (int)solver->GetAztecStatus()[AZ_its];
131 if (Comm.
MyPID() == 0) {
132 std::cout <<
"Converged in " << actual_iters <<
" iterations." << std::endl;
135 if (problem->
GetLHS()->NumVectors() > 1) {
136 throw std::runtime_error(
"ERROR: MultiVector->NumVectors()>1.");
144 r->Update(1.0, *b, -1.0);
148 if (Comm.
MyPID() == 0) {
149 std::cout <<
"2-Norm of residual vec: " << norm << std::endl;
164 int expected_iters = 0;
167 if (ret == 0 && actual_iters <= expected_iters && norm < eps) {
168 if (Comm.
MyPID() == 0) {
169 std::cout <<
"End Result: TEST PASSED" << std::endl;
173 if (Comm.
MyPID() == 0) {
174 std::cout <<
"Actual iters("<<actual_iters
175 <<
") > expected number of iterations ("
176 <<expected_iters<<
"), or resid-norm(" << norm <<
") >= "<<eps <<std::endl;
182 if (Comm.
MyPID() == 0) {
183 std::cout <<
"proc 0 total program time: " << timer.
totalElapsedTime() << std::endl;
192 cmdp.setOption(
"xml_file", &xml_file,
"XML Parameters file");
194 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)
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)