[petsc-users] Normalize vectors
LikunTan
tlk0812 at hotmail.com
Sun May 11 20:07:17 CDT 2014
Dear Petsc developers,
I have a vector M which consists of a series of 3d vectors, and I want to reset M by normalizing each 3d vector. Here is my code:
/**********************************************************************VecGetArray(M, &aM); DMDAGetCorners(da, &xs, 0, 0, &xm, 0, 0); for(node=xs; node<xs+xm; node++){ mag=0.0; for(l=0; l<3; l++) { val[l]=aM[node*3+l]; mag=mag+val[l]*val[l]; } mag=sqrt(mag); for(l=0; l<user->NDOF; l++) { aM[node*3+l]=val[l]/mag; }}VecRestoreArray(M, &aM); VecAssemblyBegin(M);VecAssemblyEnd(M); VecView(M, PETSC_VIEWER_STDOUT_WORLD);**********************************************************************/
but I got the error at the last step:--------------------------------------------------------------------------mpiexec noticed that process rank 3 with PID 17156 on node compute-21-8.local exited on signal 6 (Aborted).--------------------------------------------------------------------------and if I commented out VecView, and used vector M for other operations, e.g.KSPSolve(ksp, M, b), I got "memory corruption" message. Your comment on this issue is well appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140512/7d692768/attachment.html>
More information about the petsc-users
mailing list