Here's an example. It's trivial, but it just demonstrates solving a
variable on one grid and then using that variable to set the value of
the diffusion coefficient for an equation on a different grid.
Obviously, if the domains don't overlap then you need to take care of
the mapping and interpolation between the grids.
~~~
from fipy import CellVariable, Grid1D, DiffusionTerm, Viewer, TransientTerm
nx = 100
dt = 1e-3
Lx = 1.0
steps = 1000
mesh0 = Grid1D(nx=nx, Lx=Lx)
mesh1 = Grid1D(nx=nx, Lx=Lx)
v0 = CellVariable(mesh=mesh0, value=0., hasOld=True)
v0.constrain(1e-1, where=mesh0.facesLeft)
v0.constrain(10., where=mesh0.facesRight)
v1 = CellVariable(mesh=mesh1, value=0., hasOld=True)
v1.constrain(0., where=mesh1.facesLeft)
diff_coeff = CellVariable(mesh=mesh1, value=0.)
eqn0 = TransientTerm() == DiffusionTerm()
eqn1 = TransientTerm() == DiffusionTerm(diff_coeff) + 1.
viewer = Viewer(v1)
for i in range(steps):
v0.updateOld()
v1.updateOld()
eqn0.solve(v0, dt=dt)
diff_coeff[:] = v0
eqn1.solve(v1, dt=dt)
viewer.plot()
input("stopped")
--
Daniel Wheeler