[Trilinos-Users] Thyra::initializeAndReuseOp

Bartlett, Roscoe A. bartlettra at ornl.gov
Mon Jan 19 08:20:22 MST 2015


Laurent,

The virtual function Thyra::LinearOpWithSolveBase::initializeAndReuseOp() is meant to be a hook for implementations to override to create specialized behavior.  It is purposefully written somewhat abstract to allow subclasses some flexibility in how it is implemented.  But I don’t think any of the existing subclasses override it so its default implementation just calls Thyra::LinearOpWithSolveBase::initializeOp().  But it does not sound like that is what you want or need from your email.

It sounds like you have the most common use case which is explained here:

    http://trilinos.org/docs/dev/packages/thyra/doc/html/classThyra_1_1LinearOpWithSolveFactoryBase.html#LOWSFB_updated_of_linear_op_sec

If that is not what you want, let me know.   But If you want to just reuse the structure but use the new values for the new iteration, that is built into the Thyra::PreconditionerFactoryBase and LinearOpWithSolveFactoryBase subclasses as demonstrated in the above use case.

Are you using Stratimikos?  If so, you can just grab the PreconditionerFactoryBase object and the LinearOpWithSolveFactoryBase object and then do whatever you want.   You can update the preconditioner with whatever forward LO you want and you can associate it with any forward LO you want for the iterative solve.  If you look at the NOX/Thyra support you will see how this is done.   But you should not have to do that.

Finally, note that these are abstract interfaces that have to be applicable to any and every linear solver that has even been or will be created by humans.  Therefore, they need to be necessarily abstract in what they specify and instead focus on the critical mathematical requirements for linear solves and *not* how the solves are done (that is the job of subclass implementations).  You will need to look at the verbose output to see what is actually happening for specific configurations of linear solvers.  Does that make sense?

Cheers,

-Ross

_______________________________________________________________________________
Dr. Roscoe A. Bartlett, PhD
Oak Ridge National Laboratory
CASL Physics Integration Software Engineering Lead
Trilinos Software Engineering Technologies and Integration Lead
http://web.ornl.gov/~8vt/


From: trilinos-users-bounces at software.sandia.gov [mailto:trilinos-users-bounces at software.sandia.gov] On Behalf Of Laurent Griesser
Sent: Sunday, January 18, 2015 7:56 AM
To: trilinos-users at software.sandia.gov
Subject: [Trilinos-Users] Thyra::initializeAndReuseOp

Hi,
I am new to Trilinos and still not used to the use of linear solvers. I want to solve a parabolic differential equation. Each time iteration naturally consists in solving a linear system. From one time iteration to the other, I would like to reuse my old linear system as much as I can. The matrix of my linear system is penta-diagonal and this structure doesn't change from one iteration to the other. Only the matrix coefficients do change.
I think I can do that with Thyra::initializeAndReuseOp but I am not sure what this method really does. Does it update my ILU factorization? How efficient is that compared to the uninitializeOp/initializeOp strategy?
I have partially read the documentation under

http://trilinos.org/docs/dev/packages/thyra/doc/html/classThyra_1_1LinearOpWithSolveFactoryBase.html
They distinguish between

"Reuse of factorizations for small changes in the forward operator"
and

"Updating the linear solver for major changes in the structure of the forward operator"
What does "small changes" mean? What is the efficiency penalty when I proceed with the "major changes" method?
With PETSc for example, I don't need to think about this. Usually, I can write something along those lines:
// linear system setup phase
KSPCreate(PETSC_COMM_SELF, &m_Solver);
KSPSetType(m_Solver, KSPGMRES);
KSPGMRESSetRestart(m_Solver, 1500);
KSPSetTolerances(m_Solver, 1e-5, PETSC_DEFAULT, 1e10, 1500);
KSPGMRESSetOrthogonalization(m_Solver, KSPGMRESModifiedGramSchmidtOrthogonalization);
PC pc; KSPGetPC(m_Solver, &pc); PCSetType(pc, PCILU);

/*
 * solve parabolic equation
 */
while(t < tf) {
  // update of matrix/rhs
  ...
  // solve linear system
  KSPSetOperators(m_Solver, m_A, m_A, SAME_NONZERO_PATTERN);
  KSPSolve(m_Solver, m_b, m_X);
  // post-processing
  ...
  // time update
  tf += dt;
}

And here, the fact that I mention "SAME_NON_ZERO_PATTERN" tells my solver that I don't want a complete refactorization. This is exactly what I want from trilinos. How do I achieve this?

Thanks for your advice,
Laurent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://software.sandia.gov/pipermail/trilinos-users/attachments/20150119/45140246/attachment.html>


More information about the Trilinos-Users mailing list