Hi, First I'm sorry for confusion. I should share both versions (slow one and mine) but only share last version. But before that explaining problem domain might be helpful for smoothing confusion away.
I'm working on tumor modelling. The code I sent is the part which calculates oxygen diffusion in a tissue with 4 boundaries (they represent blood veins). Oxygen diffusion calculated on this module but based on each cells oxygen consumption. The function "myFunc" will call lots of complicated functions that calculates oxygen consumption for each living cell. But for the sake of simplicity in this phase I assume each cell has a static consumption. This consumption is represented by source term. At the end I'll have a consumption matrix for each time step like; "at time step t cell at (x,y) has 0.00001 mol oxygen consumption" and so on. So at first i think that I should pass x and y to my function at each time step but it makes the code slower so I decided calculate cordinates with "nx" and "dx" parameters in the future. itertools.chain -> list business was used for setting source matrix the source term because I think an array in a CellVariable is 1d array (as in the phi variable) and I should convert it from 2d to 1d. The first code which I mentioned as slow and forget to add is here: http://pastie.org/6642897 I hope I can make thing clear. Again sorry for mess and thanks for your help. Best Regards, Serbulent 2013/3/20 Jonathan Guyer <[email protected]>: > > On Mar 20, 2013, at 9:51 AM, Daniel Wheeler wrote: > >> On Wed, Mar 20, 2013 at 5:57 AM, Serbulent UNSAL <[email protected]> >> wrote: >> Dear Dan and Raymond, >> >> Thanks for your help to both. After your suggestions I review my code. >> But changing X and Y like >> >> X = mesh.x >> Y = mesh.y >> >> makes the code seriously slow. >> >> I'm a little confused. The variables "X" and "Y" don't appear to be used >> after lines 34 and 35 so how can it have any influence on the code >> efficiency? > > I think at this point we need to know what `source` really looks like and > where it comes from. If it's calculated, there are definitely better ways to > calculate it, as Daniel already showed. If it's looked up from some external > input, then we need to know exactly how that input is structured. Regardless, > I can't imagine any good reason to do all of that itertools.chain -> list > business. > > > _______________________________________________ > fipy mailing list > [email protected] > http://www.ctcms.nist.gov/fipy > [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ] _______________________________________________ fipy mailing list [email protected] http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
