[petsc-users] local Vec to global Vec and global 3-D array

Roc Wang pengxwang at hotmail.com
Wed May 15 10:19:21 CDT 2013


 Hello, 

 1. I am trying to save the solution of a PDE for a 3-D geometry domain.  I used DM to manage the matrix and vector.
  The solution vector was converted to local 3D arrays on each process successfully. But there was errors when the functions DMLocalToGlobalBegin() and DMLocalToGlobalEnd() were called.
  
  I built the code by following the example in /petsc-3.3-p6/src/dm/examples/tutorials/ex3.c. The codes for this are as followings :

  /*Get the solution vec */
  ierr = KSPSolve(ksp,PETSC_NULL,PETSC_NULL);CHKERRQ(ierr);
  ierr = KSPGetSolution(ksp,&x);CHKERRQ(ierr);
  
  /* local 3d arrays */ 
  ierr = DMDAVecGetArray(da, x, &localArray3d ); CHKERRQ(ierr);

  /* global 3d array */ 
  ierr = DMCreateGlobalVector(da,&gsol3d);CHKERRQ(ierr);
  ierr = DMLocalToGlobalBegin(da,x,INSERT_VALUES,gsol3d);CHKERRQ(ierr);
  ierr = DMLocalToGlobalEnd(da,x,INSERT_VALUES,gsol3d);CHKERRQ(ierr);
 
 
 2.   I am trying to visualize the solution in a 3-D domain by using some software such as Tecplot. To my understand, I need to output the solution in the format of 3-D array. The vectors of KSP solution in PETSc are local vectors on each process. So they have to be assembled to a global vector and then converted to a 3-D global array.  I am not sure if my approach is a good way and if there is some functions in PETSc to output the global solutions directly?
      
Part of the error information when DMLocalToGlobalBegin() and DMLocalToGlobalEnd() were called 
  
[0]PETSC ERROR: [1]PETSC ERROR: [2]PETSC ERROR: --------------------- Error Message ------------------------------------
[3]PETSC ERROR: --------------------- Error Message ------------------------------------
[2]PETSC ERROR: [3]PETSC ERROR: --------------------- Error Message ------------------------------------
Nonconforming object sizes!
Nonconforming object sizes!
[2]PETSC ERROR: [3]PETSC ERROR: Vector wrong size 30 for scatter 60 (scatter forward and vector from != ctx from size)!
Vector wrong size 20 for scatter 45 (scatter forward and vector from != ctx from size)!
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20130515/a767b42a/attachment.html>


More information about the petsc-users mailing list