[petsc-users] PCComposite

Jed Brown jedbrown at mcs.anl.gov
Mon May 28 08:42:34 CDT 2012


On Mon, May 28, 2012 at 8:40 AM, Hui Zhang <mike.hui.zhang at hotmail.com>wrote:

>
> On May 28, 2012, at 3:20 PM, Jed Brown wrote:
>
> On Mon, May 28, 2012 at 5:19 AM, Hui Zhang <mike.hui.zhang at hotmail.com>wrote:
>
>> Sorry for repost the following question, but after reading composite.c
>> and asm.c,
>> I can not understand.  I observed that my subroutine for modifying
>> submatrices of PCASM was
>> called twice.  In composite.c it seems there is no calling of PCSetUp on
>> its componential PC's.
>> In asm.c, the PCSetUp_ASM first determines whether pc->setupcalled is
>> true.
>>
>> I think this is a general question for PCComposite say pc. If it consists
>> of two pc's  pc0, pc1
>> and I have PCSetUp(pc0), I would not expect pc0 to be SetUp again.  I can
>> not understand
>> in my case why PCASM seems SetUp twice.
>>
>
> Does the routine do anything or just return immediately? If nothing has
> been changed since the last time a PC was set up, it should return
> immediately. If you have changed some configuration, it may need to be set
> up again.
>
>
> Thanks. But I said something wrong.  The source code asm.c does call the
> ModifySubMatrices
> whenever PCSetUp is called on PCASM, no matter whether it was called
> before.  So this
> explains my observation (two calls of ModifySubMatrices).  My new question
> is:  can you
> add a user control to determine whether MatGetSubMatrices and
> PCModifySubMatrices
> should be called inside PCSetUp_ASM ?  But maybe this is too invasive and
> not
> very useful to most people (although useful to me).
>

It does not reach PCSetUp_ASM unless something has changed. Run with -info
and/or in a debugger to see why.

PetscErrorCode  PCSetUp(PC pc)
{
  PetscErrorCode ierr;
  const char     *def;

  PetscFunctionBegin;
  PetscValidHeaderSpecific(pc,PC_CLASSID,1);
  if (!pc->mat)
SETERRQ(((PetscObject)pc)->comm,PETSC_ERR_ARG_WRONGSTATE,"Matrix must be
set first");

  if (pc->setupcalled > 1) {
    ierr = PetscInfo(pc,"Setting PC with identical
preconditioner\n");CHKERRQ(ierr);
    PetscFunctionReturn(0);



>
>
>
>
>
>>
>> Thanks!
>> Hui
>>
>>
>> > I have got a new question.  I'm now constructing a PCComposite from
>> PCASM and another PCKSP (coarse
>> > problem). And construction of PCKSP needs to use the subksp's of PCASM.
>> So I need to PCSetUp on the
>> > PCASM, right?  But the KSP using PCComposite would setup PCASM again.
>>  How can I avoid twice setup
>> > of PCASM ?
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120528/fb0af8b3/attachment.html>


More information about the petsc-users mailing list