# Absent Coefficient in Linear Form

Asked by Pietro Maximoff on 2010-01-02

Hello

I have a ufl file like so (for the Heat Equation with time-stepping via the theta-method):

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

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

dt = ....

a = u*v*dx + theta*dt*kappa*inner(grad(u), grad(v))*dx
L = ((u_old + dt*f)*v - (1-theta)*dt*kappa*inner(grad(u), grad(v)))*dx

The problem is that I can't assign kappa to L.kappa in the linear form, i.e.,

L.kappa = kappa

This is fine though for the Bilinear form.

On examining the generated header file, it turns out that the LinearForm class has no member kappa which is exactly the error message given.

What am I doing wrong?

Best wishes

Pietro

## Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Pietro Maximoff
Solved:
2010-01-02
Last query:
2010-01-02
Last reply:
2010-01-02
 Garth Wells (garth-wells) said on 2010-01-02: #1

as Maximoff wrote:
> New question #95954 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/95954
>
> Hello
>
> I have a ufl file like so (for the Heat Equation with time-stepping via the theta-method):
>
> element = FiniteElement("Lagrange", "triangle", 2)
>
> v = TestFunction(element)
> u = TrialFunction(element)
> kappa = Coefficient(element)
> u_old = Coefficient(element)
> f = Coefficient(element)
>
> dt = ....
>
> a = u*v*dx + theta*dt*kappa*inner(grad(u), grad(v))*dx
> L = ((u_old + dt*f)*v - (1-theta)*dt*kappa*inner(grad(u), grad(v)))*dx
>
> The problem is that I can't assign kappa to L.kappa in the linear form, i.e.,
>
> L.kappa = kappa
>
> This is fine though for the Bilinear form.
>
> On examining the generated header file, it turns out that the LinearForm class has no member kappa which is exactly the error message given.
>
> What am I doing wrong?
>

Are you setting theta=0? In this case, UFL will discard the entire
product involving theta.

Also, your form is not correct. You cannot have the trial function u
appearing in L.

Garth

> Best wishes
>
> Pietro
>
>

 Pietro Maximoff (segment-x) said on 2010-01-02: #2

I intend to use different theta values but in this particular instance, theta = 1.

You're right, L should read:

L = ((u_old + dt*f)*v - (1-theta)*dt*kappa*inner(grad(u_old), grad(v)))*dx

Even then, kappa is absent from the LinearForm class and hence, can't be set by

L.kappa = kappa

I wonder why this is the case.

 Garth Wells (garth-wells) said on 2010-01-02: #3

Pietro Maximoff wrote:
> Question #95954 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/95954
>
> Status: Answered => Open
>
> Pietro Maximoff is still having a problem:
> I intend to use different theta values but in this particular instance,
> theta = 1.
>
> You're right, L should read:
>
> L = ((u_old + dt*f)*v - (1-theta)*dt*kappa*inner(grad(u_old),
> grad(v)))*dx
>
> Even then, kappa is absent from the LinearForm class and hence, can't be
> set by
>
> L.kappa = kappa
>
> I wonder why this is the case.
>

(1-theta) = 0 if theta=1 -> (1-theta)*dt*kappa*inner(grad(u_old) = 0 ->
UFL throws it away.

Garth

 Pietro Maximoff (segment-x) said on 2010-01-02: #4

Ahh... I see. Thanks Garth. I just assumed that even though that part of the expression will be zero, kappa'll still be generated.

To post a message you must log in.