VecSetValue

Matthew Knepley knepley at gmail.com
Sat Feb 28 18:23:24 CST 2009


On Sat, Feb 28, 2009 at 6:19 PM, Yixun Liu <enjoywm at cs.wm.edu> wrote:

> I use VecSetValue in a loop and if I add some codes such as IO before
> the VecSetValue the output of the vector is correct. However if I remove
> the IO the output is wrong. It seems that the values are cached and need
> some time to be set.
>

1) It is unclear what the wrong behavior is.

2) This is also the a sign that memory might be corrupt somewhere else.

It is not possible to see what is wrong from your description, but I assure
you that nothing is wrong with that method. It is used millions of times
every day. Send a sample code with known output and I will run it.

  Matt


> Matthew Knepley wrote:
> > I cannot understand your question.
> >
> >   Matt
> >
> > On Fri, Feb 27, 2009 at 6:45 PM, Yixun Liu <enjoywm at cs.wm.edu
> > <mailto:enjoywm at cs.wm.edu>> wrote:
> >
> >     Hi,
> >
> >
> >      VecCreate(PETSC_COMM_WORLD,&solutionDisplacementVector);
> >
> >      VecSetSizes(solutionDisplacementVector,
> >     3*numOfVerticesOfOneProcessor,
> >     systemSize); //in this case 3*numOfVerticesOfOneProcessor==systemSize
> >      VecSetFromOptions(solutionDisplacementVector);
> >
> >
> >      VecDuplicate(solutionDisplacementVector,
> >     &weightedDisplacementVector);
> >
> >
> >     for(i = 0; i < systemSize; i++)
> >     {
> >     output weightedRealDisplacement[i] to file//with this code the
> >     values in
> >     weightedDisplacementVector are correct.
> >
> >     ...
> >     VecSetValue(weightedDisplacementVector, i,
> >     weightedRealDisplacement[i],
> >     ADD_VALUES);
> >     ...
> >
> >     }
> >
> >     VecAssemblyBegin(weightedDisplacementVector);
> >      VecAssemblyEnd(weightedDisplacementVector);
> >
> >     output weightedDisplacementVector to file to see its values
> >
> >
> >
> >     For simplicity I only use one processor. As I examine the values in
> >     weightedDisplacementVector and I found if  I add the output code
> >     in the
> >     for loop the values in weightedDisplacementVector are correct.
> Without
> >     it there is error.
> >
> >
> >     Thanks.
> >
> >     Yixun
> >
> >
> >
> >
> > --
> > What most experimenters take for granted before they begin their
> > experiments is infinitely more interesting than any results to which
> > their experiments lead.
> > -- Norbert Wiener
>
>


-- 
What most experimenters take for granted before they begin their experiments
is infinitely more interesting than any results to which their experiments
lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20090228/fad55600/attachment.htm>


More information about the petsc-users mailing list