[petsc-users] Obtain the preconditioned matrix

Matthew Knepley knepley at gmail.com
Sat Mar 24 07:58:57 CDT 2018


On Sat, Mar 24, 2018 at 8:56 AM, 我 <dayedut123 at 163.com> wrote:

> Hi Matt,
> I have tested my code with a really small matrix(10*10) just now and the
> preconditioned matrix is obtained. But for my case, the output is still
> equal to zero. I'm thinking if it is because this coefficient matrix is too
> ill. In my case, due to the Dirichlet boundary condition, I multiply a
> really huge number(e.g. 1e+10) at the matrix's given position. So this
> matrix is combined with some really huge numbers. I don't know if it will
> influence the preconditioned matrix output.
>

Try changing the PC to Jacobi and see what you get. I think its not the
huge numbers.

  Thanks,

     Matt


> The viewer is PETSC_VIEWER_STDOUT_WORLD.
> Thanks again!
> daye
>
>
>
>
>
> At 2018-03-24 19:26:34, "Matthew Knepley" <knepley at gmail.com> wrote:
>
> On Sat, Mar 24, 2018 at 8:15 AM, 我 <dayedut123 at 163.com> wrote:
>
>> Hi Matt,
>> Sorry to distribute you again. I still have trouble with
>> KSPComputeExplicitOperator. I reduced the matrix size to around 1000*1000.
>> The time-cost of this function is acceptable, but when I output the
>> preconditioned matrix, all the values are equal to zero! Here is part of my
>> codes, do I operate error with this function?
>>
>> PC pc;
>> KSP ksp;
>> Mat A,PA;
>> Vec b,x;
>> ierr=KSPCreate(PETSC_COMM_WORLD,&ksp);CHKERRQ(ierr);
>> ierr=KSPSetOperators(ksp,A,A);CHKERRQ(ierr);
>> ierr=KSPGetPC(ksp,&pc);CHKERRQ(ierr);
>> ierr=PCSetType(pc,PCHYPRE);CHKERRQ(ierr);
>> ierr=KSPSetType(ksp,KSPGMRES);CHKERRQ(ierr);
>> ierr=KSPSetFromOptions(ksp);CHKERRQ(ierr);
>> ierr=KSPSolve(ksp,b,x);CHKERRQ(ierr);
>> ierr=KSPComputeExplicitOperator(ksp,&PA);
>>
>
> There is no need to assemble the output matrix.
>
>
>> ierr=MatAssemblyBegin(PA,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
>> ierr=MatAssemblyEnd(PA,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
>>
>
> What kind of viewer are you using? The code above should work. I would
> step through
> in the debugger to see why one column is all zeros, or try it in an
> example like
> SNES ex5 to make sure its not a problem in your code.
>
>   Thanks,
>
>     Matt
>
>
>> ierr=MatView(PA,viewer);CHKERRQ(ierr);
>>
>> Thank you very much!
>> Daye
>>
>>
>>
>>
>>
>>
>> At 2018-03-23 07:41:26, "Matthew Knepley" <knepley at gmail.com> wrote:
>>
>> On Thu, Mar 22, 2018 at 8:29 PM, 我 <dayedut123 at 163.com> wrote:
>>
>>> Hi all,
>>> I want to analyze the preconditioned matrix. But the
>>> KSPComputeExplicitOperator costs too much time to obtain the matrix. My
>>> origin matrix is about 3000*3000 sparse one. I noticed this function is
>>> applicable for the relative small system. What's the matrix-size limitation
>>> for this function? And for my case, any suggestions to solve it with less
>>> time?
>>>
>>
>> This is just a really expensive operation. There is no way around it.
>>
>>    Matt
>>
>>
>>> Thank you very much!
>>> daye
>>>
>>>
>>>
>>>
>>
>>
>>
>> --
>> 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
>>
>> https://www.cse.buffalo.edu/~knepley/ <http://www.caam.rice.edu/~mk51/>
>>
>>
>>
>>
>>
>
>
>
> --
> 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
>
> https://www.cse.buffalo.edu/~knepley/ <http://www.caam.rice.edu/~mk51/>
>
>
>
>
>



-- 
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

https://www.cse.buffalo.edu/~knepley/ <http://www.caam.rice.edu/~mk51/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180324/a394c6a4/attachment.html>


More information about the petsc-users mailing list