← Back to team overview

dolfin team mailing list archive

Re: [HG DOLFIN] Comment out reaction ODE demo. Gives error when run.

 

>> On Thu, Jul 09, 2009 at 08:20:54AM +0100, Garth N. Wells wrote:
>>>
>>>
>>> Anders Logg wrote:
>>> > On Thu, Jul 09, 2009 at 08:05:42AM +0100, Garth N. Wells wrote:
>>> >>
>>> >> Anders Logg wrote:
>>> >>> On Thu, Jul 09, 2009 at 12:14:14AM +0200, DOLFIN wrote:
>>> >>>> One or more new changesets pushed to the primary dolfin
>>> repository.
>>> >>>> A short summary of the last three changesets is included below.
>>> >>>>
>>> >>>> changeset:   6458:8dacb335c9825380a2e614f5de2ae89f79131995
>>> >>>> tag:         tip
>>> >>>> user:        "Garth N. Wells <gnw20@xxxxxxxxx>"
>>> >>>> date:        Wed Jul 08 23:13:53 2009 +0100
>>> >>>> files:       demo/ode/reaction/cpp/main.cpp
>>> >>>> description:
>>> >>>> Comment out reaction ODE demo. Gives error when run.
>>> >>> What happens when you run it? Same as for the buildbot?
>>> >>>
>>> >>>   terminate called after throwing an instance of
>>> 'std::runtime_error'
>>> >>>   what():  *** Assertion (e1 != -1) [at
>>> >>>   dolfin/ode/MultiAdaptiveTimeSlab.cpp:926 in cg_feval()]
>>> >>>
>>> >>> This does not happen for me. It works fine and it's not because I
>>> >>> don't trigger assertions, I checked.
>>> >>>
>>> >>> Any special configuration you are using? I'm running without GMP.
>>> >>>
>>> >> It fails with GMP and works with GMP.
>>> >
>>>
>>> I was a bit hasty - fails with GMP and works without GMP.
>>>
>>> Garth
>>
>> ok, most likely some floating-point comparison that fails.
>>
>> I'll ask Benjamin Kehlet to look at it or fix it myself later
>> otherwise.
>
The problem is that in the reaction demo a number of real variables are
declared in main before the ode object is created.The precision of these
variables are incorrect since GMP hasn't been initialized at that time.
We need to initialize precision in GMP by calling mpf_set_default_prec()
before the first real is declared. We now do this in the constructor of
class GMPObject which ODE inherits.
The only way (I can think of) ensure absolutely, is to wrap class real and
check in the constructor, but I guess the overhead by checking this every
time a real is declared is unacceptable.
Another suggestion is to do the initalization in a function
dolfin::set_precision(uint prec) and force the user to call this function.
We can check that this has been done when an ode object is created and
otherwise give an error message. The documentation and error message must
state clearly  that this must be done _before_ creating any real
variables. The bad thing with such a solution is that the same user code
will not run both with and without GMP enabled, since we force the user to
call set_precision, which doesn't make sense when running with the normal
(double) precision.
Anders has suggested making this a parameter "floating-point precision" in
Dolfin, but I can't see what should then trigger the call to
mpf_set_default_prec() before any reals are declared.

Benjamin



Follow ups

References