Unable to assemble form.

Asked by Katharina Höhne

Hello,
I try to define a norm (res) in UFL:

element = FiniteElement("Lagrange", triangle, 1)

u = TrialFunction(element)
v = TestFunction(element)
f = Coefficient(element)
kappa = 100

a = inner(grad(u), grad(v))*dx + kappa*kappa*inner(u, v)*dx
L = f*v*dx

res=inner(f+div(grad(u))-kappa*kappa*u,f+div(grad(u))-kappa*kappa*u)*dx

And then, in the C++-Code, I take this:

Poisson::BilinearForm res(V,V);
and later

x=y*assemble(res);

But unfortunately, I get this message:

*** Error: Unable to assemble form.
*** Reason: Expecting a scalar form but rank is 2.
*** Where: This error was encountered inside assemble.cpp.

What should I do. Compiling works, it is a runtime error...

Question information

Language:
English Edit question
Status:
Answered
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Johan Hake (johan-hake) said :
#1

Please provide a minimal but runnable code that reproduce the error.

Johan

On Saturday January 14 2012 16:15:40 Katharina Höhne wrote:
> New question #184707 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/184707
>
> Hello,
> I try to define a norm (res) in UFL:
>
> element = FiniteElement("Lagrange", triangle, 1)
>
> u = TrialFunction(element)
> v = TestFunction(element)
> f = Coefficient(element)
> kappa = 100
>
> a = inner(grad(u), grad(v))*dx + kappa*kappa*inner(u, v)*dx
> L = f*v*dx
>
> res=inner(f+div(grad(u))-kappa*kappa*u,f+div(grad(u))-kappa*kappa*u)*dx
>
> And then, in the C++-Code, I take this:
>
> Poisson::BilinearForm res(V,V);
> and later
>
> x=y*assemble(res);
>
> But unfortunately, I get this message:
>
> *** Error: Unable to assemble form.
> *** Reason: Expecting a scalar form but rank is 2.
> *** Where: This error was encountered inside assemble.cpp.
>
> What should I do. Compiling works, it is a runtime error...

Can you help with this problem?

Provide an answer of your own, or ask Katharina Höhne for more information if necessary.

To post a message you must log in.