Dear all,

I have a question not too unrelated to this one. Let's say I have a 2D
numpy array and I want to assign its value to a cell variable defined
over a 2D mesh of the same dimensions. Is there any simple way to do
that.

n = 5
mesh = Grid2D(nx = n, ny = n)
k = rand(n,n)
phi = CellVariable(mesh)
phi.value = k ????

It happens a lot of time in our work. For instance, when we read a
permeability or porosity field from a file generated by a geological
model.

Kind regards,
Ali

On Thu, 2012-11-29 at 08:29 -0500, Jonathan Guyer wrote:
> On Nov 28, 2012, at 5:15 PM, Adrian Jacobo wrote:
> 
> >  I'm solving an equation in 3d and I need to calculate the integral of the 
> > field. What is the most convenient/fast way of doing this?
> 
> 
> int = var.cellVolumeAverage * var.mesh.numberOfCells
> 
> 
> >  A related question: how can I access individual points of the field? Right 
> > now, to access the point C(x,y,z) I'm doing C(((x,),(y,),(z,))), where C is 
> > a CellVariable over a Grid3d mesh. This seems cumbersome (an I don't fully 
> > understand the notation, I just found it in an example). Is there a cleaner 
> > way of doing it?
> 
> The C(points) notation is intended to return the value of C at multiple 
> points. You specify the points with a list of lists (or a tuple of tuples, as 
> you have done): 
> 
> [[x1, x2, x3, ...],
>  [y1, y2, y3, ...],
>  [z1, z2, z3, ...]]
> 
> For a single point, I guess this is a bit cumbersome, but the idea is that 
> it's symmetrical with things like var.cellCenters.
> _______________________________________________
> 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