← Back to team overview

fenics team mailing list archive

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








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