[petsc-users] DMDACoor2d and DMDACoor3d in Fortran
Barry Smith
bsmith at mcs.anl.gov
Fri Apr 25 12:06:33 CDT 2014
On Apr 25, 2014, at 11:41 AM, Danyang Su <danyang.su at gmail.com> wrote:
> Hi All,
>
> I tried to set the simulation domain using DMDA coordinates, following the example dm/examples/tutorials/ex3.c. The 1D problem worked fine but the 2D and 3D failed because of the definition in coors2d and coords3d. What should I use to define the variable coords2d and coords3d?
Failed in compiling is not very useful. Much better to send the ENTIRE compiler error message.
There is no DMDACoor2d or 3d in Fortran. You should use
> PetscScalar, pointer :: coords2d(:,:,:)
note there is three indices, the first index is 0 or 1 for the x or y coordinate
Similar for 3d.
Satish,
Please see about adding a DMDACoor2d and 3d for Fortran.
Request-assigned: Satish, add a DMDACoor2d and 3d for Fortran.
Barry
>
> -->Codes section:
>
> PetscScalar, pointer :: coords1d(:)
> DMDACoor2d, pointer :: coords2d(:,:) !Failed in compiling
> DMDACoor3d, pointer :: coords3d(:,:,:) !Failed in compiling
> Vec :: gc
>
> !1D domain
> call DMGetGlobalVector(dmda_flow%da,gc,ierr)
> call DMDAVecGetArrayF90(dmda_flow%da,gc,coords1d,ierr)
> do ivx = nvxls,nvxle
> coords1d(ivx-ibase) = xglat(ivx)
> end do
> call DMDAVecRestoreArrayF90(dmda_flow%da,gc,coords1d,ierr)
> call DMSetCoordinates(dmda_flow%da,gc,ierr)
> call DMRestoreGlobalVector(dmda_flow%da,gc,ierr)
>
>
> !2D domain
> call DMGetGlobalVector(dmda_flow%da,gc,ierr)
> call DMDAVecGetArrayF90(dmda_flow%da,gc,coords2d,ierr)
> do ivx = nvxls,nvxle
> coords2d(ivx-ibase,ivy-ibase)%x = xglat(ivx)
> coords2d(ivx-ibase,ivy-ibase)%y = yglat(ivy)
> end do
> call DMDAVecRestoreArrayF90(dmda_flow%da,gc,coords2d,ierr)
> call DMSetCoordinates(dmda_flow%da,gc,ierr)
> call DMRestoreGlobalVector(dmda_flow%da,gc,ierr)
>
> Thanks and regards,
>
> Danyang
More information about the petsc-users
mailing list