<div style="line-height:1.7;color:#000000;font-size:14px;font-family:arial">What the function of "restore the local form", <div>can i use VecDestroy to free the local form only;<br><br><br><br><br><div></div><div id="divNeteaseMailCard"></div><br><pre><br>ÔÚ 2013-08-15 19:13:52£¬"Jed Brown" <jedbrown@mcs.anl.gov> дµÀ£º
>¶¡ÀÏʦ <ztdepyahoo@163.com> writes:
>
>> I want to know
>> 1. What is the relationship between Vhat and LocalVhat. Is the
>> LocalVhat a copy of the Vhat plus the Ghost values. I think the
>> LocalVhat will consume more memeory than the Vhat, am i right?
>
>Logically, you should think of them as separate vectors. The global
>form contains only the global entries (non-overlapping partition) and
>the local form also contains the ghosted entries. If you want to
>operate strictly on the global entries, you can access the global form
>directly.
>
>Implementation-wise, the vectors share memory for the global part. This
>means that if you build a Krylov space with VecGhost, you have allocated
>storage for the ghosted entries for every Krylov vector, even though the
>algorithm will never use them. VecGhost is premature "optimization"
>("pessimization") in many cases, so consider just using a local work
>vector and performing a scatter from global to local. It's probably
>much cheaper than you think.
>
>> 2. can i direct call VecGetArrary to the Vhat if i do not operate on the ghost value.
>>
>>
>>
>> Vec Vhat;
>> Vec LocalVhat;
>> double* VhatVec;
>>
>> VecCreateGhost(PETSC_COMM_WORLD,aMesh->Nx*aMesh->Ny/Commsize,PETSC_DECIDE,aMesh->nghosts,&aMesh->ghosts[0],&Vhat);
>> VecGhostGetLocalForm(Vhat,&LocalVhat);
>
>Update, _then_ get the local form. Remember to restore the local form
>when you are done with it.
>
>> VecGhostUpdateBegin(Vhat,INSERT_VALUES,SCATTER_FORWARD);
>> VecGhostUpdateEnd(Vhat,INSERT_VALUES,SCATTER_FORWARD);
</pre></div></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>