[petsc-users] How to create and assemble matrices for DA vectors??

Алексей Рязанов ram at ibrae.ac.ru
Fri Apr 8 06:10:29 CDT 2011


Thank you very much, Satish! Ill try it

Alexey

8 апреля 2011 г. 3:32 пользователь Satish Balay <balay at mcs.anl.gov> написал:

> On Fri, 8 Apr 2011, Алексей Рязанов wrote:
>
> > Hello.
> >
> > When I create vectors using
> >
> > VecCreate(PETSC_COMM_WORLD,&u);
> > VecSetSizes(u,PETSC_DECIDE, VecSize);
> > VecSetFromOptions(u);
> > VecDuplicate(u,&b);
> >
> > and matrix using
> >
> > MatCreate(PETSC_COMM_WORLD,&A);
> > MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,VecSize,VecSize);
> > MatSetFromOptions(A);
> >
> > PETSc distributes their elements in a proper identical way among
> processors,
> > so I can use procedures like
> >
> > MatMult(A,u,b);
> >
> > and
> >      KSPSolve(ksp,b,x);
> > Ofcourse after matrix assembling and initialization of KSP and PC
> >
> > KSPCreate(PETSC_COMM_WORLD,&ksp);
> > KSPSetOperators(ksp,A,A,DIFFERENT_NONZERO_PATTERN);
> >
> > And thats great and works amazingly!
> >
> >
> >
> >
> > But now I've created DA vectors "u" and "b" and assembled them through
> the
> > natural grid indexing.
> >
> > And I need to solve the same SLE Au=b, where A is a Laplacian.
> >
> > How should I create and assemble the A matrix according to my DA vector
> to
> > use the same functionality?
>
> Create u,b with DAGetGlobalVector() and A with DAGetMatrix() and they
> will match the DA. For eg: check: src/snes/examples/tutorials/ex5.c
> [or some of the examples in src/dm/da/examples]
>
> Satish
>
> >
> > Thank you!
> >
> > Alexey Ryazanov
> > ______________________________________
> > Nuclear Safety Institute of Russian Academy of Sciences
> > <http://www.ibrae.ac.ru/>
> >
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110408/8ad1b6c6/attachment.htm>


More information about the petsc-users mailing list