dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #22607
Re: [Question #152702]: indices in an expression?
Python does not know anything about implicit index summation, so in your
code e() is only called once, and reaches the else condition and thus
returns 0.0.
Similar to as_vector, you can use the as_tensor function, since you need
three dimensions.
Martin
On 13 April 2011 19:04, B. Emek Abali
<question152702@xxxxxxxxxxxxxxxxxxxxx>wrote:
> New question #152702 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/152702
>
> May be a non-needed trial for some, but I try to define an expression
> (permutation symbol)
>
> def e(i,j,k):
> if (i,j,k) == (1.0,2.0,3.0): return 1.0
> elif (i,j,k) == (2.0,3.0,1.0): return 1.0
> elif (i,j,k) == (3.0,1.0,2.0): return 1.0
> elif (i,j,k) == (3.0,2.0,1.0): return -1.0
> elif (i,j,k) == (2.0,1.0,3.0): return -1.0
> elif (i,j,k) == (1.0,3.0,2.0): return -1.0
> else: return 0.0
>
> and use (with summation over indices, it is a curl operator contracted with
> w) in the form like
>
> f=v[j]*w[i]*e(i,j,l)*v[l]*dx
>
> which raises:
> ufl.log.UFLException: Trying to integrate expression of rank 0 with free
> indices
>
> Do I have to use as_vector(...) type definition to sum with indices or is
> there a nice possibility to let it sum over the arguments of e(...)
> expression?
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dolfin
> Post to : dolfin@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dolfin
> More help : https://help.launchpad.net/ListHelp
>
Follow ups
References