ksp tutorial ex22

Jed Brown jed at 59A2.org
Wed Dec 16 09:21:57 CST 2009


On Wed, 16 Dec 2009 16:07:00 +0800, 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"? 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

Fortran 77 has a severely crippled type system, the 4 comes from the
size of this data structure.

  http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Mat/MatStencil.html

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

Since the matrix is singular due to the constant null space, it's range
is a subspace with codimension 1.  An arbitrary right hand side may not
lie within this subspace, MatNullSpaceRemove is projecting it into the
range of the operator.

> if I do it in Fortran, is it the same?

Yes

Jed


More information about the petsc-users mailing list