This is probably a bad idea, but I want to set a boundary condition on an interior cell. Alternatively, I would just have a rectangular mesh with some of the nodes masked off (kind of like a step on one of the rectangle's sides). The problem with changing the mesh in this manner is that this boundary condition needs to move in time.

My first thought was to force a cell to a given value by repeatedly resetting its value inside the solution loop. But, since the diffusion terms use the face values (not cell values) in the solution, I'm not getting the value back. The next (bad) idea I had was to set the face values, but I didn't see a way of doing this.

Is there a way of setting a boundary condition on an interior cell?

Thanks,
-Tony

Test script:
~~~~~~~~~~~~~~~
from fipy import *

dt = 0.001
# material properties
D = 1.
c0 = 1.
c_sink = 0.
# spacial parameters
nx = ny = 3
dx = dy = 1.
mesh = Grid2D(dx=dx, dy=dy, nx=nx, ny=ny)
x, y = mesh.getCellCenters()
bottom_center = (x == 1.5) & (y == 0.5)

phi = CellVariable(name='concentration', mesh=mesh, value=c0)
phi.setValue(c_sink, where=bottom_center)
eq = TransientTerm() == ImplicitDiffusionTerm(coeff=D)

all_faces = mesh.getExteriorFaces()
BCs = (FixedFlux(faces=all_faces, value=0),)

for step in range(3):
    phi.setValue(c_sink, where=bottom_center)
    eq.solve(var=phi, boundaryConditions=BCs, dt=dt)
    # one of the cells should be 0 (c_sink value)
    print phi.reshape((ny, nx))

Reply via email to