[petsc-users] customized MatMult

Marco Cisternino marco.cisternino at optimad.it
Mon Jan 19 10:58:22 CST 2015


Understood! 
Thanks, 

Marco 

----- Messaggio originale -----

Da: "Barry Smith" <bsmith at mcs.anl.gov> 
A: "Marco Cisternino" <marco.cisternino at optimad.it> 
Cc: "Matthew Knepley" <knepley at gmail.com>, petsc-users at mcs.anl.gov 
Inviato: Lunedì, 19 gennaio 2015 17:38:34 
Oggetto: Re: [petsc-users] customized MatMult 


> On Jan 19, 2015, at 10:09 AM, Marco Cisternino <marco.cisternino at optimad.it> wrote: 
> 
> Thank you Matthew, 
> If I have understood: 
> - I have to pass to myMatMult global vecs. And Vec created with VecGhostCreate are global, right? 
> - In myMatMult I use VecGetArray, I store my result in the associated c-array, I call VecRestoreArray and the global vec is done! Right? 
> - If I re-use VecGetArray/VecRestore array, ghosted locations in the c-array are updated, right? 

VecGet/RestoreArray() does not trigger updating ghost points. You need to use VecGhostUpdateBegin/End() see the manual page to update the ghost points. 

barry 



> I'm sorry about confusion and thanks, again. 
> 
> Marco 
> 
> 
> 
> -- 
> ----------------------------------------------- 
> Marco Cisternino, PhD 
> Software Developer 
> OPTIMAD Engineering s.r.l. 
> Via Giacinto Collegno 18 
> 10143 Torino - Italy 
> www.optimad.it 
> marco.cisternino at optimad.it 
> +39 011 19719782 
> ----------------------------------------------- 
> 
> Da: "Matthew Knepley" <knepley at gmail.com> 
> A: "Marco Cisternino" <marco.cisternino at optimad.it> 
> Cc: petsc-users at mcs.anl.gov 
> Inviato: Lunedì, 19 gennaio 2015 16:40:28 
> Oggetto: Re: [petsc-users] customized MatMult 
> 
> On Mon, Jan 19, 2015 at 9:28 AM, Marco Cisternino <marco.cisternino at optimad.it> wrote: 
> Good morning, 
> I'm writing my MatMult function, but I don't know how to treat the ghost elements of the result vec. Let's say myMatMult(A,x,y). 
> 
> First question is: if I use my MatMult in a KSP to solve a linear system, do I have to update ghost elements in the result vec of MatMult?? Consider that any time the code enters myMatMult the vec x is copied in my container and the ghost of my container are updated. I made computation for matrix-vector and I copied the results in vec y, without considering ghost elements of y. 
> 
> Second question: if I have to, how? 
> Let's say I state: 
> ierr = myMatMult(A,x,y); 
> and x has been built out of myMatMult with VecGhostCreate. 
> How do I update ghost elements of y in myMatMult? VecGhostUpdateBegin/VecGhostUpdateEnd in myMatMult? 
> 
> Any hints would be appreciated. 
> 
> There is some confusion here about the spaces that Vecs represent. Vecs in the solver are globally 
> assembled vectors, which come from the "global" space. Vecs used in calculated integrals, differences, 
> etc. for assembly often have ghost entries. We will say that these come from the "local" space. 
> 
> MatMult takes in a global Vec x and returns a global Vec y. 
> 
> Hopefully that is clear, 
> 
> Matt 
> 
> Thanks for you advices in advance. 
> 
> Bests, 
> 
> Marco 
> 
> 
> 
> -- 
> 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/20150119/92a4e43f/attachment.html>


More information about the petsc-users mailing list