#include "Didasko_ConfigDefs.h"
#if defined(HAVE_DIDASKO_EPETRA) && defined(HAVE_DIDASKO_AMESOS) && defined(HAVE_DIDASKO_TEUCHOS) && defined(HAVE_DIDASKO_TRIUTILS)
#include "Epetra_ConfigDefs.h"
#include "Amesos_ConfigDefs.h"
#ifdef HAVE_MPI
#include "mpi.h"
#include "Epetra_MpiComm.h"
#else
#include "Epetra_SerialComm.h"
#endif
#include "Amesos.h"
#include "Trilinos_Util_CrsMatrixGallery.h"
using namespace Trilinos_Util;
int main(int argc, char *argv[]) {
#ifdef HAVE_MPI
MPI_Init(&argc, &argv);
#else
#endif
CrsMatrixGallery Gallery("laplace_2d", Comm, false);
Gallery.Set("problem_size", 100);
Amesos_BaseSolver* Solver;
Amesos Amesos_Factory;
Teuchos::ParameterList List;
string SolverType = "Amesos_Klu";
Solver = Amesos_Factory.Create(SolverType, *Problem);
assert (Solver);
Solver->SymbolicFactorization();
Solver->NumericFactorization();
Solver->Solve();
double residual, diff;
Gallery.ComputeResidual(&residual);
Gallery.ComputeDiffBetweenStartingAndExactSolutions(&diff);
if( Comm.
MyPID() == 0 ) {
cout << "||b-Ax||_2 = " << residual << endl;
cout << "||x_exact - x||_2 = " << diff << endl;
}
delete Solver;
if (residual > 1e-5)
exit(EXIT_FAILURE);
#ifdef HAVE_MPI
MPI_Finalize();
#endif
exit(EXIT_SUCCESS);
}
#else
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
puts("Please configure Didasko with:\n"
"--enable-epetra\n"
"--enable-teuchos\n"
"--enable-triutils\n"
"--enable-amesos");
return 0;
}
#endif