[petsc-users] How to access solution in /src/ksp/ksp/example/tutorial/ex45.c

Jed Brown jedbrown at mcs.anl.gov
Mon Apr 9 19:24:23 CDT 2012


2012/4/9 Zhenglun (Alan) Wei <zhenglun.wei at gmail.com>

> Dear All,
>    I hope you're having a nice day.
>    I'm working on ex45. It does not have any output subroutine inside.
> Therefore, I was trying to write out mine.
>    I was trying to use DMDAVecGetArray; but I found that the DM object has
> been destroyed at very beginning of the main code. Therefore, I swithed to
> VecGetArray. However, it gives me warning like:
> ex45.c:185: warning: passing argument 2 of 'VecGetArray' from incompatible
> pointer type
>    Then, it shows a memory violation error during execution, which is
> attached as 'out'. I checked 'VecGetArray' examples in PETSc manual, it
> always shows how to use it to extract one-dimensional array. I wonder if it
> can do 3-dimensional?
>

Use DMDAVecGetArray(), see my reply to your other message.


>
>    Also, there are other two minor questions:
> 1) in ex45.c, 'ComputeRHS', there is a if(x) {} statement, I write probe
> statements inside this if statement to see if the code ever go through it;
> the result shows it does not. I don't know why. ;(
>

Use a debugger and examine the stack to find out why that argument is 0.
Learning to use a debugger is absolutely a good time investment. In cases
like this, it's the difference between conclusively answering the question
in seconds and having to actually think.

2) probe statements are added in 'ComputeRHS' for both ex45.c and ex29.c.
> The size parameter used for DMDACreate3d in ex45 is -7, -7, -7; while for
> DMDACreate2d in ex29 is -7,-7. The probe statements show that the real 2d
> domain generated in ex29 is 25*25, which, as I understand, is because of
> multigrid. However, with multigrid scheme, the ex45 create a 7*7*7 3d
> domain. Any suggestions on this?
>

Please do not follow this version of ex29.c because it uses the deprecated
DMMG. The example has been updated in petsc-dev. The refinement was coming
from automatic refinement via DMMG.

http://www.mcs.anl.gov/petsc/petsc-dev/src/ksp/ksp/examples/tutorials/ex29.c.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120409/0deddca4/attachment.htm>


More information about the petsc-users mailing list