Sorry, there are some errors in my previous email and please refer to this one instead.

-------- Original Message --------
Subject: Re: How to define such cell variables in FiPy?
Date: Tue, 17 Oct 2006 12:01:33 -0400 (EDT)
From: hzhatlboro <[EMAIL PROTECTED]>
Reply-To: [email protected]
To: Multiple recipients of list <[email protected]>
References: <[EMAIL PROTECTED]> <[EMAIL PROTECTED]>

On 16/10/2006 21:52 Jonathan Guyer wrote the following:
> On Oct 15, 2006, at 9:47 PM, hzhatlboro wrote:
>> Hi, could you suggest a small piece of code to define such cell 
>> variables in FiPy?  Suppose that we have N cell variables phi_i, i=1, 
>> 2, ..., N, and we want to define another set of cell variables s_i in 
>> such a way that:
>> s_i at a nodal point of the grid is defined as s_i=1, if either phi_i 
>> at the nodal point or phi_i at any one of the four nearest 
>> neighboring nodal points is nonzero, and otherwise as s_i=0.  Thanks 
>> for your time!  Regards, hzhatlboro
> 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...

> FiPy's just not designed to work that way. Nonetheless,
> s_i = (phi_i != 0) | (phi_i.getGrad().getMag() != 0)
> should accomplish what you've asked.

Thanks for this!

> 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 meshes?

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. 2, 3, and 5?

>>> 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, ...?

Thanks for your support!

Regards,
hzhatlboro



Reply via email to