On Sun, Nov 27, 2011 at 01:44, Aron Ahmadia <aron.ahmadia at kaust.edu.sa>wrote:
> qbc is a multi-dimensional, Fortran ordered numpy array > Why is it a separate array instead of the one inside of the local vector? Well, let's just think about what actually happens. > # METHOD 1 > > # with fset(self,q) defined as follows: > def fset(self,q): > self.gqVec.setArray(q.reshape([-1], order = 'F')) > This is memcpy > > self.q = qbc[:,mbc:-mbc,mbc:-mbc] > This will do another copy to turn the view into contiguous storage that can be passed on. Note: I think PyClaw's use of fset for setting elements of an array is confusing since the call site looks like it should have different semantics than it does. > > # METHOD 2 > > self.lqVec.placeArray(qbc.reshape([-1], order = 'F')) > I think/hope this does no copy on the Numpy side. > self.q_da.localToGlobal(self.lqVec,self.gqVec) > This updates the ghost values without an intermediate copy. > self.lqVec.resetArray() > > # METHOD 3 > > self.lqVec.placeArray(qbc) > This is the same as before, right? > self.q_da.localToGlobal(self.lqVec,self.gqVec) > self.lqVec.resetArray() > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20111127/6ca08f5e/attachment.html>