On Aug 11, 2008, at 10:09 AM, franck kalala wrote:

I have some difficult to set this boundary condition in the following program(in red) could any one help to set it?

#valueLeft=1.
#valueRight=0.

x=mesh.getCellCenters()[...,0]
valueLeft=phi.setValue(0, where=x < 0)
valueRight=phi.setValue(1, where=x > 0)

from fipy.boundaryConditions.fixedValue import FixedValue
BCs=(FixedValue(faces=mesh.getFacesRight(), value=valueRight),
    FixedValue(faces=mesh.getFacesLeft(), value=valueLeft))


There are two problems with this.

The first is that `setValue()` does not return a value, so `valueLeft` and `valueRight` are set to `None` in your script by the Python language.

The second is that the value passed to any of the BoundaryCondition objects has to have exactly the right shape. It can either be a single value, or it must have exactly the same shape as the number of faces that are being set. Even if `setValue()` did return a value, it would be a value over Cells, not over Faces, so it would still not be allowed here.


In this case

   valueLeft = 1.
   valueRight = 0.

   phi.setValue(valueLeft, where=x < 0)
   phi.setValue(valueRight, where=x > 0)

   BCs=(FixedValue(faces=mesh.getFacesRight(), value=valueRight),
        FixedValue(faces=mesh.getFacesLeft(), value=valueLeft))

should work.


Reply via email to