Subject: [UFL-dev] Element problems

From: Andy Ray Terrel <[email-masked]>
Date: Mon, 15 Jun 2009 14:15:19 +0200

Hello,

I'm still getting a hang of this but I was trying to do some things
with mixed elements and derivatives.  I'm not sure if I have the bug
or if ufl has a bug but the following doesn't pass ufl-analyse.

sElem = TensorElement("DG", triangle, 1)
vElem = VectorElement("CG", triangle, 2)

mElem = sElem + vElem

phi, v = TestFunctions(mElem)
sigma, u = TrialFunctions(mElem)

sF = Function(sElem)

f = inner(sF, dot(u, grad(sF)))*dx
F = derivative(f, sF, phi)
J = derivative(F, sF, sigma)

It seems that the TestFunctions function doesn't return a proper
TestFunction but a list of things. I can do the following but then I
loose the mixed element, which I don't know if ffc could handle.

sElem = TensorElement("DG", triangle, 1)
vElem = VectorElement("CG", triangle, 2)

mElem = sElem + vElem

phi = TestFunction(sElem)
v = TestFunction(vElem)
sigma = TrialFunction(sElem)
u = TrialFunction(vElem)

sF = Function(sElem)

f = inner(sF, dot(u, grad(sF)))*dx
F = derivative(f, sF, phi)
J = derivative(F, sF, sigma)

Any thoughts on either my bug or ufl please let me know.

-- Andy

---

From: "Garth N. Wells" <[email-masked]>
Date: Mon, 15 Jun 2009 13:17:45 +0100

> sigma, u = TrialFunctions(mElem)

The above is the problem. You need to use 'split'. Look at the 
cahn-hilliard demo for an example of how to do it.

Garth

> _______________________________________________
> UFL-dev mailing list
> [email-masked]
> http://fenics.org/mailman/listinfo/ufl-dev

---

From: "Johan Hake" <[email-masked]>
Date: Mon, 15 Jun 2009 15:01:37 +0200

> cahn-hilliard demo for an example of how to do it.

I might be totaly of here but does not TestFunctions and TrialFunctions
return a properly splitted FooFunction?

What I mean is:

  dk, dc = TestFunctions(ME)

should be the same as:

  du = TestFunction(ME)
  dk, dc = split(du)

Please correct me if I am wrong.

Isn't the problem the sF Function, which is defined using an element which
is not 'properly mixed'?

>> TestFunction but a list of things.

I think the list you refere to is the somewhat unreadable representation
of the view of the TestFunctions, which should be the correct one.

Johan

> I can do the following but then I

---

From: "Garth N. Wells" <[email-masked]>
Date: Mon, 15 Jun 2009 14:06:41 +0100

> Please correct me if I am wrong.

Yes, but former approach doesn't provide access to the 'mother' function 
du, and it's with respect to du that you want to compute the derivative.

Garth

---

From: Andy Ray Terrel <[email-masked]>
Date: Mon, 15 Jun 2009 15:08:46 +0200

Yup using the following fixes the problem nicely.

-- Andy

mElem = sElem + vElem

mTest = TestFunction(mElem)
phi, v = split(mTest)
mTrial = TrialFunction(mElem)
sigma, u = split(mTrial)

mF = Function(mElem)
sF, vF = split(mF)

f = inner(sF, dot(vF, grad(sF)))*dx
F = derivative(f, mF, mTest)
J = derivative(F, mF, mTrial)

On Mon, Jun 15, 2009 at 3:06 PM, Garth N. Wells<[email-masked]> wrote:
> Yes, but former approach doesn't provide access to the 'mother' function du,
> and it's with respect to du that you want to compute the derivative.
>
> Garth
>
>

---

From: "Johan Hake" <[email-masked]>
Date: Mon, 15 Jun 2009 15:18:15 +0200

> du, and it's with respect to du that you want to compute the derivative.

Ahh, forgot the derivative.

Good to know I was not totally of ;)

Johan