[petsc-users] PCFIELDSPLIT question

Hom Nath Gharti hng.email at gmail.com
Tue Feb 2 14:20:58 CST 2016


Hi Matt, hi all,

I am trying to use PCFIELDSPLIT for my solver which consists of 4
different variables, namely, u (displacement vector), \chi
(displacement potential), p(pressure), and \phi (gravity potential).

My code segment looks like the following:
======================================================
call KSPCreate(PETSC_COMM_WORLD,ksp,ierr)
call KSPGetPC(ksp,pc,ierr)
nsplit=4
call PCFieldSplitSetBlockSize(pc,nsplit,ierr);
call PCFieldSplitSetIS(pc,"0",gdofu_is,ierr);
call ISDestroy(gdofu_is,ierr)
call PCFieldSplitSetIS(pc,"1",gdofchi_is,ierr);
call ISDestroy(gdofchi_is,ierr)
call PCFieldSplitSetIS(pc,"2",gdofp_is,ierr);
call ISDestroy(gdofp_is,ierr)
call PCFieldSplitSetIS(pc,"3",gdofphi_is,ierr);
call ISDestroy(gdofphi_is,ierr)

call PCFieldSplitGetSubKSP(pc,nsplit,subksp,ierr);

call KSPSetOperators(subksp(1),Amat,Amat,ierr);
call KSPSetOperators(subksp(2),Amat,Amat,ierr);
call KSPSetOperators(subksp(3),Amat,Amat,ierr);
call KSPSetOperators(subksp(4),Amat,Amat,ierr);

call KSPSolve(ksp,bvec,xvec,ierr)
======================================================

But I am getting the following error:
[79]PETSC ERROR: Null argument, when expecting valid pointer
[79]PETSC ERROR: Null Object: Parameter # 1
[79]PETSC ERROR: #1 KSPSetOperators() line 536 in
/home/hgharti/lsoft/petsc-3.6.3-intel16-mpi5/src/ksp/ksp/interf

It looks like I am doing something wrong in "call KSPSetOperators" but
I could not figure that out.

Could anybody help me to fix this problem? I looked into almost all
related examples but I could not really figure out the correct steps
after "call PCFieldSplitSetIS".

Any help will be greatly appreciated.

Best,
Hom nath

On Sun, Jan 24, 2016 at 7:14 PM, Hom Nath Gharti <hng.email at gmail.com> wrote:
> Thank you so much Matt! I will try.
>
> Hom Nath
>
> On Sun, Jan 24, 2016 at 6:26 AM, Matthew Knepley <knepley at gmail.com> wrote:
>> On Fri, Jan 22, 2016 at 2:19 PM, Hom Nath Gharti <hng.email at gmail.com>
>> wrote:
>>>
>>> Dear all,
>>>
>>> I am new to PcFieldSplit.
>>>
>>> I have a matrix formed using MATMPIAIJ. Is it possible to use
>>> PCFIELDSPLIT operations in this type of matrix? Or does it have to be
>>> MATMPIBIJ or MATNEST format?
>>
>>
>> Yes, you can split AIJ.
>>
>>>
>>> If possible for MATMPIAIJ, could anybody provide me a simple example
>>> or few steps? Variables in the equations are displacement vector,
>>> scalar potential and pressure.
>>
>>
>> If you do not have a collocated discretization, then you have to use
>>
>>
>> http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/PC/PCFieldSplitSetIS.html
>>
>>   Thanks,
>>
>>      Matt
>>
>>>
>>> Thanks for help.
>>>
>>> Hom Nath
>>
>>
>>
>>
>> --
>> What most experimenters take for granted before they begin their experiments
>> is infinitely more interesting than any results to which their experiments
>> lead.
>> -- Norbert Wiener


More information about the petsc-users mailing list