[petsc-users] Parallel matrix-vector multiplication

Barry Smith bsmith at mcs.anl.gov
Wed Nov 11 22:12:05 CST 2015


  When you create the 2 DM you must be set the lx, ly arguments (the ones you set to 0) in your code carefully to insure that the vectors for the 2 DM you create have compatible layout to do the matrix vector product. 

   You can run a very small problem with 2 processors and printing out the vectors to see the layout to make sure you get it correct.

   The 2 DM don't have any magically way of knowing that you created another DMDA and want it to be compatible automatically.

  Barry

DMDACreate2d(PETSC_COMM_WORLD , DM_BOUNDARY_GHOSTED , DM_BOUNDARY_GHOSTED , DMDA_STENCIL_BOX ,
      Mx      , Nx      , PETSC_DECIDE , PETSC_DECIDE , 1 , 0 , 0 , 0 , &dax); 
  DMDACreate2d(PETSC_COMM_WORLD , DM_BOUNDARY_NONE    , DM_BOUNDARY_NONE    , DMDA_STENCIL_BOX ,
      Mx-2*bs , Nx-2*bs , PETSC_DECIDE , PETSC_DECIDE , 1 , 0 , 0 , 0 , &daf); 

> On Nov 11, 2015, at 10:05 PM, Gianluca Meneghello <gianmail at gmail.com> wrote:
> 
> Hi,
> 
> I am trying to do something apparently really simple but with no success.
> 
> I need to perform a matrix-vector multiplication x = B f , where the length of x is bigger than the length of f (or viceversa). Thus, B cannot be created using DMCreateMatrix.
> 
> Both x and f are obtained from different DMs, the smaller covering only a subdomain of the larger. The application is to apply a control f to a system, e.g. \dot{x} = A x + B f.
> 
> The problem is, when running on more than one core, the vector x is not organized as I would expect (everything works fine on a single core). 
> 
> I attach a short example where B is intended to map f to the interior of x.
> 
> mpirun -n 1 ./test -draw_pause -1     works fine while
> mpirun -n 2 ./test -draw_pause -1     shows the problem
> 
> I have not found any example with non square matrices in the src folder, any help is very welcome.
> 
> Thanks for your time,
> 
> Gianluca
> <test.cpp>



More information about the petsc-users mailing list