fenics team mailing list archive
-
fenics team
-
Mailing list archive
-
Message #00398
Re: user defined operator cov(A)
Sorry I have too many questions!
I realized that I can just assemble adj(F) in the main program and pass it as a parameter, like this:
a = dot(grad(v), mult(A,grad(u)))*dx
where A will be the assembled adj(F).
However, when I compile it using ffc, I got the following error:
a = dot(grad(v), mult(A,grad(u)))*dx
NameError: name 'A' is not defined
But I don't know how to declare a matrix A in the form file!
Can anyone help me?
Thank you.
Best,
Chong Luo
----- Original Message ----
From: Chong Luo <luo.chong@xxxxxxxxx>
To: Chong Luo <luo.chong@xxxxxxxxx>
Sent: Friday, March 21, 2008 7:39:05 PM
Subject: Re: [FEniCS-dev] user defined operator cov(A)
I tried to make the algorithm simpler, but it still doesn't work:
def adj(A):
B = A
B[1] = cross(A[2],A[3])
B[2] = cross(A[1],A[3])
B[3] = cross(A[1],A[2])
return B
a(F) = dot(grad(v), mult(adj(F),grad(u)))*dx
L = dot(v, f)*dx + dot(v('+'), g('+'))*dS
File "test.py", line 36
a(F) = dot(grad(v), mult(adj(F),grad(u)))*dx
SyntaxError: can't assign to function call
Any help will be appreciated!
Best,
Chong Luo
----- Original Message ----
From: Chong Luo <luo.chong@xxxxxxxxx>
To: fenics-dev@xxxxxxxxxx
Sent: Friday, March 21, 2008 6:55:55 PM
Subject: Re: [FEniCS-dev] user defined operator cov(A)
Sorry for my bad English. I meant "adjoint matrix", not "covariance matrix".
Best,
Chong Luo
----- Original Message ----
From: Chong Luo <luo.chong@xxxxxxxxx>
To: fenics-dev@xxxxxxxxxx
Sent: Thursday, March 20, 2008 9:46:42 PM
Subject: [FEniCS-dev] user defined operator cov(A)
I saw in FFC manual that in the .form files, we can "define new operators
using standard Python syntax".
I want to define the covariance of a matrix A, so I wrote the following code:
def cov(A):
B = A
for i in range(1, 3):
for j in range(1, 3):
B[i][j] = A[(i+2)%3][(j+2)%3]*A[(i+1)%3][(j+1)%3] \
-A[(i+2)%3][(j+1)%3]*A[(i+1)%3][(j+2)%3]
a(F) = dot(grad(v), mult(cov(F), grad(u)))*dx
L = dot(v, f)*dx + dot(v('+'), g('+'))*dS
However, I got this error:
File "Elasticity.py", line 36
a(F) = dot(grad(v), mult(cov(F), grad(u)))*dx
SyntaxError: can't assign to function call
Any idea how to make it work? Similarly I'd like to implement
the operator d^2(det(F))/dF^2, because these are needed in
incompressible nonlinear elasticity.
Thank you!
Best,
Chong Luo
PhD student in Applied Math
University of Minnesota
Never miss a thing. Make Yahoo your homepage.
-----Inline Attachment Follows-----
_______________________________________________
FEniCS-dev mailing list
FEniCS-dev@xxxxxxxxxx
http://www.fenics.org/mailman/listinfo/fenics-dev
Looking for last minute shopping deals?
Find them fast with Yahoo! Search.
-----Inline Attachment Follows-----
_______________________________________________
FEniCS-dev mailing list
FEniCS-dev@xxxxxxxxxx
http://www.fenics.org/mailman/listinfo/fenics-dev
Never miss a thing. Make Yahoo your homepage.
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs