Subject: [Fenics] Does the derivative function work for multi functionspaces

From: HONGTAO CHEN <[email-masked]>
Date: Tue, 6 Jul 2010 18:33:14 -0500

Now the weak form is for coupled function spaces and I want to get the
Gateaux derivative of the form by 'derivative' function.
Code:

from dolfin import *
mesh = UnitSquare(10,10)

V1 = FunctionSpace(mesh, 'CG', 1)
V2 = FunctionSpace(mesh, 'CG', 1)
V = V1+V2
(v1,v2) = TestFunctions(V)
def q(u):
    return (1+u)**2

u1=Function(V1)
u2=Function(V2)
L = dot(q(u2)*grad(u1),grad(v1))*dx+
dot(q(u1)*grad(u2),grad(v2))*dx+(u1*v1+u2*v2)*dx

(du1,du2)=TrialFunctions(V)

a1=derivative(L,u1,du1)              #due to u1+\epsilon * du1
a2=derivative(L,u2,du2)             #due to u2+\epsilon*du2
a=a1+a2

But it raise error message below:
UFLException: Expecting Argument instance, not <class
'ufl.indexed.Indexed'>.

I don't know how to modify the problem, but I hope it can work as it will be
very convenient for problems
where differentiating the form by hand implies lengthy calculations. Thanks!

--Hongtao

---

From: "Garth N. Wells" <[email-masked]>
Date: Wed, 07 Jul 2010 01:07:19 +0100

On 07/07/10 00:33, HONGTAO CHEN wrote:
> I don't know how to modify the problem, but I hope it can work as it
> will be very convenient for problems

Look at the cahn-hilliard demo to see how to use differentiation with 
mixed spaces.

Garth

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