On Thu, Oct 9, 2008 at 11:52 AM, Angus Hendrick
<[EMAIL PROTECTED]> wrote:
> In the spirit of keeping things easy to follow, I've rembedded below your
> answer/questions.
>
>>> Retreating to more mundane topics, I'm solving the heat equation on a
>>> grid of discontinuous conductivities. Though I initially thought of the
>>> problem as having a conductivity in every cell, I realized that this is only
>>> a "shadow" of the problem as it is solved by FiPy, since the cell variables
>>> are converted to face variables. To make sure I had control over this
>>> process, I went ahead and explicitly created a FaceVariable conductivity and
>>> used the getHarmonicFaceValue (vice getArithmeticFaceValue) to convert my
>>> CellVariable conductivities into the appropriate FaceVariable values.
>>
>> Why are you explicitly creating a FaceVariable? The method
>> getHarmonicFaceValue will return a FaceVariable that updates itself whenever
>> the CellVariable values change. Everything is updated implicitly.
>
> I created a face variable just to have a place to stick the results. I
> think your point is that wherever I use that new variable, I could instead
> put the getHarmonicFaceValue call on the original cell variable. This
> avoids having them get out of sync. That seems a better way to go and I'll
> try that instead for the future.
I don' think you need to create a FaceVariable as a place to stick the
results. You already have a FaceVariable when you call
getHarmonicFaceValue that will always be in sync. Look at the
following.
>>> from fipy import *
>>> m = Grid1D(nx=10)
>>> v = CellVariable(mesh=m, value=m.getCellCenters()[0])
>>> f = v.getHarmonicFaceValue()
>>> print f
[ 0.5 0.75 1.875 2.91666667 3.9375 4.95
5.95833333 6.96428571 7.96875 8.97222222 9.5 ]
>>> v[2] = 0
>>> print f
[ 0.5 0.75 0. 0. 3.9375 4.95
5.95833333 6.96428571 7.96875 8.97222222 9.5 ]
f is the FaceVariable and whenever v changes f will implicitly know.
That goes for every other variable quantity, including all unary
operators, binary operators and slices.
> As an aside, I've seen in several of these e-mail exchanges questions to
> users about "why are they using FaceVariables," and I think part of the
> answer is that the manual sort of points you down this road. In particular,
> I guess that's how I interpreted the discussion on page 51 of version 1.2 of
> the manual in FAQ 6.6. I now note that in the later examples calls to
> getHarmonicFaceValue are demonstrated. However, I never got that far into
> the examples, just far enough to be dangerous.
Things have changes quite a bit since the last manual. It's our fault
for not getting it together and releasing a new version with updated
docs. Basically, you should be able to use fipy without ever having to
use FaceVariables. It is only when you need something other than
arithmetic averaging or use a function for coefficient values that
requires an alternate ordering of the interpolations that
FaceVariables should be necessary.
> Sorry, this is horribly explained. The core of the confusion I'm generating
> is that I'm confusing conductance and conductivity. What I want to show are
> conductances, which should be the face value conductivity times the face
> width divided by the distance between the adjoining cell centers. Is that
> correct?
You could plot a vector field of the conductance (or flux) maybe.
>>> from fipy import *
>>> m = Grid2D(nx=10, ny=10)
>>> x, y = m.getCellCenters()
>>> T = CellVariable(mesh=m, value=x * y)
>>> k = 1
>>> vi = make(m._getFaceNormals() * k * m._getFaceAreas() *
T.getFaceGrad().dot(m._getFaceNormals()))
>>> vi.plot()
The vector plot make look a little weird. The vectors probably need to
be scaled correctly.
--
Daniel Wheeler