68 int main(
int argc,
char *argv[])
72 MPI_Init(&argc, &argv);
78 int NumGlobalElements = 100;
110 for (
int i = 0; i < NumMyElements; i++)
112 if (MyGlobalElements[i] == 0)
118 else if (MyGlobalElements[i] == NumGlobalElements-1)
120 Indices[0] = NumGlobalElements-1;
121 Indices[1] = NumGlobalElements-2;
126 Indices[0] = MyGlobalElements[i]-1;
127 Indices[1] = MyGlobalElements[i];
128 Indices[2] = MyGlobalElements[i]+1;
133 NumEntries, Values, Indices));
163 Solver = Factory.
Create(
"Amesos_Klu", Problem);
169 std::cerr <<
"Selected solver is not available" << std::endl;
185 for (
int i = 0; i < NumMyElements; i++)
187 if (MyGlobalElements[i] == 0)
195 else if (MyGlobalElements[i] == NumGlobalElements-1)
197 Indices[0] = NumGlobalElements - 1;
198 Indices[1] = NumGlobalElements - 2;
205 Indices[0] = MyGlobalElements[i] - 1;
206 Indices[1] = MyGlobalElements[i];
207 Indices[2] = MyGlobalElements[i] + 1;
215 NumEntries, Values, Indices));
239 double sfact_time, nfact_time, solve_time;
240 double mtx_conv_time, mtx_redist_time, vec_redist_time;
244 sfact_time = TimingsList.
get(
"Total symbolic factorization time", 0.0 );
248 nfact_time = Teuchos::getParameter<double>( TimingsList,
"Total numeric factorization time" );
252 solve_time = Teuchos::getParameter<double>( TimingsList,
"Total solve time" );
256 mtx_conv_time = Teuchos::getParameter<double>( TimingsList,
"Total solve time" );
259 mtx_redist_time = TimingsList.get(
"Total matrix redistribution time", 0.0 );
262 vec_redist_time = TimingsList.get(
"Total vector redistribution time", 0.0 );
264 std::cout <<
" sfact_time " << sfact_time
265 <<
" nfact_time " << nfact_time
266 <<
" solve_time " << solve_time
267 <<
" mtx_conv_time " << mtx_conv_time
268 <<
" mtx_redist_time " << mtx_redist_time
269 <<
" vec_redist_time " << vec_redist_time
284 Ax.Update(1.0, b, -1.0);
288 std::cout <<
"After AMESOS solution, ||b-Ax||_2 = " << residual << std::endl;
295 return(EXIT_FAILURE);
300 return(EXIT_SUCCESS);
void SetLHS(Epetra_MultiVector *X)
void SetOperator(Epetra_RowMatrix *A)
virtual int Solve()=0
Solves A X = B (or AT x = B)
int Multiply(bool TransA, const Epetra_Vector &x, Epetra_Vector &y) const
int MyGlobalElements(int *MyGlobalElementList) const
T & get(ParameterList &l, const std::string &name)
virtual int NumericFactorization()=0
Performs NumericFactorization on the matrix A.
virtual int SymbolicFactorization()=0
Performs SymbolicFactorization on the matrix A.
virtual int InsertGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
int FillComplete(bool OptimizeDataStorage=true)
int NumMyElements() const
#define AMESOS_CHK_ERR(a)
virtual void PrintTiming() const =0
Prints timing information about the current solver.
virtual const Epetra_BlockMap & Map() const =0
int main(int argc, char *argv[])
Factory for binding a third party direct solver to an Epetra_LinearProblem.
virtual void GetTiming(Teuchos::ParameterList &TimingParameterList) const
Extracts timing information from the current solver and places it in the parameter list...
void SetRHS(Epetra_MultiVector *B)
Amesos_BaseSolver * Create(const char *ClassType, const Epetra_LinearProblem &LinearProblem)
Amesos Create method.
Amesos_BaseSolver: A pure virtual class for direct solution of real-valued double-precision operators...
virtual int ReplaceGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)