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.]


> 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

Reply via email to