← Back to team overview

dolfin team mailing list archive

Re: [Question #152508]: division in forms

 

On 12 April 2011 11:53, Neilen Marais
<question152508@xxxxxxxxxxxxxxxxxxxxx>wrote:

> Question #152508 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/152508
>
> Neilen Marais posted a new comment:
> It seems to be related to the
>
>  from __future__ import division
>
> statement. The following doesn't work:
>
> from __future__ import division
>
> import dolfin as dol
> from dolfin import dot, curl, inner, dx
>
> # Define mesh
> mesh = dol.UnitCube(1,1,1)
> material_func_space = dol.FunctionSpace(mesh, 'DG', 0)
> mu_r = dol.Function(material_func_space)
> mu_r.vector()[:] = 1.
>
>
> # Define function space
> order = 3
> V = dol.FunctionSpace(mesh, "Nedelec 1st kind H(curl)", order)
>
> # Define basis and bilinear form
> u = dol.TrialFunction(V)
> v = dol.TestFunction(V)
>
> s = dot(curl(v), curl(u))/mu_r*dx            # Stiffness form
>
>
> But if you comment out the from __future__ statement it does work.


I have commited a fix for this in the development version of UFL. When
future division is enabled, __div__ is replaced with __truediv__ and
__floordiv__. UFL now handles __div__ and __truediv__ the same way, and
throws an error on __floordiv__ which is not supported.

For future bug reports, pasting the error you get instead of "it doesn't
work" is appreciated.

Martin

References