petsc-current/docs/manualpages/Vec/VecScatterCreateToAll.html

Il 05 Giu 2017 4:12 PM, "Francesco Migliorini" <
francescomigliorin...@gmail.com> ha scritto:

> Hello there!
>
> I am working with an MPI code in which I should create a petsc vector such
> that all the processes can access to all its entries. So, I tried with
> VecCreateShared but it does not work with my machine. Then I tried
> VecCreateMPI but it seems to me that it does not change anything from the
> usual VecCreate. Finally I found the scatter commands but the examples are
> a bit tricky. So, are there any other way? If no, could someone please show
> me how to use scatter in this simple code?
>
> Vec  feP    !The vector to be shared with all the processes
> (...)
> mpi_np = 2    !The number of processes
> ind(1) = 10   !The global dimension of the vector
> call VecCreate(PETSC_COMM_WORLD,feP,perr)
> call VecSetSizes(feP,PETSC_DECIDE,ind,perr)
> call VecSetFromOptions(feP,perr)
> (...)    !Here feP is filled in
> call VecAssemblyBegin(feP,perr)
> call VecAssemblyEnd(feP,perr)
>
> Many thanks,
> Francesco
>

Reply via email to