Re: Setting CellVariable values

2019-04-10 Thread Guyer, Jonathan E. Dr. (Fed) via fipy
> On Apr 10, 2019, at 11:12 AM, Dario Panada wrote: > > In my case, as I just have only one dimension, using sourceGrid.value[i] or > sourceGrid[...,i] should be equivalent though? Yes ___ fipy mailing list fipy@nist.gov

Re: Setting CellVariable values

2019-04-10 Thread Dario Panada
Thanks, makes sense. In my case, as I just have only one dimension, using sourceGrid.value[i] or sourceGrid[...,i] should be equivalent though? On Tue, Apr 9, 2019 at 3:32 PM Guyer, Jonathan E. Dr. (Fed) via fipy < fipy@nist.gov> wrote: > > On Apr 8, 2019, at 6:38 PM, Dario Panada wrote: > > >

Re: Setting CellVariable values

2019-04-09 Thread Guyer, Jonathan E. Dr. (Fed) via fipy
> On Apr 8, 2019, at 6:38 PM, Dario Panada wrote: > DP: I guess what confuses me here is the [..., i] syntax on the CellVariable > object thought. FiPy is built on NumPy. `...` or Ellipsis means "all the indices except for the one specified". FiPy stores cells in the last index of the

Re: Setting CellVariable values

2019-04-08 Thread Dario Panada
On Mon, Apr 8, 2019 at 11:22 PM Guyer, Jonathan E. Dr. (Fed) via fipy < fipy@nist.gov> wrote: > > > > On Apr 8, 2019, at 4:09 PM, Dario Panada wrote: > > > > DP: That would be diffusion of solubles from blood vessels (endothelial > cells). Specifically, glucose or oxygen. It wouldn't change

Re: Setting CellVariable values

2019-04-08 Thread Guyer, Jonathan E. Dr. (Fed) via fipy
> On Apr 8, 2019, at 4:09 PM, Dario Panada wrote: > > DP: That would be diffusion of solubles from blood vessels (endothelial > cells). Specifically, glucose or oxygen. It wouldn't change significantly be > increasing it to a 40x40x40 grid, you'd just be simulating a larger section > of

Re: Setting CellVariable values

2019-04-08 Thread Guyer, Jonathan E. Dr. (Fed) via fipy
Martin - That's interesting that `u.value.reshape(Nz,Ny,Nx)` gives you a view on the CellVariable's value. I'd say it's not 100% reliable that it always will, but it probably will. The result is certainly easier to read than juggling around with `ravel_multi_index`. - Jon > On Apr 8, 2019,

Re: Setting CellVariable values

2019-04-08 Thread Guyer, Jonathan E. Dr. (Fed) via fipy
> On Apr 8, 2019, at 11:30 AM, Dario Panada wrote: > I two initial numpy grids (n*n*n) where each value corresponds to a > source/sink. Eg: Given my source grid and coordinates (1,2,3) having value 5, > I want to set such value as a source in FiPy. That wasn't my question. When you publish

Re: Setting CellVariable values

2019-04-08 Thread Dario Panada
Dear Martin, Many thanks for your message. I think your approach is not too dissimilar from mine, but you are accessing *.value* of CellVariable whereas I am accessing *._array*. I have no problem switching to that, I'd just like confirmation that we can directly set the values by modifying the

Re: Setting CellVariable values

2019-04-08 Thread Martinus WERTS
Dear Dario, I am currently using Fipy for a slightly different diffusion-reaction problem. I use a CellVariable on the same grid for the (spatially-dependent) rate constant. One can set its values in a "numpy-vectorized" fashion by accessing the "value" property of the CellVariable. By

Re: Setting CellVariable values

2019-04-08 Thread Dario Panada
Hello, Many thanks for your reply. Yes, let me provide a bit more context. I two initial numpy grids (n*n*n) where each value corresponds to a source/sink. Eg: Given my source grid and coordinates (1,2,3) having value 5, I want to set such value as a source in FiPy. Currently I am dong that by,

Re: Setting CellVariable values

2019-04-08 Thread Guyer, Jonathan E. Dr. (Fed) via fipy
Iterating over a mesh with a Python `for` loop is, as you've found, an incredibly inefficient way to do things. FiPy, like numpy it relies on, is intended to be used with vectorized operations. As far as your approach, things that start with `_` in Python are internal implementation details