[petsc-users] Behavior of PetscViewerVTKOpen
Emmanuel Ayala
juaneah at gmail.com
Mon Feb 24 18:11:42 CST 2020
Ok, that's right, now i understand. Thanks!
Kind regards.
El lun., 24 de feb. de 2020 a la(s) 17:48, Jed Brown (jed at jedbrown.org)
escribió:
> Emmanuel Ayala <juaneah at gmail.com> writes:
>
> > Hi everyone,
> >
> > I think VTK is not the best option to save files, but I just want a quick
> > way to visualize a structured grid generated with DMDACreate3d. I
> visualize
> > the vts file with ParaView.
> >
> > The situation is, If I change the number global dimension in each
> direction
> > of the array (*M,N,P *parameters for DMDACreate3d) it is supposed that
> the
> > size of the mesh won't changes, ONLY the number of division in the
> affected
> > direction, but it does NOT happen ( I used DMDASetUniformCoordinates to
> > have an uniform grid ). When I save the file, and then check it with
> > ParaView, the size changes. (I checked the coordinates with
> > DMGetCoordinates everything is OK, size and division), the problem is in
> > the visualization using VTK.
> >
> > I use the next set of functions to save the file.
>
> Normally you view a field defined on your DM (which will be correctly
> mapped by your coordinates), not the coordinates (which reside on a
> coordinate DM, which does not itself have coordinates). Try something
> like this:
>
> DMCreateGlobalVector(dm, &U);
> VecView(U, viewer);
>
> > ierr =
> >
> PetscViewerVTKOpen(PETSC_COMM_WORLD,"nodes_coord.vts",FILE_MODE_WRITE,&view);
> > CHKERRQ(ierr);
> > ierr = DMGetCoordinates(da_nodes,&v1); CHKERRQ(ierr); // borrowed
> reference
> > ierr = VecView(coord,view);CHKERRQ(ierr);
> >
> > Then, I realize that if I create a vector with DMCreateGlobalVector and
> > then copy in it the coordinate from DMGetCoordinates, the size remains
> > unchanged (in the visualization) and just the number of elements along
> the
> > direction change (when I modify M,N,P).
> >
> > ierr =
> >
> PetscViewerVTKOpen(PETSC_COMM_WORLD,"nodes_coord.vts",FILE_MODE_WRITE,&view);
> > CHKERRQ(ierr);
> > ierr = DMGetCoordinates(da_nodes,&v1); CHKERRQ(ierr); // borrowed
> reference
> > ierr = DMCreateGlobalVector(da_nodes,&coord); CHKERRQ(ierr);
> > ierr = VecCopy(v1,coord); CHKERRQ(ierr);
> > ierr = VecView(coord,view);CHKERRQ(ierr);
> >
> > *There is something wrong with PetscViewerVTKOpen or it's just the
> approach
> > that I used?*
> >
> > Kind regards.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20200224/a873653e/attachment.html>
More information about the petsc-users
mailing list