2011/9/1 Jonathan Guyer <gu...@nist.gov> > > > On Feb 11, 2011, at 9:43 AM, Benny Malengier wrote: > > > Hence I conclude I don't understand the code. > > > > I rewrote the code to what I can understand myself and to what I think it > is supposed to do, using the repeat function of fipy, which I think is more > correct that the resize and newaxis combination. > > I also added the chunk trick that was posted some days ago so as to > prevent to original memoryerror I wanted to avoid. I can now add the two 3D > meshes without a mem error, and it is actually quite fast which I was not > expecting as I am using chunks of only 10. > > To reduce memory further, I added a method to pass the vertices over > which to add, which is used when set, and otherwise exteriorFaces is used > like before (so the code was already adding only over the external edges). > > I've finally found the time to sit down and both understand the old > algorithm and what you provided. I've merged your changes to trunk and put > some comments at http://matforge.org/fipy/ticket/348. > > Many thanks for the contribution! >
Great to hear! Looking at the picture you uploaded, my main problem with how to know the size of the chunks, was tackled thoroughly. I was on euroscipy last week, and talked about a likewise algorithm to determine overlap of grains. Gave some slides about FiPy which drew some attention :-) Anyway, they advised to do a test with scipy.spatial (pdist function, or even ckdtree) to see if it is not faster for my use-case. For different meshes I don't think that would work however (as you don't want to compare with points of the same mesh). So, if you have a general function, submitting for inclusion in scipy.spatial is an option that could benefit many people. I refractored the code of my patch also as a more 'general' array procedure I use in another project: http://gitorious.org/stickproject/stickproject/blobs/master/src/lib/utils/arraycompare.py Main difference with the patch is: 1/repeat of second array outside of the loop so it is done only once 2/arrays as in scipy.spatial, meaning they are transposed from the ones in fipy. I'll look at your final commit and merge your improvements back in my project, and see if I did not find another optimization myself which could go back in fipy. Greetings, Benny