build_solver.cpp

Go to the documentation of this file.
00001 #ifndef _build_solver_hpp_
00002 #define _build_solver_hpp_
00003 
00004 #include "Teuchos_RefCountPtr.hpp"
00005 #include "Teuchos_ParameterList.hpp"
00006 #include "Teuchos_Time.hpp"
00007 #include "Epetra_LinearProblem.h"
00008 #include "Epetra_Map.h"
00009 #include "Epetra_Comm.h"
00010 #include "AztecOO.h"
00011 #include "Ifpack.h"
00012 
00013 #include "ParameterHelper.hpp"
00014 
00015 Teuchos::RCP<AztecOO>
00016 build_solver(Teuchos::ParameterList& test_params,
00017              Teuchos::RCP<Epetra_LinearProblem> problem)
00018 {
00019   Teuchos::ParameterList azparams;
00020   if (test_params.isSublist("AztecOO")) {
00021     azparams = test_params.sublist("AztecOO");
00022   }
00023 
00024   Teuchos::RCP<AztecOO> solver = Teuchos::rcp(new AztecOO);
00025 
00026   solver->SetProblem(*problem);
00027 
00028   solver->SetParameters(azparams);
00029 
00030   std::string ifpack_precond("not specified");
00031   helper::GetParameter(test_params, "Ifpack_Preconditioner", ifpack_precond);
00032   if (ifpack_precond != "not specified") {
00033     Ifpack factory;
00034     Ifpack_Preconditioner* precond = factory.Create(ifpack_precond, problem->GetMatrix());
00035 
00036     if (test_params.isSublist("Ifpack")) {
00037       Teuchos::ParameterList& ifparams = test_params.sublist("Ifpack");
00038       precond->SetParameters(ifparams);
00039     }
00040     Teuchos::Time prec_time("precond");
00041     prec_time.start();
00042     precond->Initialize();
00043     precond->Compute();
00044     prec_time.stop();
00045     int my_proc = problem->GetMatrix()->RowMatrixRowMap().Comm().MyPID();
00046     if (my_proc == 0) {
00047       std::cout << "Time to initialize/compute preconditioner: " << prec_time.totalElapsedTime() << "s" << std::endl;
00048     }
00049     
00050     solver->SetPrecOperator(precond);
00051   }
00052 
00053   return solver;
00054 }
00055 #endif
00056 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Wed Apr 13 10:05:33 2011 for Ifpack Package Browser (Single Doxygen Collection) by  doxygen 1.6.3