[petsc-users] Behavior of PetscViewerVTKOpen

Emmanuel Ayala juaneah at gmail.com
Mon Feb 24 16:50:53 CST 2020


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.

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/ac579e5f/attachment.html>


More information about the petsc-users mailing list