Hi Daniel, Jonathan, many thanks for your replies -- both very useful to understand the philosophy behind fipy.
On 26 May 2011, at 15:31, Daniel Wheeler wrote: > > On Thu, May 26, 2011 at 2:11 AM, Fangohr H. <[email protected]> wrote: >> >> >> Hi again, >> >> here is my next query: at this point, I would like to modify the value of >> phi at a particular position r=(x,y). > > Try this. > >>>> from fipy import * >>>> m = Grid2D(nx=3, ny=3) >>>> v = CellVariable(mesh=m) >>>> r = (2.9, 2.9) >>>> v[argmin(sum((r - m.cellCenters)**2))] = 100. >>>> print v > [ 0. 0. 0. 0. 0. 0. 0. 0. 100.] > This is great, allows me to do what I want. Minor correction for others reading this: instead of >>>> v[argmin(sum((r - m.cellCenters)**2))] = 100. I had to use >>>> v[argmin(sum((r - m.getCellCenters())**2))] = 100. Does exactly what I want. Thanks again. Hans > >> My question is: is there a function that gives me the index for a given mesh >> and position r? > > No, but argmin allows you to do this fairly easily. > > -- > Daniel Wheeler >
