[petsc-users] updating values in a DA Global array
Matthew Knepley
knepley at gmail.com
Tue Jun 22 18:21:11 CDT 2010
On Tue, Jun 22, 2010 at 12:59 PM, Mark Cheeseman <
mark.cheeseman at kaust.edu.sa> wrote:
> Hi,
>
> I am trying to write a PETSc program in FORTRAN90 where I need to update a
> single value in a global distributed array. I know the global coordinates
> of the position that needs to be updated in the global array but I cannot
> get the mapping from the local vector correct. In this case, I am working
> on a domain with global dimensions [arraysize(1),arraysize(2),arraysize(3)]
> and I want to alter a single point in the global distributed array, uGLOBAL,
> at the global position [arraysize(1)/2-1,arraysize(2)-1,3]. I cannot seem
> to be able to do this... what am I doing wrong?
>
> ...
> DA da
> Vec uGLOBAL, uLOCAL, tmp
> PetscErrorCode ierr
> PetscScalar, pointer :: xx
> PetscInt rank, source_rank, i,j,k, row
>
> ....
>
> call MPI_Comm_rank( PETSC_COMM_WORLD, rank, ierr )
> call DACreate3d( PETSC_COMM_WORLD, DA_NONPERIODIC, DA_STENCIL_BOX, &
> arraysize(1), arraysize(2), arraysize(3),
> PETSC_DECIDE, &
> PETSC_DECIDE, PETSC_DECIDE, 1, 5,
> PETSC_NULL_INTEGER, &
> PETSC_NULL_INTEGER, PETSC_NULL_INTEGER, da, ierr)
> call DACreateGlobalVector( da, pNOW, ierr )
> call DAGetCorners( da, xs, ys, zs, xl, yl, zl, ierr )
>
call DAVecGetArrayF90()
> do i = xs,xs+xl-1
> if ( i.eq.arraysize(1)/2-1 ) then
> do j = ys,ys+yl-1
> if ( j.eq.arraysize(2)/2-1 ) then
> do k = zs,zs+zl-1
> if ( k.eq.3 ) then
>
array(k,j,i) = pressure
> endif
> enddo
> endif
> enddo
> endif
> enddo
>
>
call DAVecRestoreArrayF90()
That should work.
Matt
Thank you,
> Mark
>
> --
> Mark Patrick Cheeseman
>
> Computational Scientist
> KSL (KAUST Supercomputing Laboratory)
> Building 1, Office #126
> King Abdullah University of Science & Technology
> Thuwal 23955-6900
> Kingdom of Saudi Arabia
>
> EMAIL : mark.cheeseman at kaust.edu.sa
> PHONE : +966 (2) 808 0221 (office)
> +966 (54) 470 1082 (mobile)
> SKYPE : mark.patrick.cheeseman
>
--
What most experimenters take for granted before they begin their experiments
is infinitely more interesting than any results to which their experiments
lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20100622/cf2afc9b/attachment.htm>
More information about the petsc-users
mailing list