On May 25, 2011, at 9:01 AM, Hans Fangohr wrote:
> thank you for providing FiPy -- while we have only just started to use
> it and I am not ever sure we understand the basics sufficiently, it is
> clearly a powerful tool.
We hope you continue to find it useful.
>
> Here is a question to which I couldn't find the answer in the manual,
> examples, or by inspecting the variable and mesh classes:
We clearly need to do a better job of documenting this.
> Given a CellVariable that contains the solution of a (scalar) field
> phi (through an instance of the CellVariable class), I would like to
> know the value of phi at a particular position.
The CellVariable.__call__() operator provides this, such that
phi((x,y))
provides what you want. This works for both single points
phi((2.5, 3.2))
and sets of points
phi(((2.5, 7.8, 9.9),
(3.2, 1.7, 0.2)))
I see that the Sphinx tool that generates our documentation is omitting the
special Python methods like __call__. We'll have to figure out how to fix that.
In the meantime, you can find the documentation here:
http://matforge.org/fipy/browser/branches/version-2_1/fipy/variables/cellVariable.py#L159
> Custom code can be written to do this: for a regular mesh (as
> fipy.Grid2D would return) this is fairly straightforward, but for an
> irregular mesh this is a more expensive operation.
It can, indeed, be expensive. FiPy uses a full-factorial method that is
generally fast, but can be quite memory intensive, although regular grids use a
more expedient method that tends to be both fast and memory-friendly. Benny
Malengier has sent us a more memory friendly implementation for the general
case (for mesh concatenation, but it's the same issue), but we've not yet had a
chance to incorporate it, yet.
> I understand that this operation is rarely required
Not at all. It's not needed for every simulation, but it certainly comes up
regularly.