[petsc-users] Printing parallel Vector in VTK format
khalid ashraf
khalid_eee at yahoo.com
Fri Nov 26 17:02:14 CST 2010
Thanks Jed and Barry. It works fine now.
Khalid
________________________________
From: "petsc-users-request at mcs.anl.gov" <petsc-users-request at mcs.anl.gov>
To: petsc-users at mcs.anl.gov
Sent: Fri, November 26, 2010 10:00:19 AM
Subject: petsc-users Digest, Vol 23, Issue 29
Send petsc-users mailing list submissions to
petsc-users at mcs.anl.gov
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.mcs.anl.gov/mailman/listinfo/petsc-users
or, via email, send a message with subject or body 'help' to
petsc-users-request at mcs.anl.gov
You can reach the person managing the list at
petsc-users-owner at mcs.anl.gov
When replying, please edit your Subject line so it is more specific
than "Re: Contents of petsc-users digest..."
Today's Topics:
1. Global DA index using DAGetCorners (khalid ashraf)
2. Re: Global DA index using DAGetCorners (Barry Smith)
3. Re: Printing parallel Vector in VTK format (khalid ashraf)
4. Re: Printing parallel Vector in VTK format (Jed Brown)
5. Re: Printing parallel Vector in VTK format (Barry Smith)
----------------------------------------------------------------------
Message: 1
Date: Thu, 25 Nov 2010 17:50:21 -0800 (PST)
From: khalid ashraf <khalid_eee at yahoo.com>
Subject: [petsc-users] Global DA index using DAGetCorners
To: petsc-users at mcs.anl.gov
Message-ID: <113982.45603.qm at web112617.mail.gq1.yahoo.com>
Content-Type: text/plain; charset="us-ascii"
It doesn't seem like the problem is with the natural ordering. Since in Fig.9 of
the manual,
the highest number of the grid should be the same(30 in fig. 9) for natural and
petsc ordering.
But I get a lower number when I print it.
I also tried the petsc to natural conversion using the following code,
{
ia[0]=(PetscInt)((k)*(my)*(mx)+(j)*(mx)+(i));
AOPetscToApplication(ao,1,ia);
w_localptr[k][j][i] = ia[0];
PetscPrintf(PETSC_COMM_WORLD,"%d\n",ia[0]);
}
But this gives even lower number for the highest index.
Anyway my goal is to be able to determine the global natural index of the
grid within the for loops in the following way:
for (k=zs; k<zs+zm; k++) {
for (j=ys; j<ys+ym; j++) {
for (i=xs; i<xs+xm; i++) {
natural_global_coordinate(k',j',i')=f(k,j,i);
if natural_global_coord[k'][j'][i'] > half of the grid along x {Do something}
if natural_global_coord[k'][j'][i'] > half of the grid along y {Do something}
etc..
}}}
Could you please suggest what would be the simplest way to achieve this.
Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20101125/ff463aaa/attachment-0001.htm>
------------------------------
Message: 2
Date: Thu, 25 Nov 2010 20:31:17 -0600
From: Barry Smith <bsmith at mcs.anl.gov>
Subject: Re: [petsc-users] Global DA index using DAGetCorners
To: PETSc users list <petsc-users at mcs.anl.gov>
Message-ID: <B39F8696-63EC-4C5B-83D2-AA0ECAA6A073 at mcs.anl.gov>
Content-Type: text/plain; charset=us-ascii
On Nov 25, 2010, at 7:50 PM, khalid ashraf wrote:
> It doesn't seem like the problem is with the natural ordering. Since in Fig.9
>of the manual,
> the highest number of the grid should be the same(30 in fig. 9) for natural and
>petsc ordering.
> But I get a lower number when I print it.
>
> I also tried the petsc to natural conversion using the following code,
> {
> ia[0]=(PetscInt)((k)*(my)*(mx)+(j)*(mx)+(i));
This give the natural number of the location in ia[0]
> AOPetscToApplication(ao,1,ia);
So it makes no sense to call AOPetscToApplication() to map it to something
else. It is already in the natural (i.e. application ordering)
> w_localptr[k][j][i] = ia[0];
> PetscPrintf(PETSC_COMM_WORLD,"%d\n",ia[0]);
> }
> But this gives even lower number for the highest index.
>
> Anyway my goal is to be able to determine the global natural index of the
> grid within the for loops in the following way:
> for (k=zs; k<zs+zm; k++) {
> for (j=ys; j<ys+ym; j++) {
> for (i=xs; i<xs+xm; i++) {
> natural_global_coordinate(k',j',i')=f(k,j,i);
> if natural_global_coord[k'][j'][i'] > half of the grid along x {Do something}
> if natural_global_coord[k'][j'][i'] > half of the grid along y {Do something}
i > m/2 means means it is in the right half of the grid along x (where m
is the number of grid points in the x direction).
To determine these things you don't need to do anything about mapping
between orderings.
You are chasing yourself in circles to do something that is essentially
trivial. With the loop structure you have above, the i,j,k ARE exactly the
logical locations in the global X, Y, Z grid. It couldn't be simplier.
Barry
> etc..
> }}}
> Could you please suggest what would be the simplest way to achieve this.
> Thanks in advance.
>
>
>
>
>
------------------------------
Message: 3
Date: Thu, 25 Nov 2010 21:36:08 -0800 (PST)
From: khalid ashraf <khalid_eee at yahoo.com>
Subject: Re: [petsc-users] Printing parallel Vector in VTK format
To: petsc-users at mcs.anl.gov
Message-ID: <804366.55079.qm at web112616.mail.gq1.yahoo.com>
Content-Type: text/plain; charset="us-ascii"
Thanks Barry. I get the correct output when I use
VecView(w,PETSC_VIEWER_STDOUT_WORLD)
But if I use the VecView_VTK function from the file
ksp/ksp/examples/tutorials/ex29.c
then I get different results.
For the code:
if (i<m/2) vec=0.001 else vec=-0.001;
Output with VecView: 0.001 for half of the grid
-0.001 for rest half of the grid
Output with VecView_VTK:
0.001 for the full grid.
Date: Thu, 25 Nov 2010 02:24:52 -0800 (PST)
From: khalid ashraf <khalid_eee at yahoo.com>
Subject: [petsc-users] DAGetCorners; xs,ys,zs return 0 for all the
processors
To: petsc-users at mcs.anl.gov
Message-ID: <588844.78157.qm at web112619.mail.gq1.yahoo.com>
Content-Type: text/plain; charset="us-ascii"
Here is the call to DA creation:
ierr =
DACreate3d(PETSC_COMM_WORLD,DA_NONPERIODIC,DA_STENCIL_BOX,appctx.l,appctx.m,appctx.n,
PETSC_DECIDE,PETSC_DECIDE,PETSC_DECIDE,1,1,PETSC_NULL,PETSC_NULL,PETSC_NULL,
&appctx.da);CHKERRQ(ierr);
Khalid
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20101125/d0590ec8/attachment-0001.htm>
------------------------------
Message: 2
Date: Thu, 25 Nov 2010 11:35:43 +0100
From: Jed Brown <jed at 59A2.org>
Subject: Re: [petsc-users] DAGetCorners; xs,ys,zs return 0 for all the
processors
To: PETSc users list <petsc-users at mcs.anl.gov>
Message-ID:
<AANLkTineq3bTG=iRsjkdoY2ZhZ9ac7r8vBmSUqEpOvu5 at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Thu, Nov 25, 2010 at 11:24, khalid ashraf <khalid_eee at yahoo.com> wrote:
> Here is the call to DA creation:
>
> ierr =
>DACreate3d(PETSC_COMM_WORLD,DA_NONPERIODIC,DA_STENCIL_BOX,appctx.l,appctx.m,appctx.n,
>
>,
>
> PETSC_DECIDE,PETSC_DECIDE,PETSC_DECIDE,1,1,PETSC_NULL,PETSC_NULL,PETSC_NULL,
> &appctx.da);CHKERRQ(ierr);
>
If you created the DA as above and then call
DAGetCorners(appctx.da,&xs,&ys,&zs,&xm,&ym,&zm);
then only on rank=0 will xs,ys,zs all be equal to zero. Your other message
about PETSc versus natural ordering indicates that this is working
correctly. Is it working now? If not, please send more context, including
whatever code you are using to print output.
Jed
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20101125/6da538a3/attachment-0001.htm>
------------------------------
_______________________________________________
petsc-users mailing list
petsc-users at mcs.anl.gov
https://lists.mcs.anl.gov/mailman/listinfo/petsc-users
End of petsc-users Digest, Vol 23, Issue 28
*******************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20101125/d2817c38/attachment-0001.htm>
------------------------------
Message: 4
Date: Fri, 26 Nov 2010 10:13:31 +0100
From: Jed Brown <jed at 59A2.org>
Subject: Re: [petsc-users] Printing parallel Vector in VTK format
To: PETSc users list <petsc-users at mcs.anl.gov>
Message-ID:
<AANLkTikLk3g3xgGnVbDTtB4Wcr7HcuJeLyn9ejWuMBEg at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Fri, Nov 26, 2010 at 06:36, khalid ashraf <khalid_eee at yahoo.com> wrote:
> Thanks Barry. I get the correct output when I use
> VecView(w,PETSC_VIEWER_STDOUT_WORLD)
>
> But if I use the VecView_VTK function from the file
> ksp/ksp/examples/tutorials/ex29.c
>
> then I get different results.
>
This is a crucial piece of information, if you stated this in the first
email, you would have gotten a good answer to your first email.
The problem is that this function and the copy in ex50.c, never worked in
parallel. Clearly the person who wrote it misunderstood the VTK legacy
format because nothing similar can work in parallel. See
src/snes/examples/tutorials/ex5.c for the correct way to do it:
PetscViewer viewer;
ierr = PetscViewerCreate(PETSC_COMM_WORLD, &viewer);CHKERRQ(ierr);
ierr = PetscViewerSetType(viewer, PETSCVIEWERASCII);CHKERRQ(ierr);
ierr = PetscViewerFileSetName(viewer, "ex5_sol.vtk");CHKERRQ(ierr);
ierr = PetscViewerSetFormat(viewer,
PETSC_VIEWER_ASCII_VTK);CHKERRQ(ierr);
ierr = DAView(user.da, viewer);CHKERRQ(ierr);
ierr = VecView(x, viewer);CHKERRQ(ierr);
ierr = PetscViewerDestroy(viewer);CHKERRQ(ierr);
Jed
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20101126/31c1b6cf/attachment-0001.htm>
------------------------------
Message: 5
Date: Fri, 26 Nov 2010 10:42:04 -0600
From: Barry Smith <bsmith at mcs.anl.gov>
Subject: Re: [petsc-users] Printing parallel Vector in VTK format
To: PETSc users list <petsc-users at mcs.anl.gov>
Message-ID: <8A1D2053-2CC5-44E6-AC92-AAE60D7CF966 at mcs.anl.gov>
Content-Type: text/plain; charset=us-ascii
Jed,
Can you please remove that bad code from those two examples if you haven't
yet.
Thanks
Barry
On Nov 26, 2010, at 3:13 AM, Jed Brown wrote:
> On Fri, Nov 26, 2010 at 06:36, khalid ashraf <khalid_eee at yahoo.com> wrote:
> Thanks Barry. I get the correct output when I use
> VecView(w,PETSC_VIEWER_STDOUT_WORLD)
>
> But if I use the VecView_VTK function from the file
> ksp/ksp/examples/tutorials/ex29.c
>
> then I get different results.
>
> This is a crucial piece of information, if you stated this in the first email,
>you would have gotten a good answer to your first email.
>
> The problem is that this function and the copy in ex50.c, never worked in
>parallel. Clearly the person who wrote it misunderstood the VTK legacy format
>because nothing similar can work in parallel. See
>src/snes/examples/tutorials/ex5.c for the correct way to do it:
>
> PetscViewer viewer;
> ierr = PetscViewerCreate(PETSC_COMM_WORLD, &viewer);CHKERRQ(ierr);
> ierr = PetscViewerSetType(viewer, PETSCVIEWERASCII);CHKERRQ(ierr);
> ierr = PetscViewerFileSetName(viewer, "ex5_sol.vtk");CHKERRQ(ierr);
> ierr = PetscViewerSetFormat(viewer, PETSC_VIEWER_ASCII_VTK);CHKERRQ(ierr);
> ierr = DAView(user.da, viewer);CHKERRQ(ierr);
> ierr = VecView(x, viewer);CHKERRQ(ierr);
> ierr = PetscViewerDestroy(viewer);CHKERRQ(ierr);
>
> Jed
------------------------------
_______________________________________________
petsc-users mailing list
petsc-users at mcs.anl.gov
https://lists.mcs.anl.gov/mailman/listinfo/petsc-users
End of petsc-users Digest, Vol 23, Issue 29
*******************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20101126/8061a91f/attachment.htm>
More information about the petsc-users
mailing list