On Nov 12, 2013, at 11:59 AM, Daniel Wheeler wrote:
On Sat, Nov 9, 2013 at 3:01 PM, Richard Gillilan
<[email protected]<mailto:[email protected]>> wrote:
Benny: I'm confused by the extra step of going from CellVariable (vvel) to
FaceVariable (exteriorCoeff) in your example. Is it simply that your code
uses CellVariables for the vvel and ImplicitSourceTerm requires a
FaceVariable? I thought ImplicitSourceTerms were supposed to need
CellVariables.
"exteriorCoeff.getDivergence()" returns a CellVariable, but
"getDivergence" is a method of a FaceVariable so a FaceVarialbe is not
being passed to the ImplicitSourceTerm.
Yes, that makes sense now! Thanks. The divergence is a cell-based variable but
derived from face vectors. So if I were to zero out 5 of the 6 vectors on a
volume element, but keep the 6th (an exit face)
non-zero, then the divergence would represent the flux though that one face.
# create an "open" exit
# These terms didn't work for me:
#phi.faceGrad.constrain([0],ExitFaces) # no diffusion out exit
Perhaps the above would work bettter if "D" is set to zero on ExitFaces.
According to Sec 5.6.3 "Applying fixed flux boundary conditions", I should
constrain both the diffusion and convection values on the exit faces to zero.
>>> diffCoeff.constrain(0., mesh.exteriorFaces)
>>> convCoeff.constrain(0., mesh.exteriorFaces)
or in my case,
D.constrain(0.,ExitFaces)
exteriorCoeff.constain(0.,ExitFaces)
But Sec 5.6.4 "Applying outlet or inlet boundary conditions" implies that all
convection terms default to the no flux boundary condition anyway. So the
constrain term
for exteriorCoeff is not necessary.
I am suspecting the same is true for the diffusion term D. It must default to
no diffusion outside a boundary. At least that is the behavior I am seeing when
all walls are closed.
So that would explain why I don't need either of these terms.
I'm not quite sure what Benny had in mind with the faceGrad.constrain except
that it might be an equivalent way of preventing diffusion past a wall ...
should one need to explicitly do that.
#vel.setValue([[0],[0]], where=ExitFaces) # no convection out exit
exteriorCoeff = FaceVariable(mesh, value=vel, rank=1)
exteriorCoeff.setValue([[0],[0]], where=~ExitFaces)
eq = TransientTerm() ==
(DiffusionTerm(coeff=D)+VanLeerConvectionTerm(coeff=vel))+ImplicitSourceTerm(exteriorCoeff.divergence())
------ end of example ----
This example seems to do the right thing ... as near as I can tell.
Now, why should this work at all?
I'm not entirely sure what the above does. It may be that the source
cancels the outward flux from the convection term.
Yes, that's what I was hoping it would do ... and it makes sense now given how
divergence is being computed from the faces in exteriorCoeff for volume
elements on the outlet boundary.
My fluid is incompressible so that
vel.divergence = 0. What does setting exteriorCoeff.setValue to zero on the
ExitFaces do to the divergence?
Nothing because then "exteriorCoeff" would be zero everywhere. IN the
above, "exteriorCoeff" is not set to zero on the the "ExitFaces", it
is only set to zero on the non-exit faces ("~" is NOT in
numpy-array-like language).
Sorry, I was referring to the commented-out term:
#vel.setValue([[0],[0]], where=ExitFaces) # no convection out exit
But I'm guessing this term is not technically necessary (see above comments)
since it would be the default boundary condition already.
I think that the convection term includes
the outward flux, but that is being added back in by the source term.
There may or may not be a reason why this works better. I don't know
for sure
Thanks for all your useful comments!
Richard
--
Daniel Wheeler
_______________________________________________
fipy mailing list
[email protected]<mailto:[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 ]