#include "Epetra_CrsMatrix.h"
#include "Epetra_LinearProblem.h"
#include "Epetra_InvOperator.h"
#include "BelosEpetraOperator.h"
#include "BelosEpetraAdapter.hpp"
#include "Ifpack.h"
#include "ModeLaplace2DQ2.h"
#ifdef EPETRA_MPI
#include "Epetra_MpiComm.h"
#else
#include "Epetra_SerialComm.h"
#endif
#include "Epetra_Map.h"
int main(int argc, char *argv[]) {
using std::cout;
using std::endl;
int i;
#ifdef EPETRA_MPI
MPI_Init(&argc,&argv);
#else
#endif
int MyPID = Comm.
MyPID();
int space_dim = 2;
std::vector<double> brick_dim( space_dim );
brick_dim[0] = 1.0;
brick_dim[1] = 1.0;
std::vector<int> elements( space_dim );
elements[0] = 10;
elements[1] = 10;
Ifpack Factory;
std::string PrecType = "ICT";
int OverlapLevel = 0;
assert(Prec != Teuchos::null);
ifpackList.
set(
"fact: drop tolerance", 1e-4);
ifpackList.
set(
"fact: ict level-of-fill", 0.);
ifpackList.
set(
"schwarz: combine mode",
"Add");
IFPACK_CHK_ERR(Prec->SetParameters(ifpackList));
IFPACK_CHK_ERR(Prec->Initialize());
IFPACK_CHK_ERR(Prec->Compute());
int blockSize = 3;
My_LP =
Teuchos::rcp(
new Belos::LinearProblem<double,Epetra_MultiVector,Epetra_Operator>() );
My_LP->setOperator( K );
My_LP->setLeftPrec( belosPrec );
My_List->
set(
"Solver",
"BlockCG" );
My_List->
set(
"Maximum Iterations", maxits );
My_List->
set(
"Block Size", 1 );
My_List->
set(
"Convergence Tolerance", 1e-12 );
double tol = 1.0e-8;
int nev = 10;
int numBlocks = 3*nev/blockSize;
int maxRestarts = 5;
std::string which = "LM";
MyPL.
set(
"Verbosity", verbosity );
MyPL.
set(
"Which", which );
MyPL.
set(
"Block Size", blockSize );
MyPL.
set(
"Num Blocks", numBlocks );
MyPL.
set(
"Maximum Restarts", maxRestarts );
MyPL.
set(
"Convergence Tolerance", tol );
MVT::MvRandom( *ivec );
MyProblem->setHermitian(true);
MyProblem->setNEV( nev );
bool boolret = MyProblem->setProblem();
if (boolret != true) {
if (MyPID == 0) {
cout << "Anasazi::BasicEigenproblem::setProblem() returned with error." << endl;
}
#ifdef HAVE_MPI
MPI_Finalize() ;
#endif
return -1;
}
cout << "Anasazi::EigensolverMgr::solve() returned unconverged." << endl;
}
std::vector<Anasazi::Value<double> > evals = sol.
Evals;
if (numev > 0) {
OPT::Apply( *K, *evecs, tempvec );
MVT::MvTransMv( 1.0, tempvec, *evecs, dmatr );
if (MyPID==0) {
double compeval = 0.0;
cout.setf(std::ios_base::right, std::ios_base::adjustfield);
cout<<"Actual Eigenvalues (obtained by Rayleigh quotient) : "<<endl;
cout<<"------------------------------------------------------"<<endl;
cout<<std::setw(16)<<"Real Part"
<<std::setw(16)<<"Rayleigh Error"<<endl;
cout<<"------------------------------------------------------"<<endl;
for (i=0; i<numev; i++) {
compeval = dmatr(i,i);
cout<<std::setw(16)<<compeval
<<endl;
}
cout<<"------------------------------------------------------"<<endl;
}
}
#ifdef EPETRA_MPI
MPI_Finalize();
#endif
return 0;
}