<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: arial,helvetica,sans-serif; font-size: 12pt; color: #000000'>Understood!<br>Thanks,<br><br>Marco<br><br><hr id="zwchr"><div style="color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>Da: </b>"Barry Smith" <bsmith@mcs.anl.gov><br><b>A: </b>"Marco Cisternino" <marco.cisternino@optimad.it><br><b>Cc: </b>"Matthew Knepley" <knepley@gmail.com>, petsc-users@mcs.anl.gov<br><b>Inviato: </b>Lunedì, 19 gennaio 2015 17:38:34<br><b>Oggetto: </b>Re: [petsc-users] customized MatMult<br><br><br>> On Jan 19, 2015, at 10:09 AM, Marco Cisternino <marco.cisternino@optimad.it> wrote:<br>> <br>> Thank you Matthew,<br>> If I have understood:<br>> - I have to pass to myMatMult global vecs. And Vec created with VecGhostCreate are global, right?<br>> - In myMatMult I use VecGetArray, I store my result in the associated c-array, I call VecRestoreArray and the global vec is done! Right?<br>> - If I re-use VecGetArray/VecRestore array, ghosted locations in the c-array are updated, right?<br><br>   VecGet/RestoreArray() does not trigger updating ghost points. You need to use VecGhostUpdateBegin/End() see the manual page to update the ghost points.<br><br>  barry<br><br><br><br>> I'm sorry about confusion and thanks, again.<br>> <br>> Marco<br>> <br>> <br>> <br>> --<br>> -----------------------------------------------<br>> Marco Cisternino, PhD<br>> Software Developer<br>> OPTIMAD Engineering s.r.l.<br>> Via Giacinto Collegno 18<br>> 10143 Torino - Italy<br>> www.optimad.it<br>> marco.cisternino@optimad.it<br>> +39 011 19719782<br>> -----------------------------------------------<br>> <br>> Da: "Matthew Knepley" <knepley@gmail.com><br>> A: "Marco Cisternino" <marco.cisternino@optimad.it><br>> Cc: petsc-users@mcs.anl.gov<br>> Inviato: Lunedì, 19 gennaio 2015 16:40:28<br>> Oggetto: Re: [petsc-users] customized MatMult<br>> <br>> On Mon, Jan 19, 2015 at 9:28 AM, Marco Cisternino <marco.cisternino@optimad.it> wrote:<br>> Good morning,<br>> 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).<br>> <br>> 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.<br>> <br>> Second question: if I have to, how? <br>> Let's say I state:<br>> ierr = myMatMult(A,x,y);<br>> and x has been built out of myMatMult with VecGhostCreate.<br>> How do I update ghost elements of y in myMatMult? VecGhostUpdateBegin/VecGhostUpdateEnd in myMatMult?<br>> <br>> Any hints would be appreciated.<br>> <br>> There is some confusion here about the spaces that Vecs represent. Vecs in the solver are globally<br>> assembled vectors, which come from the "global" space. Vecs used in calculated integrals, differences,<br>> etc. for assembly often have ghost entries. We will say that these come from the "local" space.<br>> <br>> MatMult takes in a global Vec x and returns a global Vec y.<br>> <br>>   Hopefully that is clear,<br>> <br>>      Matt<br>>  <br>> Thanks for you advices in advance.<br>> <br>> Bests,<br>> <br>> Marco<br>> <br>> <br>> <br>> -- <br>> What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>> -- Norbert Wiener<br><br></div><br></div></body></html>