On Thu, Feb 3, 2011 at 1:45 PM, Julien Derr <julien.d...@gmail.com> wrote: > Thanks Daniel,
Happy to help. > Indeed getting the value of the variable works great for arbitrary values. > but I am still a little bit lost I cannot manage to assign a new value for > my new variable. Strange. > I tried setValue but doesn't seem to work right. > > xc, yc = mesh.getCellCenters() > newphi = CellVariable(name = "solution variable", mesh = mesh, > value=0) > newphi.setValue(oldphi((xc,yc))) Does the following work for you? >>> from fipy import * >>> m = Grid2D(nx=2, ny=2) >>> x, y = m.getCellCenters() >>> v0 = CellVariable(mesh=m) >>> v1 = CellVariable(mesh=m, value=x * y) >>> v0.setValue(v1((x, y))) >>> print v0 [ 0.25 0.75 0.75 2.25] >>> v0.setValue(v1) >>> print v0 [ 0.25 0.75 0.75 2.25] > when I look at newphi, there are only zeros, it didn't take the values of > oldphi; isn't it supposed to do that with setValue ? What happens when you "print oldphi((xc,yc))"? Is it actually non zero and is it the same length as phi? You should also be able to do newphi.setValue(oldPhi) if they are the same length. -- Daniel Wheeler