On Oct 17, 2006, at 12:01 PM, hzhatlboro wrote:


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.
Good comments and thank you! I am rushing to get one thing working at the moment...

I understand, but asking low-level questions is almost never an efficient way to get things working. The answers to low-level questions tend to be things like "yes" or "12" or "banana", which may not prove too useful for you. If you tell us what you *really* want to achieve, we can almost certainly save both you and us a great deal of wasted time.


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.
Could you explain this a little bit further? In particular, the case that one cell has "eighty-two" neighbors. Are your referring to unstructured mesh?

Yes, unstructured meshes. "Eighty-two" is a bit of an exaggeration, but FiPy is designed throughout to deal with unstructured meshes and so it does not know a priori how many neighbors there are. There are some efficiency shortcuts for structured meshes, but you should not generally assume that you know what the layout of the mesh is.


Two more question, not related to this message, though. On page 170 of "Programmer's reference" v1.1, you presented one example on how to override the values of particular cells by using "mesh.getCells()", i.e.:-
>>>v1.setValue(1, cells=mesh.getCells()[2:])
Could you give some examples in the cases that, for example, I only want to replace the value of cell No. 2, or the values of cell No. 3, 4, and 5?

"[2:]" simply means element 2 and all subsequent elements. To specify a single item:

        >>>v1.setValue(1, cells=mesh.getCells()[2])
        >>>v1.setValue(1, cells=mesh.getCells()[3])
        >>>v1.setValue(1, cells=mesh.getCells()[4])
        >>>v1.setValue(1, cells=mesh.getCells()[5])

Note that you will get a DeprecationWarning if you use "cells=". The "where=" syntax is always superior in our experience because it allows you to express what you really mean, rather than worrying about an implementation detail of a particular mesh (such as the ID number of a particular cell). In a future version of FiPy, "cells=" will probably be removed, and it certainly should not be used in any of our examples.


>>> x=mesh.getCellCenters()[...,0]
By issuing the above command, I should be able to get the x coordinates of the centers of the cells. The question is: does the sequence of x follow the sequence of the cell numbers, or are x [0], x[1], x[2], ..., the coordinates of the centers of cell No. 0, 1, 2, ...?

Yes, they are in the same order. There is no guarantee, however, that the cell numbers will be laid out in any predictable order. We reserve the right to change the mesh ordering at any time, either for efficiency or out of simple vindictiveness.



Reply via email to