[petsc-users] normalization of a vector

likunt at caltech.edu likunt at caltech.edu
Thu May 8 11:08:05 CDT 2014


Dear Petsc developers,

I have a vector V={u1, u2, u3, v1, v2, v3}. I need to normalize each 3d
vector  and reset V, i.e.

V={u1/|u|, u2/|u|, u3/|u|, v1/|v|, v2/|v|, v3/|v|},
with |u| and |v| denotes the magnitudes of {u1,u2,u3} and {v1,v2,v3}.

I tried

VecGetValues(V, 3, col, val);
normalization of val;
VecSetValues(V, 3, col, val, INSERT_VALUES);

but I got the error message

PETSC ERROR: Object is in wrong state!
PETSC ERROR: You have already added values; you cannot now insert!

Is there any fast way to do that? Thanks.




More information about the petsc-users mailing list