On Oct 15, 2006, at 9:47 PM, hzhatlboro wrote:
Hi, could you suggest a small piece of code to define such cell
variables in FiPy? Suppose that we have N cell variables phi_i,
i=1, 2, ..., N, and we want to define another set of cell variables
s_i in such a way that:
s_i at a nodal point of the grid is defined as s_i=1, if either
phi_i at the nodal point or phi_i at any one of the four nearest
neighboring nodal points is nonzero, and otherwise as s_i=0.
Thanks for your time! Regards, hzhatlboro
It's probably better in the long run to focus on what you're trying
to achieve mathematically, rather than trying to manipulate things on
a cell-by-cell basis. FiPy's just not designed to work that way.
Nonetheless,
s_i = (phi_i != 0) | (phi_i.getGrad().getMag() != 0)
should accomplish what you've asked.
Realize that FiPy is not designed with the assumption of a Cartesian
grid. There may not be exactly four nearest neighbors. One cell might
have three and another might have eighty-two.