On Jun 26, 2013, at 11:45 AM, Ianis Bernard <[email protected]> wrote:

> I noticed that when deleting the boundary conditions, the first element of 
> the faceGrad arrays was replaced by a 0. And I don't know how to keep the old 
> value.

.faceGrad is a calculated quantity, not stored. In the absence of constraints, 
the boundary gradient is zero.


> Moreover, I cannot explain why if the line 161 (printing the first value of 
> the faceGrad vector) is commented, the first value of the phi.faceGrad vector 
> is 0., whereas it is a positive value (equal to 20.949) if this same line is 
> not commented. That would mean that printing a value or not changes the 
> behavior of the following code, and seems weird to me.

That's a caching issue. FiPy caches values under some circumstances out of an 
attempt at efficiency. When dependencies change, the cached value is 
recalculated. In this case, deleting a constraint is not seen as a change in 
dependencies (it should be). The first print triggers a cache and this cached 
value is not removed when you remove the constraint.

If you add

   phi.faceGrad.dontCacheMe()

after 

   phi = fp.CellVariable(name=r"$\tilde{\phi}$", mesh=mesh,
        value=(5.*mesh.x/Lx),
        hasOld=True)

you will see that the value of phi.faceGrad no longer depends on whether it was 
previously printed.
       
 
Alternatively, call

  phi.faceGrad._markStale()

after deleting the constraints.
_______________________________________________
fipy mailing list
[email protected]
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]

Reply via email to