[Trilinos-Users] AztecOO recursion
Bora Ucar
boraucar at gmail.com
Sun Nov 6 15:53:36 MST 2005
Hi,
I have to solve a linear system. the system is defined using an
Epetra_Operator AOp as
Epetra_LinearProblem probDef(AOp, solution, rhs);
AztecOO probSolver(probDef);
probSolver.SetPrecOperator(P);
probSolver.SetAztecOption(AZ_kspace,outerNIter);
probSolver.SetAztecOption(AZ_solver, AZ_gmres);
probSolver.Iterate(outerNIter, 1.0E-8);
where P is an Epetra_Operator which will be used as a preconditioner.
The ApplyInverse of P requires two linear system solutions with
matrices P1 and P2.
(The codes are given below). the problem is that the input inX of
ApplyInverse changes during the solve_P2 function; the calls to
inX.Norm2() at lines L1 and L2 below result in different values. I
have tried all combinations of recursiveIterate and iterate in the
solve_P1 and solve_P2 functions, none worked.
Any suggestions?
Bora
-----------------------------------------------------------------------------------------------------------------------------------
int myPre::ApplyInverse(const Epetra_MultiVector &inX,
Epetra_MultiVector &outY ) const
{
int s1, s2;
double nn;
Epetra_MultiVector y1(outY);
y1.PutScalar(0.0);
s1 = solve_P1(y1, inX);
inX.Norm2(&nn);
/*L1*/ cout <<"Before second solve norm2(inX)= "<<nn<<endl;
outY.PutScalar(0.0);
s2 = solve_P2(outY, y1);
inX.Norm2(&nn);
/*L2*/ cout <<"After second solve norm2(inX)="<<nn<<endl;
return s1+s2;
}
-----------------------------------------------------------------------------------------------------------------------------------
where solve_P1 and solve_P2 solves linear systems using AzteccOO
(solve_P2 is the same as above where P1 is replaced by P2):
int myPre::solve_P1(Epetra_MultiVector &initialGuess, const
Epetra_MultiVector &rhs ) const
{
int outerNIter = 50;
int rv;
Epetra_MultiVector tmpRhs (rhs);
Epetra_LinearProblem probDef(P1, &initialGuess, &tmpRhs);
AztecOO probSolver(probDef);
probSolver.SetAztecOption(AZ_precond, AZ_none);
probSolver.SetAztecOption(AZ_output, AZ_all);
probSolver.SetAztecOption(AZ_diagnostics, AZ_all);
probSolver.SetAztecOption(AZ_kspace, outerNIter);
probSolver.SetAztecOption(AZ_solver, AZ_gmres);
probSolver.recursiveIterate(outerNIter, 1.0E-5);
return rv //rv is set according to the status of probSolver;
}
More information about the Trilinos-Users
mailing list