← Back to team overview

ufl team mailing list archive

Re: [Dolfin] [Question #152702]: indices in an expression?

 


On 13/04/11 19:31, Martin Sandve Alnæs wrote:
> That should be fairly easy to do, can be handled similarly to Identity.
>

Yes - I had a look in the code this afternoon because I thought that it
may have already been implemented somewhere close to Identity.

> I = Identity(cell.d)
> f = I[i,j] * ...
> 
> e = Permutation(cell.d)
> f = e[i,j,l] * v[j]*w[i]*v[l]*dx
> 
> Other suggestions for naming?
> 

Maybe

   e = PermutationSymbol()

? 'Permutation' sounds a bit generic.

I don't think that it needs the cell dimension since it's only defined
for d = 3.

Garth


> Martin
> 
> On 13 April 2011 20:24, Garth N. Wells <gnw20@xxxxxxxxx
> <mailto:gnw20@xxxxxxxxx>> wrote:
> 
>     The permutation symbol should be added to UFL.
> 
>     Garth
> 
>     On 13/04/11 19:20, Martin Sandve Alnæs wrote:
>     > 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
>     <mailto:question152702@xxxxxxxxxxxxxxxxxxxxx>
>     > <mailto:question152702@xxxxxxxxxxxxxxxxxxxxx
>     <mailto: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
>     <mailto:dolfin@xxxxxxxxxxxxxxxxxxx>
>     >     <mailto:dolfin@xxxxxxxxxxxxxxxxxxx
>     <mailto:dolfin@xxxxxxxxxxxxxxxxxxx>>
>     >     Unsubscribe : https://launchpad.net/~dolfin
>     >     More help   : https://help.launchpad.net/ListHelp
>     >
>     >
>     >
>     >
>     > _______________________________________________
>     > Mailing list: https://launchpad.net/~dolfin
>     > Post to     : dolfin@xxxxxxxxxxxxxxxxxxx
>     <mailto:dolfin@xxxxxxxxxxxxxxxxxxx>
>     > Unsubscribe : https://launchpad.net/~dolfin
>     > More help   : https://help.launchpad.net/ListHelp
> 
>     _______________________________________________
>     Mailing list: https://launchpad.net/~dolfin
>     Post to     : dolfin@xxxxxxxxxxxxxxxxxxx
>     <mailto:dolfin@xxxxxxxxxxxxxxxxxxx>
>     Unsubscribe : https://launchpad.net/~dolfin
>     More help   : https://help.launchpad.net/ListHelp
> 
> 



Follow ups

References