Subject: [Ufl] updating an index

From: Mehdi Nikbakht <[email-masked]>
Date: Wed, 21 Apr 2010 12:09:41 +0200

Hello,

I am just started examining ufl to expand integrands. To perform the
expansion, I have defined a transformation derived form
ReusedTransformer. I succeeded expanding ufl integrands for scaler
functions, but I encountered a problem while trying to work with vector
functions.

Assume that I have a linear form defined as,

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

u = TrialFunction(element)
v = TestFunction(element)

f = Coefficient(element)
g = Coefficient(element)

L = inner(f + g, v)*dx

which will be interpersonal as,
sum_{i_0} ((v_0)[i_0]) * ((w_0 + w_1)[i_0]) 

I want to use ufl to expand linear form to, 

L = inner(f, v)*dx + inner(g, v)*dx
which should be interpreted as,

sum_{i_0} ((v_0)[i_0]) * ((w_0)[i_0]) + sum_{i_1} ((v_0)[i_1]) *
(( w_1)[i_1]) 

Now I am getting
sum_{i_0} ((v_0)[i_0]) * ((w_0)[i_0]) + sum_{i_0} ((v_0)[i_0]) *
(( w_1)[i_0])

which fails by an error message as,

FAILURE in reuse_if_possible:
type(o) = <class 'ufl.indexsum.IndexSum'>
operands =

sum_{i_0} ((v_0)[i_0]) * ((w_0)[i_0])  + sum_{i_0} ((v_0)[i_0]) *
((w_1)[i_0]) 

It seems to perform this extension, I need to update indices defined for
summation. My question is how I can update an index like i_0 to i_1? 

I hope that my question was clear enough.
Mehdi

---

From: Kristian Oelgaard <[email-masked]>
Date: Wed, 21 Apr 2010 16:18:44 +0200 (CET)

> summation. My question is how I can update an index like i_0 to i_1?

I don't see why you need one of the indices to be i_1, the above code seems to make just as much sense.
I think there is something else going wrong in your transformer class.

Kristian

> _______________________________________________
> Mailing list: https://launchpad.net/~ufl
> Post to     : [email-masked]
> Unsubscribe : https://launchpad.net/~ufl
> More help   : https://help.launchpad.net/ListHelp
>

---

From: Mehdi Nikbakht <[email-masked]>
Date: Wed, 21 Apr 2010 16:32:20 +0200

> I think there is something else going wrong in your transformer class.

If we compile,

the ufl integrand is,

although having the same indices for summation is valid for these two
terms in integrand in index notation, but it seems that it is not case
for ufl.

Mehdi

---

From: Kristian Oelgaard <[email-masked]>
Date: Wed, 21 Apr 2010 16:43:57 +0200 (CET)

> sum_{i_0} ((v_0)[i_0]) * ((w_0)[i_0]) + sum_{i_1} ((v_0)[i_1]) *

Yes, but here you also have two integrals --> two integrands.

If you expand:
L = inner((f +g ), v)*dx, you have just one, and I think you should get:

sum( sum_i0( v[i0]*f[i0]), sum_i0( v[i0]*g[i0]) )

for the integrand such that the integral will be:

L = (v:f + v:g)*dx

Kristian