ksp tutorial ex22

Ryan Yan vyan2000 at gmail.com
Wed Dec 16 09:25:53 CST 2009


Hi Wee-Beng,
See the reply below,

On Wed, Dec 16, 2009 at 3:07 AM, Wee-Beng Tay <zonexo at gmail.com> wrote:

> Hi Ryan,
>
> Thanks alot.
>
> There's still some parts I don't understand. It'll be great if someone can
> help:
>
> In ex22f.f90, there's a :
>
> MatStencil   row(4),col(4,7)
>
> I understand that the 7 is due to the 7-pt stencil. However, why is there a
> "4"?


You may want to check example 28.c, on line 107, to see why there is a
4. From my understanding, row() is an indicator of the global location
of the current grid point that you are looking at. I think the 4th
entry of row() is reserved for time dependent problem.


In that eg., coarsest grid has dimension 3 with 3 lvl. it seems that in eg.
> ex29.c, it is only given as "row", not array
>
As for Neumann B.C.s, it's mentioned there's null space of the coefficient
> matrix A. looking at ex29,
>
> if (user->bcType == NEUMANN) {
> MatNullSpace <http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-3.0.0/docs/manualpages/Mat/MatNullSpace.html#MatNullSpace> nullspace;
>
> KSPGetNullSpace <http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-3.0.0/docs/manualpages/KSP/KSPGetNullSpace.html#KSPGetNullSpace>(dmmg->ksp,&nullspace);
> MatNullSpaceRemove <http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-3.0.0/docs/manualpages/Mat/MatNullSpaceRemove.html#MatNullSpaceRemove>(nullspace,b,PETSC_NULL <http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-3.0.0/docs/manualpages/Sys/PETSC_NULL.html#PETSC_NULL>);
> }
>
> I don't really understand what it is trying to do. My BC has du/dx=0 and
> du/dy = 0 and I believe it's the same as that of ex29.c
>
> if I do it in Fortran, is it the same?
>
> Thanks again!
>
>
>
>
> On Sat, Dec 12, 2009 at 12:25 AM, Ryan Yan <vyan2000 at gmail.com> wrote:
>
>>
>>
>> On Fri, Dec 11, 2009 at 1:44 AM, Wee-Beng Tay <zonexo at gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I'm also looking at the fortran version of ex22. I have some questions:
>>>
>>> 1. M,N,P are global dimension in each direction of the array. I'm abit
>>> confused. Do you mean the no. of grid pts at the coarse level? Hence, if my
>>> problem has 27x27 grid pts, do I use M=N=9 with 3 multigrid levels or M=N=3
>>> with 9 lvls? What is the guideline in choosing the number of multigrid
>>> levels?
>>>
>>> 2. What is stencil width (s)? Seems to be 1 in both ex22 and ex29.
>>>
>>> 3. What are arrays containing the number of nodes in each cell along the
>>> x/y/z coordinates? Is it ok to just use the default PETSC_NULL_INTEGER?
>>>
>>> 4. There's a subroutine ComputeJacobian which computes the jacobian.
>>> However, what is it actually calculating? Is it simply calculating the
>>> coefficient arising from the discretization of the matrix?
>>>
>>>
>> I just realized that you are looking at Fortran version ex22f.F for this
>> question.
>> In fact, my answer still applies.
>> You may want to make a comparison between:
>>
>> http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/DMMG/DMMGSetSNES.html
>>
>> http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/DMMG/DMMGSetKSP.html
>>
>>
>>
>>> 5. My objective is to solve for the poisson equation arising from the
>>> Navier Stokes equations. ie div grad P = F, which F can be calculated
>>> separately. The boundary conditions are Neumann which is dp/dx, dp/dy=0. Is
>>> this a good example to follow? Or is ex29 a better example, although I need
>>> time to digest the C syntax.
>>>
>>> thanks alot!
>>>
>>>
>>> On Fri, Dec 11, 2009 at 4:14 AM, Ryan Yan <vyan2000 at gmail.com> wrote:
>>>
>>>> Hi Barry,
>>>> Thank you very much for the confirm.
>>>>
>>>> Yan
>>>>
>>>>
>>>> On Thu, Dec 10, 2009 at 3:12 PM, Barry Smith <bsmith at mcs.anl.gov>wrote:
>>>>
>>>>>
>>>>> On Dec 10, 2009, at 2:09 PM, Ryan Yan wrote:
>>>>>
>>>>>  Hi all,
>>>>>> I was looking at the ex22 of ksp.
>>>>>>
>>>>>> If I call:
>>>>>> ...
>>>>>> ierr = DMMGCreate(PETSC_COMM_WORLD,3,PETSC_NULL,&dmmg);CHKERRQ(ierr);
>>>>>> ierr =
>>>>>> DACreate3d(PETSC_COMM_WORLD,DA_NONPERIODIC,DA_STENCIL_STAR,-3,-3,-3,PETSC_DECIDE,PETSC_DECIDE,PETSC_DECIDE,1,1,0,0,0,&da);CHKERRQ(ierr);
>>>>>>  ...
>>>>>>
>>>>>> How many grid pts should I have on the finest level? Is it 27,
>>>>>> considering I am set 3 as the global dimension in each direction of the
>>>>>> array?
>>>>>>
>>>>>> When I run ex22 with -ksp_view, I saw that  on the finest level there
>>>>>> are 9 pts on each direction.
>>>>>>
>>>>>> Is that because I have 3 level?
>>>>>>
>>>>>
>>>>>   Yes. The DA you create initially is for the coarsest grid, finer ones
>>>>> are automatically created by the DMMG.
>>>>>
>>>>>   Barry
>>>>>
>>>>>
>>>>>> Yan
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20091216/55fa44ea/attachment.htm>


More information about the petsc-users mailing list