Thanks Daniel,
ok so I can generate a function to do it but it is quite slow :
def interface(phi):
tmp = CellVariable(name="interface", mesh=mesh,value=0.,hasOld=1)
for i in range(len(phi._cellInterfaceFlag)):
if phi._cellInterfaceFlag[i]==1:
tmp[i]=1
return tmp
I tried to implement your class idea, but I am not sure with the syntax :
this doesn't seem to work :
class classeinterface(CellVariable):
def _calcValue(self,phi):
for i in range(len(phi._cellInterfaceFlag)):
if phi._cellInterfaceFlag[i]==1:
self[i]=1
return self
Interface_Variable = CellVariable(name="InterfacecellvvariableI",
mesh=mesh,value=0.,hasOld=1)
Interface_Variable=classeinterface(phi)
On Mon, Oct 17, 2011 at 4:43 PM, Daniel Wheeler
<[email protected]>wrote:
> On Fri, Oct 14, 2011 at 10:44 AM, Julien Derr <[email protected]>
> wrote:
> > Hi everyone,
> >
> > here is my technical question of the day ...
> >
> > phi is a DistanceVariable
> >
> > type(phi)
> > Out[39]: <class
> >
> 'fipy.models.levelSet.distanceFunction.distanceVariable.DistanceVariable'>
> >
> > if I define I=phi._cellInterfaceFlag
> >
> > it gives me an array.
> >
> > In [41]: I
> > Out[41]: array([0, 0, 0, ..., 0, 0, 0])
> >
> > In [42]: type(I)
> > Out[42]: <type 'numpy.ndarray'>
> >
> >
> > is it possible to get directly a Cellvariable ?
>
> Not really. You can use it to set the value of a cell variable.
> Another option is to create a cell variable class with a calcValue
> method that uses _cellInterfaceFlag to update its own value and also
> requires phi. It will then update whenever phi changes.
>
> --
> Daniel Wheeler
>
> _______________________________________________
> 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]