#include "ml_config.h"
#include "ml_common.h"
#ifdef HAVE_ML_MLAPI
#include "EpetraExt_CrsMatrixIn.h"
#include "EpetraExt_VectorIn.h"
#include "Epetra_Vector.h"
using namespace Teuchos;
using namespace MLAPI;
int main(int argc, char *argv[])
{
#ifdef HAVE_MPI
MPI_Init(&argc,&argv);
#endif
std::string matrixFile; clp.
setOption(
"matrix", &matrixFile,
"Matrix to solve");
std::string rhsFile; clp.
setOption(
"rhs", &rhsFile,
"RHS to solve");
int AdditionalCandidates=1; clp.
setOption(
"numvecs",&AdditionalCandidates,
"Number of additional adaptive candidate vectors");
int NumPDEs=1; clp.
setOption(
"numpdes",&NumPDEs,
"Number of PDE equations");
switch (clp.
parse(argc, argv)) {
}
try {
if(!matrixFile.empty()) {
EpetraExt::MatrixMarketFileToCrsMatrix(matrixFile.c_str(),
GetEpetra_Comm(),temp);
if(!rhsFile.empty()) {
EpetraExt::MatrixMarketFileToVector(rhsFile.c_str(),temp->
RowMap(),tempV);
}
}
else {
int NX = 1000;
{
for (int i = 0 ; i < NX ; ++i)
{
(*Atemp)(2*i, 2*i) = 2.0;
(*Atemp)(2*i+1, 2*i+1) = 2.0;
if (i)
{
(*Atemp)(2*i, 2*(i - 1)) = - 1.0;
(*Atemp)(2*i+1, 2*(i - 1)+1) = - 1.0;
}
if (i != NX - 1)
{
(*Atemp)(2*i, 2*(i + 1)) = - 1.0;
(*Atemp)(2*i+1, 2*(i + 1)+1) = - 1.0;
}
}
}
Atemp->FillComplete();
}
int MaxLevels = 10;
List.
set(
"additional candidates", AdditionalCandidates);
List.
set(
"PDE equations",NumPDEs);
List.
set(
"use default null space",
true);
List.
set(
"krylov: type",
"cg");
bool UseDefaultNullSpace = true;
Prec->
AdaptCompute(UseDefaultNullSpace, AdditionalCandidates);
for(int i=0; i<rhsE->MyLength(); i++)
RHS(i,0) = (*rhsE)[i];
LHS = 0.0;
}
else {
RHS = 0.0;
}
Krylov(*A, LHS, RHS, *Prec, List);
}
catch (const int e) {
std::cerr << "Caught integer exception, code = " << e << std::endl;
}
catch (...) {
std::cerr << "Caught exception..." << std::endl;
}
#ifdef HAVE_MPI
MPI_Finalize() ;
#endif
return(0);
}
#else
#include "ml_include.h"
int main(int argc, char *argv[])
{
#ifdef HAVE_MPI
MPI_Init(&argc,&argv);
#endif
puts("This MLAPI example requires the following configuration options:");
puts("\t--enable-epetra");
puts("\t--enable-teuchos");
puts("\t--enable-ifpack");
puts("\t--enable-amesos");
puts("Please check your configure line.");
#ifdef HAVE_MPI
MPI_Finalize();
#endif
return(0);
}
#endif // #if defined(HAVE_ML_MLAPI)