Subject: [FEniCS-dev] user defined operator cov(A)

From: Chong Luo <[email-masked]>
Date: Thu, 20 Mar 2008 19:46:42 -0700 (PDT)

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

      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

---

From: Chong Luo <[email-masked]>
Date: Fri, 21 Mar 2008 16:55:55 -0700 (PDT)

Sorry for my bad English. I meant "adjoint matrix", not "covariance matrix".

Best,
Chong Luo
----- Original Message ----
From: Chong Luo <[email-masked]>
To: [email-masked]
Sent: Thursday, March 20, 2008 9:46:42 PM
Subject: [FEniCS-dev] user defined operator cov(A)

def cov(A):
    B = A
    for i in range(1, 3):
        for j in range(1, 3):

Thank you!

Best,

Chong Luo

      Never miss a thing.   Make Yahoo your homepage.

-----Inline Attachment Follows-----

_______________________________________________
FEniCS-dev mailing list
[email-masked]
http://www.fenics.org/mailman/listinfo/fenics-dev

---

From: Chong Luo <[email-masked]>
Date: Sat, 22 Mar 2008 10:57:08 -0700 (PDT)

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 <[email-masked]>
To: Chong Luo <[email-masked]>
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 <[email-masked]>
To: [email-masked]
Sent: Friday, March 21, 2008 6:55:55 PM
Subject: Re: [FEniCS-dev] user defined operator cov(A)

Best,
Chong Luo
----- Original Message ----
From: Chong Luo <[email-masked]>
To: [email-masked]
Sent: Thursday, March 20, 2008 9:46:42 PM
Subject: [FEniCS-dev] user defined operator cov(A)

def cov(A):
    B = A
    for i in range(1, 3):
        for j in range(1, 3):

Thank you!

Best,

Chong Luo

-----Inline Attachment Follows-----

      Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.

-----Inline Attachment Follows-----

      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs