[petsc-users] Reusing ML preconditioner

Barry Smith bsmith at mcs.anl.gov
Wed Jun 29 22:21:37 CDT 2011


On Jun 29, 2011, at 10:12 PM, John Fettig wrote:

> On Wed, Jun 29, 2011 at 11:01 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
>> 
>>  John,
>> 
>>   The MatCreateSeqAIJWithArrays() uses the memory (arrays) that you provide so you cannot free those arrays or muck with them until you are finished with the solve.
> 
> I figured that was the case.  I wasn't sure how far down the hierarchy
> the memory I provided was referenced, so I figured if I passed in a
> Pmat that used petsc allocated memory I could get around this.

   Once the preconditioner is built the "old" Pmat is not used for later linear solves only the "built" preconditioner is used so passing the old Pmat is not doing anything for you.

> 
>>   What happens if you ALWAYS copy with MatDuplicate() the MatCreate*WithArrays() matrix immediately after you create it and use that matrix as I describe below in the setoperators? Does it start behaving like
>> the 1) MatSetValues()  or does it still behave "badly"?
> 
> It takes roughly the same number of CG iterations as 1), but the solve
> time indicates to me that PCSetUp is being called every solve.  The
> solutions are also different, which also indicates that the
> preconditioner is being rebuilt every solve.

  If you pass in SAME_PRECONDITIONER to the KSPSetOperators() it is simply impossible that it will rebuild the preconditioner. There must be another explanation as to what is going on. Are you calling anything else on the KSP?  

  If you run with -info it should print the message "Setting PC with identical preconditioner\n" when it reuses the preconditioner otherwise it will print "Setting up new PC\n") or 
  "Setting up PC with same nonzero pattern\n") or "Setting up PC with different nonzero pattern"


   Is this only happing with PCML and not with other preconditioners like PCILU? 

   Barry



> 
> Thanks,
> John



More information about the petsc-users mailing list