Hi,
Consider the following code:
mesh = dolfin.UnitSquareMesh(1,1)
dX = dolfin.dx(mesh)
ve = dolfin.VectorElement(
family="Quadrature",
cell=mesh.ufl_cell(),
degree=1,
quad_scheme="default")
class MyExpr2(dolfin.Expression):
def __init__(self, **kwargs):
pass
def value_shape(self):
return (2,)
def eval(self, Expr, X):
print " X = " + str(X)
Expr[0] = 0
Expr[1] = 1
print " Expr = " + str(Expr)
myExpr = MyExpr(element=ve)
dolfin.assemble(dolfin.dot(myExpr,dolfin.Constant((1,1)))*dX, form_compiler_parameters={'quadrature_degree': 1})
Which returns
X = [ 0.66666667 0.33333333]
Expr = [ 0. 1.]
X = [ 0.66666667 0.33333333]
Expr = [ 0. 1.]
X = [ 0.33333333 0.66666667]
Expr = [ 0. 1.]
X = [ 0.33333333 0.66666667]
Expr = [ 0. 1.]
Clearly, the expression is evaluated twice at each integration point. I assume that components are evaluated one by one. Is there a way to evaluate them all at once? Thanks!