Rank analysis is wrong

Bug #997739 reported by Johan Hake
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SyFi
New
Undecided
Unassigned

Bug Description

from dolfin import *
parameters.form_compiler.name = "sfc"
mesh = UnitCube(5,5,5)
VV = VectorFunctionSpace(mesh,"Lagrange",1)
u = TrialFunction(VV)
v = TestFunction(VV)
Aij = diag(Constant((1,1,1)))
Delta = Identity( mesh.ufl_cell().geometric_dimension())
# Works but should not work...
assemble(inner(Aij*(grad(u)+Delta), grad(v))*dx)

Revision history for this message
Marie Rognes (meg-simula) wrote : Re: [Bug 997739] [NEW] Rank analysis is wrong

On 05/10/2012 08:18 PM, Johan Hake wrote:
> mesh = UnitCube(5,5,5)
> VV = VectorFunctionSpace(mesh,"Lagrange",1)
> u = TrialFunction(VV)
> v = TestFunction(VV)
> Aij = diag(Constant((1,1,1)))
> Delta = Identity( mesh.ufl_cell().geometric_dimension())
> # Does not work (but works with sfc)
> assemble(inner(Aij*(grad(u)+Delta), grad(v))*dx)
> # Works
> assemble(inner(Aij*grad(u), grad(v))*dx)

As far as I can see, your form has different ranks.
The error message then seems very correct.

--

Marie

Revision history for this message
Garth Wells (garth-wells) wrote :

On 10 May 2012 19:34, Marie Rognes <email address hidden> wrote:
> On 05/10/2012 08:18 PM, Johan Hake wrote:
>> mesh = UnitCube(5,5,5)
>> VV = VectorFunctionSpace(mesh,"Lagrange",1)
>> u = TrialFunction(VV)
>> v = TestFunction(VV)
>> Aij = diag(Constant((1,1,1)))
>> Delta = Identity( mesh.ufl_cell().geometric_dimension())
>> # Does not work (but works with sfc)
>> assemble(inner(Aij*(grad(u)+Delta), grad(v))*dx)
>> # Works
>> assemble(inner(Aij*grad(u), grad(v))*dx)
>
> As far as I can see, your form has different ranks.
> The error message then seems very correct.
>

And that would then make it an SFC bug ;).

Garth

> --
>
> Marie
>
> --
> You received this bug notification because you are a member of FFC Core
> Team, which is subscribed to FFC.
> https://bugs.launchpad.net/bugs/997739
>
> Title:
>  Rank analysis is wrong
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/ffc/+bug/997739/+subscriptions

Revision history for this message
Johan Hake (johan-hake) wrote :

On 05/10/2012 08:34 PM, Marie Rognes wrote:
> On 05/10/2012 08:18 PM, Johan Hake wrote:
>> mesh = UnitCube(5,5,5)
>> VV = VectorFunctionSpace(mesh,"Lagrange",1)
>> u = TrialFunction(VV)
>> v = TestFunction(VV)
>> Aij = diag(Constant((1,1,1)))
>> Delta = Identity( mesh.ufl_cell().geometric_dimension())
>> # Does not work (but works with sfc)
>> assemble(inner(Aij*(grad(u)+Delta), grad(v))*dx)
>> # Works
>> assemble(inner(Aij*grad(u), grad(v))*dx)
>
> As far as I can see, your form has different ranks.
> The error message then seems very correct.

grad(u).rank() == 2
Delta.rank() == 2
Aij.rank() == 2
(grad(u)+Delta).rank() == 2
(Aij*(grad(u)+Delta)).rank() == 2

Can you point our where it is wrong?

Johan

Revision history for this message
Marie Rognes (meg-simula) wrote :

There is a difference between tensor rank and form rank. You are printing
the tensor ranks. The form rank would be number of Arguments.
So, in your example:

  (grad(u) + Delta) * grad(v) = grad(u)*grad(v) + Delta*grad(v)

The first term on the right-hand side has form rank 2 (there is a TestFunction
and a TrialFunction involved) while the other has form rank 1 (just a TestFunction).

DOLFIN can only assemble (and FFC only generate code for) forms
in which all terms have the same (form) rank.
In short, you can't add a matrix and vector together.

Revision history for this message
Garth Wells (garth-wells) wrote :

On 10 May 2012 19:45, Johan Hake <email address hidden> wrote:
> On 05/10/2012 08:34 PM, Marie Rognes wrote:
>> On 05/10/2012 08:18 PM, Johan Hake wrote:
>>> mesh = UnitCube(5,5,5)
>>> VV = VectorFunctionSpace(mesh,"Lagrange",1)
>>> u = TrialFunction(VV)
>>> v = TestFunction(VV)
>>> Aij = diag(Constant((1,1,1)))
>>> Delta = Identity( mesh.ufl_cell().geometric_dimension())
>>> # Does not work (but works with sfc)
>>> assemble(inner(Aij*(grad(u)+Delta), grad(v))*dx)
>>> # Works
>>> assemble(inner(Aij*grad(u), grad(v))*dx)
>>
>> As far as I can see, your form has different ranks.
>> The error message then seems very correct.
>
> grad(u).rank() == 2
> Delta.rank() == 2
> Aij.rank() == 2
> (grad(u)+Delta).rank() == 2
> (Aij*(grad(u)+Delta)).rank() == 2
>
> Can you point our where it is wrong?
>

The form ranks are mixed up - u is a TrialFunction and Delta is a
constant. You're mixing linear and bilinear forms.

Garth

> Johan
>
> --
> You received this bug notification because you are a member of FFC Core
> Team, which is subscribed to FFC.
> https://bugs.launchpad.net/bugs/997739
>
> Title:
>  Rank analysis is wrong
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/ffc/+bug/997739/+subscriptions

Revision history for this message
Johan Hake (johan-hake) wrote : Re: [Bug 997739] Re: Rank analysis is wrong

On 05/10/2012 08:54 PM, Marie Rognes wrote:
> There is a difference between tensor rank and form rank. You are printing
> the tensor ranks. The form rank would be number of Arguments.
> So, in your example:
>
> (grad(u) + Delta) * grad(v) = grad(u)*grad(v) + Delta*grad(v)
>
> The first term on the right-hand side has form rank 2 (there is a TestFunction
> and a TrialFunction involved) while the other has form rank 1 (just a TestFunction).

Tensors, smensors!!

> DOLFIN can only assemble (and FFC only generate code for) forms
> in which all terms have the same (form) rank.
> In short, you can't add a matrix and vector together.

Will target this as a bug for sfc :)

affects: ffc → fenics-syfi
description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.