[petsc-users] about VecGetArray()

LikunTan tlk0812 at hotmail.com
Sat Jun 7 01:40:06 CDT 2014


Hello,
I defined the partition of Vector, which is not stored contiguously. Here is a part of my code. The total number of nodes is NODE*DOF. Before executing this following code, I defined LEN and an array NODENP[] to store the number of nodes and the list of nodes in each processor. I accessed the element using aM[node*DOF+j] and aM[i*DOF+j], but none of them gave me the correct answer. Your help is well appreciated.
**************************************************************VecCreate(PETSC_COMM_WORLD, &M);VecSetSizes(M, LEN*DOF, NODE*DOF);  
VecGetArray(M, &aM); 
for(int i=0; i<LEN; i++){    node=NODENP[i];    for(int j=0; j<DOF; j++)    {        aM[node*DOF+j] or aM[i*DOF+j] ?  //accessing the elements of M            }}VecRestoreArray(M, &aM); ********************************************************* 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140607/7c0701eb/attachment.html>


More information about the petsc-users mailing list