> Your first case doesn't work because x = array([11,12,13]) is not an array of 
> rank-1 vectors; it's an array of rank-0 scalars.


This explanation did the trick for me.

>>> mesh.faceCenters.value
array([[ 0.25 ,  0.125,  0.375,  0.125,  0.125,  0.   ,  1.   ,  0.875,
         0.875,  0.75 ,  0.875,  0.625,  0.375,  0.5  ,  0.25 ,  0.125,
         0.625,  0.625,  0.375,  0.75 ,  0.625,  0.875,  0.5  ,  0.375,
         0.25 ,  1.   ,  0.   ,  0.75 ],
       [ 1.   ,  0.875,  0.875,  0.125,  0.375,  0.25 ,  0.75 ,  0.875,
         0.625,  0.   ,  0.125,  0.125,  0.625,  0.75 ,  0.5  ,  0.625,
         0.625,  0.875,  0.375,  0.5  ,  0.375,  0.375,  0.25 ,  0.125,
         0.   ,  0.25 ,  0.75 ,  1.   ]])

>>> numerix.nearest(mesh.faceCenters.value,[[.25],[.5]])
array([14])

>>> mesh.faceCenters.value[0][14], mesh.faceCenters.value[1][14]
(0.25000000000004186, 0.50000000000111045)

Beautiful! Thank you very much for the response,
Ryan Smith


On Jun 21, 2013, at 5:46 AM, Jonathan Guyer <[email protected]> wrote:

> 
> On Jun 20, 2013, at 1:22 PM, Ryan Smith <[email protected]> wrote:
> 
>> I don't understand the result of 18 being the index if the length of each 
>> component of mesh.cellCenters.value is 16. So, it seems the biggest problem 
>> here is that I don't fully understand the use of numerix.nearest(). But, if 
>> numerix.nearest did work, then I would have used numerix.take() to get the 
>> value of the velocity vector given the indices from numerix.nearest().
> 
> The purpose of numerix.nearest() is to "find the indices of `data` that are 
> closest to `points`". Both `data` and `points` are expected to be fields of 
> rank-1 vectors, such as returned by mesh.cellCenters.
> 
> Where is the scalar .3 closest to a field of 2D coordinates? I have no idea. 
> Apparently, it's at 18. FiPy is doing its best to answer a question it 
> doesn't understand.
> 
> Where is the coordinate [[.3], [.5]] closest to that same field of 
> coordinates? That I can answer. It's at mesh.cellCenters.value[..., 5], or 
> [[.25], [0.58333333]].
> 
> Your first case doesn't work because x = array([11,12,13]) is not an array of 
> rank-1 vectors; it's an array of rank-0 scalars.
> 
> 
> _______________________________________________
> fipy mailing list
> [email protected]
> http://www.ctcms.nist.gov/fipy
>  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
> 


_______________________________________________
fipy mailing list
[email protected]
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]

Reply via email to