#98: ZeroDivisionError for CellTerms when asling for coeff,getOld()
-------------------+--------------------------------------------------------
Reporter:  wd15    |       Owner:      
    Type:  defect  |      Status:  new 
Priority:  1       |   Component:  None
 Version:          |    Severity:  Bugs
Keywords:          |  
-------------------+--------------------------------------------------------
 The code below throws a !ZeroDivisionError. This is due to the
 !ImplicitSourceTerm, being
 a !CellTerm, calling getOld() on its coefficient. The coefficient's old
 value cannot be
 evaluated. See code below:

 {{{

 from fipy import Grid1D, CellVariable
 mesh=Grid1D(nx=2)

 from fipy.variables.cellVariable import CellVariable
 phase = CellVariable(mesh=mesh, hasOld=1)
 phase.setValue(1)
 coeff = (2 / (phase > 0)) * 5

 from fipy import TransientTerm, ImplicitSourceTerm
 eq = TransientTerm() + ImplicitSourceTerm(coeff)
 ## coeff.getOld() ## throws a ZeroDivisionError if uncommented (it should
 do!)

 eq.solve(phase) ## throws a ZeroDivisionError error
 }}}

 !CellTerm should not be calling getOld() for an !ImplicitSourceTerm. The
 remedy may be to
 not build all the keys in self.coeffVectors in !CellTerm, but only those
 with nonZero
 or nonNone weights.

-- 
Ticket URL: <https://matdl-osi.org/fipy/ticket/98>
FiPy <http://www.ctcms.nist.gov/fipy>
A Finite Volume PDE Solver Using Python


Reply via email to