← Back to team overview

dolfin team mailing list archive

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

 

Question #152702 on DOLFIN changed:
https://answers.launchpad.net/dolfin/+question/152702

Anders Logg posted a new comment:
On Thu, Apr 14, 2011 at 10:03:42AM -0000, B. Emek Abali wrote:
> Question #152702 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/152702
>
> B. Emek Abali posted a new comment:
> probably not the coolest way but I solved it as that way, one can also
> implement it like dolfin.Identity class
>
> class levicivita2(Expression):
> 	def eval(self, out, x):
> 		out[0,0] = 0.0
> 		out[0,1] = 1.0
> 		out[1,1] = 0.0
> 		out[1,0] = -1.0
> 	def value_shape(self):
> 		return (3,3)
>
> class levicivita3(Expression):
> 	def eval(self, out, x):
> 		out[0,0,0] = 0.0
> 		out[1,1,1] = 0.0
> 		out[2,2,2] = 0.0
> 		out[0,1,2] = 1.0
> 		out[1,2,0] = 1.0
> 		out[2,0,1] = 1.0
> 		out[2,1,0] = -1.0
> 		out[1,0,2] = -1.0
> 		out[0,2,1] = -1.0
> 	def value_shape(self):
> 		return (3,3,3)
>
> e=levicivita3()
> form = v[j]*w[i]*e[i,j,l]*v[l]*dx

This might work but it will most likely be slow since it will result
in a run-time callback (during assembly) to the eval function you have
defined.

--
Anders

-- 
You received this question notification because you are a member of
DOLFIN Team, which is an answer contact for DOLFIN.