# Absent Coefficient in Linear Form

Hello

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

element = FiniteElement(

v = TestFunction(

u = TrialFunction(

kappa = Coefficient(

u_old = Coefficient(

f = Coefficient(

dt = ....

a = u*v*dx + theta*dt*

L = ((u_old + dt*f)*v - (1-theta)

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 : | #1 |

as Maximoff wrote:

> New question #95954 on DOLFIN:

> https:/

>

> Hello

>

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

>

> element = FiniteElement(

>

> v = TestFunction(

> u = TrialFunction(

> kappa = Coefficient(

> u_old = Coefficient(

> f = Coefficient(

>

> dt = ....

>

> a = u*v*dx + theta*dt*

> L = ((u_old + dt*f)*v - (1-theta)

>

> 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 : | #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)

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 : | #3 |

Pietro Maximoff wrote:

> Question #95954 on DOLFIN changed:

> https:/

>

> 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)

> 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)

UFL throws it away.

Garth

Pietro Maximoff (segment-x) said : | #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.