#include "Didasko_ConfigDefs.h"
#if defined(HAVE_DIDASKO_EPETRA) && defined(HAVE_DIDASKO_IFPACK) && defined(HAVE_DIDASKO_AZTECOO)
#include "Epetra_ConfigDefs.h"
#ifdef HAVE_MPI
#include "mpi.h"
#include "Epetra_MpiComm.h"
#else
#include "Epetra_SerialComm.h"
#endif
#include "Epetra_Comm.h"
#include "Epetra_Map.h"
#include "Epetra_Time.h"
#include "Epetra_BlockMap.h"
#include "Epetra_MultiVector.h"
#include "Epetra_Vector.h"
#include "Epetra_Export.h"
#include "AztecOO.h"
#include "Trilinos_Util.h"
#include "Epetra_VbrMatrix.h"
#include "Epetra_CrsMatrix.h"
#include "Ifpack_CrsIct.h"
string toString(const int& x) {
char s[100];
sprintf(s, "%d", x);
return string(s);
}
string toString(const double& x) {
char s[100];
sprintf(s, "%g", x);
return string(s);
}
int main(int argc, char *argv[]) {
#ifdef HAVE_MPI
MPI_Init(&argc,&argv);
#else
#endif
int MyPID = Comm.
MyPID();
bool verbose = false;
if (MyPID==0) verbose = true;
char FileName[] = "../HBMatrices/fidap005.rua";
Trilinos_Util_ReadHb2Epetra(FileName, Comm, readMap, readA, readx,
readb, readxexact);
A.Export(*readA, exporter, Add);
x.Export(*readx, exporter, Add);
b.Export(*readb, exporter, Add);
xexact.Export(*readxexact, exporter, Add);
A.FillComplete();
delete readA;
delete readx;
delete readb;
delete readxexact;
delete readMap;
int LevelFill = 1;
double DropTol = 0.0;
double Condest;
Ifpack_CrsIct * ICT = NULL;
ICT = new Ifpack_CrsIct(A,DropTol,LevelFill);
ICT->InitValues(A);
ICT->Factor();
ICT->Condest(false,Condest);
cout << Condest << endl;
if( Comm.
MyPID() == 0 ) {
cout << "Condition number estimate (level-of-fill = "
<< LevelFill << ") = " << Condest << endl;
}
string label = "Ifpack_CrsIct Preconditioner: LevelFill = " + toString(LevelFill) +
" Overlap = 0";
ICT->SetLabel(label.c_str());
AztecOO solver;
solver.SetUserMatrix(&A);
solver.SetLHS(&x);
solver.SetRHS(&b);
solver.SetAztecOption(AZ_solver,AZ_cg);
solver.SetPrecOperator(ICT);
int Niters = 1200;
solver.SetAztecOption(AZ_kspace, Niters);
solver.SetAztecOption(AZ_output, 20);
solver.Iterate(Niters, 5.0e-5);
if (ICT!=0) delete ICT;
#ifdef HAVE_MPI
MPI_Finalize() ;
#endif
return 0 ;
}
#else
#include <stdlib.h>
#include <stdio.h>
#ifdef HAVE_MPI
#include "mpi.h"
#endif
int main(int argc, char *argv[])
{
#ifdef HAVE_MPI
MPI_Init(&argc,&argv);
#endif
puts("Please configure Didasko with:");
puts("--enable-epetra");
puts("--enable-ifpack");
puts("--enable-aztecoo");
#ifdef HAVE_MPI
MPI_Finalize();
#endif
return 0;
}
#endif